Skip to content

Commit a218cea

Browse files
committed
Simplify command_add_output_file.
1 parent a211d91 commit a218cea

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

src/lib.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -523,18 +523,14 @@ impl Build {
523523
}
524524

525525
let mut cmd = compiler.to_command();
526-
let is_arm = target.contains("aarch64") || target.contains("arm");
527-
let clang = compiler.family == ToolFamily::Clang;
528-
let gnu = compiler.family == ToolFamily::Gnu;
529526
command_add_output_file(
530527
&mut cmd,
531528
&obj,
532-
self.cuda,
533-
target.contains("msvc"),
534-
clang,
535-
gnu,
536-
false,
537-
is_arm,
529+
!self.cuda
530+
&& match compiler.family {
531+
ToolFamily::Msvc { .. } => true,
532+
_ => false,
533+
},
538534
);
539535

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

15151509
let is_assembler_msvc = msvc && asm_ext == Some(AsmFileExt::DotAsm);
15161510
let (mut cmd, name) = if is_assembler_msvc {
@@ -1532,7 +1526,17 @@ impl Build {
15321526
};
15331527
let is_arm = target.contains("aarch64") || target.contains("arm");
15341528
command_add_output_file(
1535-
&mut cmd, &obj.dst, self.cuda, msvc, clang, gnu, is_asm, is_arm,
1529+
&mut cmd,
1530+
&obj.dst,
1531+
if is_assembler_msvc {
1532+
!is_arm
1533+
} else {
1534+
!self.cuda
1535+
&& match compiler.family {
1536+
ToolFamily::Msvc { .. } => true,
1537+
_ => false,
1538+
}
1539+
},
15361540
);
15371541
// armasm and armasm64 don't requrie -c option
15381542
if !is_assembler_msvc || !is_arm {
@@ -3863,17 +3867,8 @@ fn fail(s: &str) -> ! {
38633867
std::process::exit(1);
38643868
}
38653869

3866-
fn command_add_output_file(
3867-
cmd: &mut Command,
3868-
dst: &Path,
3869-
cuda: bool,
3870-
msvc: bool,
3871-
clang: bool,
3872-
gnu: bool,
3873-
is_asm: bool,
3874-
is_arm: bool,
3875-
) {
3876-
if msvc && !clang && !gnu && !cuda && !(is_asm && is_arm) {
3870+
fn command_add_output_file(cmd: &mut Command, dst: &Path, msvc: bool) {
3871+
if msvc {
38773872
let mut s = OsString::from("-Fo");
38783873
s.push(&dst);
38793874
cmd.arg(s);

0 commit comments

Comments
 (0)