Skip to content

Commit

Permalink
make xarch generate two arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jul 28, 2024
1 parent 2489187 commit 0191795
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,25 @@ mod test {
);
}

#[test]
fn test_parse_xarch() {
let a = parses!(
"-c",
"foo.c",
"-o",
"foo.o",
"-Xarch_arm64",
"-include/Path/pch_arm64.hxx",
"-Xarch_x86_64",
"-include/Path/pch_x86_64.hxx"
);
println!("{:?}", a);
assert_eq!(
ovec!["-Xarch_arm64", "-include/Path/pch_arm64.hxx", "-Xarch_x86_64", "-include/Path/pch_x86_64.hxx"],
a.preprocessor_args
);
}

#[test]
fn test_parse_xclang_llvm_stuff() {
let a = parses!(
Expand Down
14 changes: 13 additions & 1 deletion src/compiler/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,19 @@ where
Some(s) if s.len() == 2 => NormalizedDisposition::Concatenated,
_ => NormalizedDisposition::Separated,
};
args.extend(arg.normalize(norm).iter_os_strings());

match arg {
Argument::WithValue(s, PreprocessorArgument(d), ArgDisposition::Concatenated(_)) if s.starts_with("-Xarch") => {
// let's get nested
if let Ok(str_data) = d.into_string() {
if let Some((arch, next_arg)) = str_data.split_once(" ") {
args.push(OsString::from(format!("{}_{}", s, arch)));
args.push(OsString::from(next_arg));
}
}
}
_ => args.extend(arg.normalize(norm).iter_os_strings())
}
}

let xclang_it = ExpandIncludeFile::new(cwd, &xclangs);
Expand Down

0 comments on commit 0191795

Please sign in to comment.