Skip to content

Commit

Permalink
Rename target variable to target_triplet
Browse files Browse the repository at this point in the history
  • Loading branch information
kylefleming committed Oct 2, 2019
1 parent 8141f0e commit 6a2ce3d
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl Config {
/// This will run both the build system generator command as well as the
/// command to build the library.
pub fn build(&mut self) -> PathBuf {
let target = match self.target.clone() {
let target_triplet = match self.target.clone() {
Some(t) => t,
None => {
let mut t = getenv_unwrap("TARGET");
Expand All @@ -316,7 +316,7 @@ impl Config {
}
};
let host = self.host.clone().unwrap_or_else(|| getenv_unwrap("HOST"));
let msvc = target.contains("msvc");
let msvc = target_triplet.contains("msvc");
let ndk = self.uses_android_ndk();
let mut c_cfg = cc::Build::new();
c_cfg
Expand All @@ -327,7 +327,7 @@ impl Config {
.host(&host)
.no_default_flags(ndk);
if !ndk {
c_cfg.target(&target);
c_cfg.target(&target_triplet);
}
let mut cxx_cfg = cc::Build::new();
cxx_cfg
Expand All @@ -339,7 +339,7 @@ impl Config {
.host(&host)
.no_default_flags(ndk);
if !ndk {
cxx_cfg.target(&target);
cxx_cfg.target(&target_triplet);
}
if let Some(static_crt) = self.static_crt {
c_cfg.static_crt(static_crt);
Expand Down Expand Up @@ -383,7 +383,7 @@ impl Config {
if let Some(ref generator) = self.generator {
is_ninja = generator.to_string_lossy().contains("Ninja");
}
if target.contains("windows-gnu") {
if target_triplet.contains("windows-gnu") {
if host.contains("windows") {
// On MinGW we need to coerce cmake to not generate a visual
// studio build system but instead use makefiles that MinGW can
Expand Down Expand Up @@ -440,22 +440,23 @@ impl Config {
// This also guarantees that NMake generator isn't chosen implicitly.
let using_nmake_generator;
if self.generator.is_none() {
cmd.arg("-G").arg(self.visual_studio_generator(&target));
cmd.arg("-G")
.arg(self.visual_studio_generator(&target_triplet));
using_nmake_generator = false;
} else {
using_nmake_generator = self.generator.as_ref().unwrap() == "NMake Makefiles";
}
if !is_ninja && !using_nmake_generator {
if target.contains("x86_64") {
if target_triplet.contains("x86_64") {
cmd.arg("-Thost=x64");
cmd.arg("-Ax64");
} else if target.contains("thumbv7a") {
} else if target_triplet.contains("thumbv7a") {
cmd.arg("-Thost=x64");
cmd.arg("-Aarm");
} else if target.contains("aarch64") {
} else if target_triplet.contains("aarch64") {
cmd.arg("-Thost=x64");
cmd.arg("-AARM64");
} else if target.contains("i686") {
} else if target_triplet.contains("i686") {
use cc::windows_registry::{find_vs_version, VsVers};
match find_vs_version() {
Ok(VsVers::Vs16) => {
Expand All @@ -468,14 +469,14 @@ impl Config {
_ => {}
};
} else {
panic!("unsupported msvc target: {}", target);
panic!("unsupported msvc target: {}", target_triplet);
}
}
} else if target.contains("redox") {
} else if target_triplet.contains("redox") {
if !self.defined("CMAKE_SYSTEM_NAME") {
cmd.arg("-DCMAKE_SYSTEM_NAME=Generic");
}
} else if target.contains("solaris") {
} else if target_triplet.contains("solaris") {
if !self.defined("CMAKE_SYSTEM_NAME") {
cmd.arg("-DCMAKE_SYSTEM_NAME=SunOS");
}
Expand Down

0 comments on commit 6a2ce3d

Please sign in to comment.