Skip to content

Commit

Permalink
On non-windows, when preprocessing with clang-cl, -xc needs to be -Xc…
Browse files Browse the repository at this point in the history
…lang -xc

Closes: #68
  • Loading branch information
nabijaczleweli committed Jul 15, 2024
1 parent 21fd920 commit e98e9aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/non_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ impl Compiler {
CompilerType::LlvmRc { has_no_preprocess } => {
let preprocessed_path = format!("{}/{}-preprocessed.rc", out_dir, prefix);
fs::write(&preprocessed_path,
apply_macros_cc(cc::Build::new().define("RC_INVOKED", None), macros)
.flag("-xc")
cc_xc(apply_macros_cc(cc::Build::new().define("RC_INVOKED", None), macros))
.file(resource)
.cargo_metadata(false)
.include(out_dir)
Expand Down Expand Up @@ -137,6 +136,14 @@ fn apply_macros_cc<'t, Ms: AsRef<OsStr>, Mi: IntoIterator<Item = Ms>>(to: &'t mu
to
}

fn cc_xc(to: &mut cc::Build) -> &mut cc::Build {
if to.get_compiler().is_like_msvc() { // clang-cl
to.flag("-Xclang");
}
to.flag("-xc");
to
}

fn try_command(cmd: &mut Command, exec: &Path, action: &str, whom: &str, whre: &str) {
match cmd.status() {
Ok(stat) if stat.success() => {}
Expand Down

0 comments on commit e98e9aa

Please sign in to comment.