Skip to content

Commit

Permalink
boards: build/linker: need to expand search path
Browse files Browse the repository at this point in the history
For relative imports to work in linker scripts we must include all of
the locations of the linker scripts in the linker search path. Since we
are already tracing through linker scripts we can do this fairly easily.
  • Loading branch information
bradjc committed Aug 30, 2024
1 parent 5d683f0 commit 0a19c34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion boards/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ fn track_linker_script<P: AsRef<Path>>(path: P) {
}
fn track_linker_script_inner(linker_script: std::path::PathBuf, directory: std::path::PathBuf) {
let path = std::path::absolute(directory.join(linker_script)).unwrap();
let parent_buf = path.parent().unwrap().to_path_buf();
let parent = path.parent().unwrap();
let parent_buf = parent.to_path_buf();

assert!(path.is_file(), "expected path {path:?} to be a file");

// Make sure we include the path of the linker script in the search so we
// can use relative imports inside the linker script.
println!("cargo:rustc-link-arg=-L{}", parent.display());

println!("cargo:rerun-if-changed={}", path.display());

// Find all the `INCLUDE <relative path>` lines in the linker script.
Expand Down

0 comments on commit 0a19c34

Please sign in to comment.