Skip to content

Commit 20b48c5

Browse files
committed
fix: Replace cpp/.. with ../cpp in generated paths for CMake compatibility
The pathdiff crate generates 'cpp/..' when calculating relative paths from android/ to cpp/, but CMake and build tools prefer the canonical '../cpp' form. This fix applies a simple string replacement to normalize the paths, matching the behavior of the existing workaround script. Fixes: #315
1 parent 2bfdedd commit 20b48c5

File tree

1 file changed

+7
-1
lines changed
  • crates/ubrn_cli/src/codegen

1 file changed

+7
-1
lines changed

crates/ubrn_cli/src/codegen/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ pub(crate) trait RenderedFile: DynTemplate {
2626
let from = file
2727
.parent()
2828
.expect("Expected this file to have a directory");
29-
pathdiff::diff_utf8_paths(to, from).expect("Should be able to find a relative path")
29+
let path = pathdiff::diff_utf8_paths(to, from).expect("Should be able to find a relative path");
30+
31+
// Fix non-canonical paths: pathdiff can generate "cpp/.." when "../cpp" is more canonical
32+
// This happens when calculating paths between sibling directories (e.g., android/ to cpp/)
33+
// CMake and other tools prefer the "../dir" form over "dir/.." even though both work
34+
let path_str = path.as_str().replace("cpp/..", "../cpp");
35+
Utf8PathBuf::from(path_str)
3036
}
3137
fn filter_by(&self) -> bool {
3238
true

0 commit comments

Comments
 (0)