//! everything.
use std::collections::HashSet;
-use std::{env, iter};
use std::path::{Path, PathBuf};
use std::process::Command;
+use std::{env, iter};
use build_helper::output;
-use crate::{Build, GitRepo};
-use crate::config::Target;
use crate::cache::Interned;
+use crate::config::Target;
+use crate::{Build, GitRepo};
// The `cc` crate doesn't provide a way to obtain a path to the detected archiver,
// so use some simplified logic here. First we respect the environment variable `AR`, then
} else if target.contains("openbsd") {
Some(PathBuf::from("ar"))
} else if target.contains("vxworks") {
- Some(PathBuf::from("vx-ar"))
+ Some(PathBuf::from("wr-ar"))
} else {
let parent = cc.parent().unwrap();
let file = cc.file_name().unwrap().to_str().unwrap();
pub fn find(build: &mut Build) {
// For all targets we're going to need a C compiler for building some shims
// and such as well as for being a linker for Rust code.
- let targets = build.targets.iter().chain(&build.hosts).cloned().chain(iter::once(build.build))
- .collect::<HashSet<_>>();
+ let targets = build
+ .targets
+ .iter()
+ .chain(&build.hosts)
+ .cloned()
+ .chain(iter::once(build.build))
+ .collect::<HashSet<_>>();
for target in targets.into_iter() {
let mut cfg = cc::Build::new();
- cfg.cargo_metadata(false).opt_level(2).warnings(false).debug(false)
- .target(&target).host(&build.build);
+ cfg.cargo_metadata(false)
+ .opt_level(2)
+ .warnings(false)
+ .debug(false)
+ .target(&target)
+ .host(&build.build);
match build.crt_static(target) {
- Some(a) => { cfg.static_crt(a); }
+ Some(a) => {
+ cfg.static_crt(a);
+ }
None => {
if target.contains("msvc") {
cfg.static_crt(true);
// If we use llvm-libunwind, we will need a C++ compiler as well for all targets
// We'll need one anyways if the target triple is also a host triple
let mut cfg = cc::Build::new();
- cfg.cargo_metadata(false).opt_level(2).warnings(false).debug(false).cpp(true)
- .target(&target).host(&build.build);
+ cfg.cargo_metadata(false)
+ .opt_level(2)
+ .warnings(false)
+ .debug(false)
+ .cpp(true)
+ .target(&target)
+ .host(&build.build);
let cxx_configured = if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) {
cfg.compiler(cxx);
}
}
-fn set_compiler(cfg: &mut cc::Build,
- compiler: Language,
- target: Interned<String>,
- config: Option<&Target>,
- build: &Build) {
+fn set_compiler(
+ cfg: &mut cc::Build,
+ compiler: Language,
+ target: Interned<String>,
+ config: Option<&Target>,
+ build: &Build,
+) {
match &*target {
// When compiling for android we may have the NDK configured in the
// config.toml in which case we look there. Otherwise the default
// compiler already takes into account the triple in question.
t if t.contains("android") => {
if let Some(ndk) = config.and_then(|c| c.ndk.as_ref()) {
- let target = target.replace("armv7neon", "arm")
- .replace("armv7", "arm")
- .replace("thumbv7neon", "arm")
- .replace("thumbv7", "arm");
+ let target = target
+ .replace("armv7neon", "arm")
+ .replace("armv7", "arm")
+ .replace("thumbv7neon", "arm")
+ .replace("thumbv7", "arm");
let compiler = format!("{}-{}", target, compiler.clang());
cfg.compiler(ndk.join("bin").join(compiler));
}
let c = cfg.get_compiler();
let gnu_compiler = compiler.gcc();
if !c.path().ends_with(gnu_compiler) {
- return
+ return;
}
let output = output(c.to_command().arg("--version"));
None => return,
};
match output[i + 3..].chars().next().unwrap() {
- '0' ..= '6' => {}
+ '0'..='6' => {}
_ => return,
}
let alternative = format!("e{}", gnu_compiler);