-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Bug Report
Description
The generated android/CMakeLists.txt uses non-canonical relative paths like cpp/../file.cpp instead of the canonical form ../cpp/file.cpp. While both are technically valid, the non-canonical form can cause issues with some CMake versions and build tools.
Problem
When relative_to() calculates paths from android/CMakeLists.txt to files in cpp/, the pathdiff crate generates paths like:
cpp/../generated/file.cpp
cpp/../module.cppImpact
- Some CMake configurations may fail to find source files with non-canonical paths
- Build errors in certain environments
- Less readable generated CMakeLists.txt files
Expected Behavior
Paths should be in canonical form:
../cpp/generated/file.cpp
../cpp/module.cppRoot Cause
The relative_to() function in crates/ubrn_cli/src/codegen/mod.rs uses pathdiff::diff_utf8_paths() directly without normalizing the result. The pathdiff crate can produce non-canonical paths when calculating relative paths.
Reproduction
- Generate Android bindings for any project
- Check
android/CMakeLists.txt - Observe
cpp/../patterns in source file paths
References
- CMake best practices prefer canonical relative paths
- Issue discovered while testing 32-bit ARM fix (see PR fix: Use uint64_t for RustBuffer fields to fix 32-bit ARM crash #313)
Fix
PR #313 now includes a fix that lexically normalizes paths by processing components and eliminating dir/.. patterns.
Metadata
Metadata
Assignees
Labels
No labels