Skip to content

Commit

Permalink
[bndbuild] Fix a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Sep 19, 2023
1 parent eb0d098 commit 0e64fd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cpclib-bndbuild/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ where D: Deserializer<'de> {
.into_iter()
.map(|s| expand_glob(s.as_ref()))
.flatten()
.map(|s| if s.starts_with(r"./") || s.starts_with(r".\") {
s[2..].to_owned()
}
else {
s
})
.map(|s| PathBuf::from(s))
.collect_vec();

Ok(r)
Ok(dbg!(r))
}

fn deserialize_task_list<'de, D>(deserializer: D) -> Result<Vec<Task>, D::Error>
Expand Down Expand Up @@ -179,6 +185,7 @@ impl Rule {
true
}
}

}

#[derive(Deserialize)]
Expand All @@ -199,6 +206,20 @@ impl Rules {
/// Get the rule for this target (of course None is returned for leaf files)
pub fn rule<P: AsRef<Path>>(&self, tgt: P) -> Option<&Rule> {
let tgt = tgt.as_ref();

dbg!(tgt);

// remove current dir path if any
let tgt = if tgt.starts_with(r"./") {
tgt.strip_prefix(r"./").unwrap()
} else if dbg!(tgt.to_str().unwrap().starts_with(r".\")) {
Path::new(&tgt.to_str().unwrap()[2..])
}else {
tgt
};

dbg!(&tgt);

self.rules
.iter()
.find(|r| r.targets.iter().any(|tgt2| tgt2 == tgt))
Expand Down
2 changes: 2 additions & 0 deletions cpclib-bndbuild/tests/build_dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ fn test_dummy_phony() {
assert!(!builder.get_rule("distclean").unwrap().is_phony());
assert!(!builder.get_rule("clean").unwrap().is_phony());
assert!(!builder.get_rule("./dummy_logo.o").unwrap().is_phony());
assert!(!builder.get_rule(r".\dummy_logo.o").unwrap().is_phony());
assert!(!builder.get_rule("dummy_logo.o").unwrap().is_phony());
assert!(!builder.get_rule("./dummy.sna").unwrap().is_phony());
}

0 comments on commit 0e64fd7

Please sign in to comment.