Skip to content

Commit

Permalink
warn on .cpp that isn't .hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Feb 19, 2024
1 parent 5b5ca30 commit b822c44
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions bin/src/modules/rapifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,24 @@ pub fn rapify(addon: &Addon, path: &WorkspacePath, ctx: &Context) -> Result<Repo
if !configreport.errors().is_empty() {
return Ok(report);
}
let out = if path.filename().to_lowercase() == "config.cpp" {
let (version, cfgpatch) = configreport.required_version();
let mut file = path;
let mut span = 0..0;
if let Some(cfgpatch) = cfgpatch {
let map = processed.mapping(cfgpatch.name().span.start).unwrap();
file = map.original().path();
span = map.original().start().0..map.original().end().0;
let out = if std::path::Path::new(&path.filename())
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("cpp"))
{
if path.filename() == "config.cpp" {
let (version, cfgpatch) = configreport.required_version();
let mut file = path;
let mut span = 0..0;
if let Some(cfgpatch) = cfgpatch {
let map = processed.mapping(cfgpatch.name().span.start).unwrap();
file = map.original().path();
span = map.original().start().0..map.original().end().0;
}
addon
.build_data()
.set_required_version(version, file.to_owned(), span);
}
addon
.build_data()
.set_required_version(version, file.to_owned(), span);
path.parent().join("config.bin").unwrap()
path.parent().with_extension("bin")?
} else {
path.to_owned()
};
Expand All @@ -151,10 +156,13 @@ pub fn rapify(addon: &Addon, path: &WorkspacePath, ctx: &Context) -> Result<Repo

pub fn can_rapify(path: &str) -> bool {
let path = PathBuf::from(path);
let name = path
let ext = path
.extension()
.unwrap_or_else(|| std::ffi::OsStr::new(""))
.to_str()
.unwrap();
["cpp", "rvmat", "ext"].contains(&name)
if ext == "cpp" && path.file_name() != Some(std::ffi::OsStr::new("config.cpp")) {
warn!("{} - cpp files other than config.cpp are usually not intentional. use hpp for includes", path.file_name().unwrap().to_str().unwrap());
}
["cpp", "rvmat", "ext"].contains(&ext)
}

0 comments on commit b822c44

Please sign in to comment.