let _p = profile::start("Context::probe_target_info");
debug!("probe_target_info");
let host_target_same = match build_config.requested_target {
- Some(ref s) if s != &build_config.host_triple => false,
+ Some(ref s) if s != &build_config.host_triple() => false,
_ => true,
};
self.compilation.native_dirs.insert(dir.clone());
}
}
- self.compilation.host = self.build_config.host_triple.clone();
+ self.compilation.host = self.build_config.host_triple().to_string();
self.compilation.target = self.build_config.target_triple().to_string();
Ok(self.compilation)
}
None => return true,
};
let (name, info) = match kind {
- Kind::Host => (self.build_config.host_triple.as_ref(), &self.host_info),
+ Kind::Host => (self.build_config.host_triple(), &self.host_info),
Kind::Target => (self.build_config.target_triple(), &self.target_info),
};
platform.matches(name, info.cfg())
let target = build_config
.requested_target
.as_ref()
- .unwrap_or(&build_config.host_triple);
+ .map(|s| s.as_str())
+ .unwrap_or(build_config.host_triple());
let key = format!("target.{}.{}", target, name);
if let Some(args) = config.get_list_or_split_string(&key)? {
let args = args.val.into_iter();
.env(
"TARGET",
&match unit.kind {
- Kind::Host => &cx.build_config.host_triple,
+ Kind::Host => &cx.build_config.host_triple(),
Kind::Target => cx.build_config.target_triple(),
},
)
"debug"
},
)
- .env("HOST", &cx.build_config.host_triple)
+ .env("HOST", &cx.build_config.host_triple())
.env("RUSTC", &cx.build_config.rustc.path)
.env("RUSTDOC", &*cx.config.rustdoc()?)
.inherit_jobserver(&cx.jobserver);
use core::{Feature, PackageId, Profile, Target};
use core::manifest::Lto;
use core::shell::ColorChoice;
-use util::{self, machine_message, Config, ProcessBuilder, Rustc, Freshness};
+use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc};
use util::{internal, join_paths, profile};
use util::paths;
use util::errors::{CargoResult, CargoResultExt, Internal};
/// Configuration information for a rustc build.
pub struct BuildConfig {
pub rustc: Rustc,
- /// The host arch triple
- ///
- /// e.g. x86_64-unknown-linux-gnu, would be
- /// - machine: x86_64
- /// - hardware-platform: unknown
- /// - operating system: linux-gnu
- pub host_triple: String,
/// Build information for the host arch
pub host: TargetConfig,
/// The target arch triple, defaults to host arch
};
let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32);
let rustc = config.new_rustc()?;
- let host_triple = rustc.host.clone();
- let host_config = TargetConfig::new(config, &host_triple)?;
+ let host_config = TargetConfig::new(config, &rustc.host)?;
let target_config = match target.as_ref() {
Some(triple) => TargetConfig::new(config, triple)?,
None => host_config.clone(),
};
Ok(BuildConfig {
rustc,
- host_triple,
requested_target: target,
jobs,
host: host_config,
})
}
+ /// The host arch triple
+ ///
+ /// e.g. x86_64-unknown-linux-gnu, would be
+ /// - machine: x86_64
+ /// - hardware-platform: unknown
+ /// - operating system: linux-gnu
+ pub fn host_triple(&self) -> &str {
+ &self.rustc.host
+ }
+
pub fn target_triple(&self) -> &str {
self.requested_target
.as_ref()
- .unwrap_or_else(|| &self.host_triple)
+ .map(|s| s.as_str())
+ .unwrap_or(self.host_triple())
}
}