Skip to content

Commit

Permalink
Only pass .asm files to masm
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Nov 23, 2022
1 parent daa41b9 commit 0c0b6cb
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ impl Build {
self
}

fn asm_ext(&self, file: &Path) -> Option<AsmExt> {
if let Some(ext) = file.extension() {
if let Some(ext) = ext.to_str() {
let ext = ext.to_lowercase();
match &*ext {
"asm" => return Some(AsmExt::Asm),
"s" => return Some(AsmExt::S),
_ => return None,
}
}
}
None
}

fn ensure_check_file(&self) -> Result<PathBuf, Error> {
let out_dir = self.get_out_dir()?;
let src = if self.cuda {
Expand Down Expand Up @@ -1339,12 +1353,14 @@ impl Build {
}

fn compile_object(&self, obj: &Object) -> Result<(), Error> {
let is_asm = is_asm(&obj.src);
let asm_ext = self.asm_ext(&obj.src);
let is_asm = asm_ext.is_some();
let target = self.get_target()?;
let msvc = target.contains("msvc");
let compiler = self.try_get_compiler()?;
let clang = compiler.family == ToolFamily::Clang;
let (mut cmd, name) = if msvc && is_asm {

let (mut cmd, name) = if msvc && matches!(asm_ext, Some(AsmExt::Asm)) {
self.msvc_macro_assembler()?
} else {
let mut cmd = compiler.to_command();
Expand Down Expand Up @@ -3496,14 +3512,8 @@ fn which(tool: &Path) -> Option<PathBuf> {
})
}

/// Check if the file's extension is either "asm" or "s", case insensitive.
fn is_asm(file: &Path) -> bool {
if let Some(ext) = file.extension() {
if let Some(ext) = ext.to_str() {
let ext = ext.to_lowercase();
return ext == "asm" || ext == "s";
}
}

false
#[derive(Clone, Copy, PartialEq)]
enum AsmExt {
S,
Asm,
}

0 comments on commit 0c0b6cb

Please sign in to comment.