Skip to content

Commit

Permalink
Handle spaces in source/build paths
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Nov 21, 2024
1 parent 91689c4 commit d05559b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ impl CmakeBuilder {
if parent_dir.is_some() && (target_family() == "unix" || target_env() == "gnu") {
let parent_dir = parent_dir.unwrap();
let cc_build = cc::Build::new();
let flag = format!("-ffile-prefix-map={}=", parent_dir.display());
let flag = format!("\"-ffile-prefix-map={}=\"", parent_dir.display());
if let Ok(true) = cc_build.is_flag_supported(&flag) {
emit_warning(&format!("Using flag: {}", &flag));
cmake_cfg.asmflag(&flag);
cmake_cfg.cflag(&flag);
} else {
let flag = format!("-fdebug-prefix-map={}=", parent_dir.display());
let flag = format!("\"-fdebug-prefix-map={}=\"", parent_dir.display());
if let Ok(true) = cc_build.is_flag_supported(&flag) {
emit_warning(&format!("Using flag: {}", &flag));
cmake_cfg.asmflag(&flag);
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-sys/builder/cc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl CcBuilder {
env::set_var("CFLAGS", cflags);
}

if target_os() == "macos" && target_arch() == "x86_64" {
if target_os() == "macos" {
// This compiler error has only been seen on MacOS x86_64:
// ```
// clang: error: overriding '-mmacosx-version-min=13.7' option with '--target=x86_64-apple-macosx14.2' [-Werror,-Woverriding-t-option]
Expand Down
20 changes: 19 additions & 1 deletion aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,25 @@ impl CmakeBuilder {
self.output_lib_type,
);
let mut cflags = OsString::new();
cflags.push(cc_builder.prepare_builder().get_compiler().cflags_env());
let compiler = cc_builder.prepare_builder().get_compiler();
let args = compiler.args();
for (i, arg) in args.iter().enumerate() {
if i > 0 {
cflags.push(" ");
}
if let Some(arg) = arg.to_str() {
if arg.contains(' ') {
cflags.push("\"");
cflags.push(arg);
cflags.push("\"");
} else {
cflags.push(arg);
}
} else {
cflags.push(arg);
}
}

if !get_cflags().is_empty() {
cflags.push(" ");
cflags.push(get_cflags());
Expand Down

0 comments on commit d05559b

Please sign in to comment.