Skip to content

Commit

Permalink
Simplify command_add_output_file.
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-asm committed Sep 27, 2023
1 parent a211d91 commit a218cea
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,14 @@ impl Build {
}

let mut cmd = compiler.to_command();
let is_arm = target.contains("aarch64") || target.contains("arm");
let clang = compiler.family == ToolFamily::Clang;
let gnu = compiler.family == ToolFamily::Gnu;
command_add_output_file(
&mut cmd,
&obj,
self.cuda,
target.contains("msvc"),
clang,
gnu,
false,
is_arm,
!self.cuda
&& match compiler.family {
ToolFamily::Msvc { .. } => true,
_ => false,
},
);

// We need to explicitly tell msvc not to link and create an exe
Expand Down Expand Up @@ -1509,8 +1505,6 @@ impl Build {
let target = self.get_target()?;
let msvc = target.contains("msvc");
let compiler = self.try_get_compiler()?;
let clang = compiler.family == ToolFamily::Clang;
let gnu = compiler.family == ToolFamily::Gnu;

let is_assembler_msvc = msvc && asm_ext == Some(AsmFileExt::DotAsm);
let (mut cmd, name) = if is_assembler_msvc {
Expand All @@ -1532,7 +1526,17 @@ impl Build {
};
let is_arm = target.contains("aarch64") || target.contains("arm");
command_add_output_file(
&mut cmd, &obj.dst, self.cuda, msvc, clang, gnu, is_asm, is_arm,
&mut cmd,
&obj.dst,
if is_assembler_msvc {
!is_arm
} else {
!self.cuda
&& match compiler.family {
ToolFamily::Msvc { .. } => true,
_ => false,
}
},
);
// armasm and armasm64 don't requrie -c option
if !is_assembler_msvc || !is_arm {
Expand Down Expand Up @@ -3863,17 +3867,8 @@ fn fail(s: &str) -> ! {
std::process::exit(1);
}

fn command_add_output_file(
cmd: &mut Command,
dst: &Path,
cuda: bool,
msvc: bool,
clang: bool,
gnu: bool,
is_asm: bool,
is_arm: bool,
) {
if msvc && !clang && !gnu && !cuda && !(is_asm && is_arm) {
fn command_add_output_file(cmd: &mut Command, dst: &Path, msvc: bool) {
if msvc {
let mut s = OsString::from("-Fo");
s.push(&dst);
cmd.arg(s);
Expand Down

0 comments on commit a218cea

Please sign in to comment.