Skip to content

Commit

Permalink
Expose cc-rs no_default_flags for hassle-free cross-compilation (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov authored Nov 25, 2024
1 parent b689783 commit 3f5d7de
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub struct Config {
uses_cxx11: bool,
always_configure: bool,
no_build_target: bool,
no_default_flags: bool,
verbose_cmake: bool,
verbose_make: bool,
pic: Option<bool>,
Expand Down Expand Up @@ -184,6 +185,7 @@ impl Config {
path: env::current_dir().unwrap().join(path),
generator: None,
generator_toolset: None,
no_default_flags: false,
cflags: OsString::new(),
cxxflags: OsString::new(),
asmflags: OsString::new(),
Expand Down Expand Up @@ -297,6 +299,13 @@ impl Config {
self
}

/// Disables the generation of default compiler flags. The default compiler
/// flags may cause conflicts in some cross compiling scenarios.
pub fn no_default_flags(&mut self, no_default_flags: bool) -> &mut Config {
self.no_default_flags = no_default_flags;
self
}

/// Sets the host triple for this compilation.
///
/// This is automatically scraped from `$HOST` which is set for Cargo
Expand Down Expand Up @@ -515,7 +524,7 @@ impl Config {
.debug(false)
.warnings(false)
.host(&host)
.no_default_flags(ndk);
.no_default_flags(ndk || self.no_default_flags);
if !ndk {
c_cfg.target(&target);
}
Expand All @@ -527,7 +536,7 @@ impl Config {
.debug(false)
.warnings(false)
.host(&host)
.no_default_flags(ndk);
.no_default_flags(ndk || self.no_default_flags);
if !ndk {
cxx_cfg.target(&target);
}
Expand Down

0 comments on commit 3f5d7de

Please sign in to comment.