}
if let Some(ref code) = args.value_of("explain") {
- let mut procss = config.rustc()?.process();
+ let mut procss = config.new_rustc()?.process();
procss.arg("--explain").arg(code).exec()?;
return Ok(());
}
/// Flags to pass to rustdoc when invoked from cargo test, per package.
pub rustdocflags: HashMap<PackageId, Vec<String>>,
+ pub host: String,
pub target: String,
config: &'cfg Config,
+ rustc_process: ProcessBuilder,
target_runner: LazyCell<Option<(PathBuf, Vec<String>)>>,
}
impl<'cfg> Compilation<'cfg> {
- pub fn new(config: &'cfg Config) -> Compilation<'cfg> {
+ pub fn new(config: &'cfg Config, rustc_process: ProcessBuilder) -> Compilation<'cfg> {
Compilation {
libraries: HashMap::new(),
native_dirs: BTreeSet::new(), // TODO: deprecated, remove
cfgs: HashMap::new(),
rustdocflags: HashMap::new(),
config,
+ rustc_process,
+ host: String::new(),
target: String::new(),
target_runner: LazyCell::new(),
}
/// See `process`.
pub fn rustc_process(&self, pkg: &Package) -> CargoResult<ProcessBuilder> {
- self.fill_env(self.config.rustc()?.process(), pkg, true)
+ self.fill_env(self.rustc_process.clone(), pkg, true)
}
/// See `process`.
unit.target.name().hash(&mut hasher);
unit.target.kind().hash(&mut hasher);
- if let Ok(rustc) = cx.config.rustc() {
- rustc.verbose_version.hash(&mut hasher);
- }
+ cx.build_config.rustc.verbose_version.hash(&mut hasher);
// Seed the contents of __CARGO_DEFAULT_LIB_METADATA to the hasher if present.
// This should be the release channel, to get a different hash for each channel.
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 != &config.rustc()?.host => false,
+ Some(ref s) if s != &build_config.host_triple => false,
_ => true,
};
config,
target_info,
host_info,
- compilation: Compilation::new(config),
+ compilation: Compilation::new(config, build_config.rustc.process()),
build_state: Arc::new(BuildState::new(&build_config)),
build_config,
fingerprints: HashMap::new(),
self.compilation.native_dirs.insert(dir.clone());
}
}
+ self.compilation.host = self.build_config.host_triple.clone();
self.compilation.target = self.build_config.target_triple().to_string();
Ok(self.compilation)
}
impl TargetInfo {
pub fn new(config: &Config, build_config: &BuildConfig, kind: Kind) -> CargoResult<TargetInfo> {
let rustflags = env_args(config, build_config, None, kind, "RUSTFLAGS")?;
- let mut process = config.rustc()?.process();
+ let mut process = build_config.rustc.process();
process
.arg("-")
.arg("--crate-name")
},
)
.env("HOST", &cx.build_config.host_triple)
- .env("RUSTC", &cx.config.rustc()?.path)
+ .env("RUSTC", &cx.build_config.rustc.path)
.env("RUSTDOC", &*cx.config.rustdoc()?)
.inherit_jobserver(&cx.jobserver);
cx.rustflags_args(unit)?
};
let fingerprint = Arc::new(Fingerprint {
- rustc: util::hash_u64(&cx.config.rustc()?.verbose_version),
+ rustc: util::hash_u64(&cx.build_config.rustc.verbose_version),
target: util::hash_u64(&unit.target),
profile: util::hash_u64(&(&unit.profile, cx.incremental_args(unit)?)),
// Note that .0 is hashed here, not .1 which is the cwd. That doesn't
use core::{Feature, PackageId, Profile, Target};
use core::manifest::Lto;
use core::shell::ColorChoice;
-use util::{self, machine_message, Config, ProcessBuilder};
+use util::{self, machine_message, Config, ProcessBuilder, Rustc, Freshness};
use util::{internal, join_paths, profile};
use util::paths;
use util::errors::{CargoResult, CargoResultExt, Internal};
-use util::Freshness;
use self::job::{Job, Work};
use self::job_queue::JobQueue;
}
/// Configuration information for a rustc build.
-#[derive(Default, Clone)]
pub struct BuildConfig {
+ pub rustc: Rustc,
/// The host arch triple
///
/// e.g. x86_64-unknown-linux-gnu, would be
None => None,
};
let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32);
-
- let host_triple = config.rustc()?.host.clone();
+ let rustc = config.new_rustc()?;
+ let host_triple = rustc.host.clone();
let host_config = TargetConfig::new(config, &host_triple)?;
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,
target: target_config,
- ..Default::default()
+ release: false,
+ test: false,
+ doc_all: false,
+ json_messages: false,
})
}
let config = options.compile_opts.config;
// We don't build/rust doctests if target != host
- if config.rustc()?.host != compilation.target {
+ if compilation.host != compilation.target {
return Ok((Test::Doc, errors));
}
}
/// Get the path to the `rustc` executable
- pub fn rustc(&self) -> CargoResult<&Rustc> {
- self.rustc.try_borrow_with(|| {
- Rustc::new(
- self.get_tool("rustc")?,
- self.maybe_get_tool("rustc_wrapper")?,
- )
- })
+ pub fn new_rustc(&self) -> CargoResult<Rustc> {
+ Rustc::new(
+ self.get_tool("rustc")?,
+ self.maybe_get_tool("rustc_wrapper")?,
+ )
}
/// Get the path to the `cargo` executable