Skip to content

Simplify command_add_output_file. #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3895,17 +3899,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