Skip to content

Commit

Permalink
build/util: prevent infinite loop if target/ not found
Browse files Browse the repository at this point in the history
Previously, if you attempted to use certain functions in the build_util
crate...and your output directory happened to not include any parent
directories with the exact name "target"...

...the build script would burn 100% of a core forever, until you killed
it.

This doesn't affect Hubris-proper but _does_ affect out of tree builds.
The original code was arguably wrong anyway, so, this fixes that.
  • Loading branch information
cbiffle committed Dec 10, 2024
1 parent 1757b8b commit a5a0335
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build/util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ pub fn expose_target_board() {
std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
loop {
let done = out_dir.file_name() == Some(OsStr::new("target"));
out_dir.pop();
if !out_dir.pop() {
panic!("can't find target/ in OUT_DIR");
}
if done {
break;
}
Expand Down

0 comments on commit a5a0335

Please sign in to comment.