From 0e64fd711decb168c643edc62e6bbf35b6518cd4 Mon Sep 17 00:00:00 2001 From: Krusty/Benediction Date: Tue, 19 Sep 2023 20:39:28 +0200 Subject: [PATCH] [bndbuild] Fix a failing test --- cpclib-bndbuild/src/deps.rs | 23 ++++++++++++++++++++++- cpclib-bndbuild/tests/build_dummy.rs | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cpclib-bndbuild/src/deps.rs b/cpclib-bndbuild/src/deps.rs index cbf8a6ef..fddb1084 100644 --- a/cpclib-bndbuild/src/deps.rs +++ b/cpclib-bndbuild/src/deps.rs @@ -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, D::Error> @@ -179,6 +185,7 @@ impl Rule { true } } + } #[derive(Deserialize)] @@ -199,6 +206,20 @@ impl Rules { /// Get the rule for this target (of course None is returned for leaf files) pub fn rule>(&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)) diff --git a/cpclib-bndbuild/tests/build_dummy.rs b/cpclib-bndbuild/tests/build_dummy.rs index 3645947f..95ed0feb 100644 --- a/cpclib-bndbuild/tests/build_dummy.rs +++ b/cpclib-bndbuild/tests/build_dummy.rs @@ -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()); }