Skip to content

Commit

Permalink
Support for ASM_FLAGS (#86)
Browse files Browse the repository at this point in the history
* Add support for ASM_FLAGS

* Use c_cfg when determining asm_compiler
  • Loading branch information
kylefleming authored and alexcrichton committed Oct 1, 2019
1 parent 7fdc5d1 commit 8141f0e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Expand Up @@ -60,6 +60,7 @@ pub struct Config {
generator: Option<OsString>,
cflags: OsString,
cxxflags: OsString,
asmflags: OsString,
defines: Vec<(OsString, OsString)>,
deps: Vec<String>,
target: Option<String>,
Expand Down Expand Up @@ -106,6 +107,7 @@ impl Config {
generator: None,
cflags: OsString::new(),
cxxflags: OsString::new(),
asmflags: OsString::new(),
defines: Vec::new(),
deps: Vec::new(),
profile: None,
Expand Down Expand Up @@ -146,6 +148,14 @@ impl Config {
self
}

/// Adds a custom flag to pass down to the ASM compiler, supplementing those
/// that this library already passes.
pub fn asmflag<P: AsRef<OsStr>>(&mut self, flag: P) -> &mut Config {
self.asmflags.push(" ");
self.asmflags.push(flag.as_ref());
self
}

/// Adds a new `-D` flag to pass to cmake during the generation step.
pub fn define<K, V>(&mut self, k: K, v: V) -> &mut Config
where
Expand Down Expand Up @@ -337,6 +347,7 @@ impl Config {
}
let c_compiler = c_cfg.get_compiler();
let cxx_compiler = cxx_cfg.get_compiler();
let asm_compiler = c_cfg.get_compiler();

let dst = self
.out_dir
Expand Down Expand Up @@ -650,6 +661,7 @@ impl Config {

set_compiler("C", &c_compiler, &self.cflags);
set_compiler("CXX", &cxx_compiler, &self.cxxflags);
set_compiler("ASM", &asm_compiler, &self.asmflags);
}

if !self.defined("CMAKE_BUILD_TYPE") {
Expand Down

0 comments on commit 8141f0e

Please sign in to comment.