Skip to content

Commit

Permalink
Merge pull request #3 from Traverse-Research/for-traverse-fix-spaces-…
Browse files Browse the repository at this point in the history
…in-paths

🌌 Use `build.rustflags` (and variants) as a replacement for environment variable to enable spaces in paths
  • Loading branch information
Jasper-Bekkers authored Sep 26, 2024
2 parents 20febe8 + 24a53e7 commit eb2f5c5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions xbuild/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl CargoBuild {
}

pub fn set_sysroot(&mut self, path: &Path) {
let arg = format!("--sysroot={}", path.display());
let arg = format!("--sysroot=\"{}\"", path.display());
self.add_cflag(&arg);
self.add_link_arg(&arg);
}
Expand All @@ -480,10 +480,24 @@ impl CargoBuild {
}

pub fn exec(mut self) -> Result<()> {
// TODO: CARGO_ENCODED_RUSTFLAGS doesn't support this?
// self.cargo_target_env("ENCODED_RUSTFLAGS", &self.rust_flags.join(SEP));
self.cmd
.env("CARGO_ENCODED_RUSTFLAGS", &self.rust_flags.join(SEP));
if !self.rust_flags.is_empty() {
let rustflags =
toml::to_string(&self.rust_flags).expect("serializing a string should never fail");

let mut cargo_args: Vec<String> = vec![];

cargo_args.push("--config".into());
if let Some(triple) = self.triple {
cargo_args.push(format!("target.{}.rustflags={}", triple, rustflags));
} else {
cargo_args.push(format!("build.rustflags={}", rustflags));
}

self.cmd.args(cargo_args);
}

self.cmd.env("CC_SHELL_ESCAPED_FLAGS", "1");

self.bindgen_env(&self.c_flags.clone());
self.cc_triple_env("CFLAGS", &self.c_flags.clone());
// These strings already end with a space if they're non-empty:
Expand Down

0 comments on commit eb2f5c5

Please sign in to comment.