let profiles = ws.profiles();
let host_triple = opts.config.rustc()?.host.clone();
- let mut cx = Context::new(
- ws,
- &resolve,
- &packages,
- opts.config,
- BuildConfig {
- host_triple,
- requested_target: opts.target.clone(),
- release: opts.release,
- jobs: 1,
- ..BuildConfig::default()
- },
- profiles,
- )?;
let mut units = Vec::new();
for spec in opts.spec.iter() {
}
}
- cx.probe_target_info()?;
- cx.build_unit_dependencies(&units)?;
+ let mut cx = Context::new(
+ ws,
+ &resolve,
+ &packages,
+ opts.config,
+ BuildConfig {
+ host_triple,
+ requested_target: opts.target.clone(),
+ release: opts.release,
+ jobs: 1,
+ ..BuildConfig::default()
+ },
+ profiles,
+ &units,
+ )?;
for unit in units.iter() {
rm_rf(&cx.fingerprint_dir(unit), config)?;
profiles: &'a Profiles,
incremental_env: Option<bool>,
- unit_dependencies: Option<HashMap<Unit<'a>, Vec<Unit<'a>>>>,
+ unit_dependencies: HashMap<Unit<'a>, Vec<Unit<'a>>>,
/// For each Unit, a list all files produced as a triple of
///
/// - File name that will be produced by the build process (in `deps`)
config: &'cfg Config,
build_config: BuildConfig,
profiles: &'a Profiles,
+ units: &[Unit<'a>],
) -> CargoResult<Context<'a, 'cfg>> {
let dest = if build_config.release {
"release"
None => Client::new(build_config.jobs as usize - 1)
.chain_err(|| "failed to create jobserver")?,
};
-
- Ok(Context {
+ let mut cx = Context {
ws,
host: host_layout,
target: target_layout,
jobserver,
build_script_overridden: HashSet::new(),
- unit_dependencies: None,
+ unit_dependencies: HashMap::new(),
// TODO: Pre-Calculate these with a topo-sort, rather than lazy-calculating
target_filenames: HashMap::new(),
target_metadatas: HashMap::new(),
- })
+ };
+
+ cx.probe_target_info()?;
+ let deps = build_unit_dependencies(units, &cx)?;
+ cx.unit_dependencies = deps;
+
+ Ok(cx)
}
/// Prepare this context, ensuring that all filesystem directories are in
Ok(())
}
- pub fn build_unit_dependencies(&mut self, units: &[Unit<'a>]) -> CargoResult<()> {
- assert!(self.unit_dependencies.is_none());
- self.unit_dependencies = Some(build_unit_dependencies(units, self)?);
- Ok(())
- }
-
/// Ensure that we've collected all target-specific information to compile
/// all the units mentioned in `units`.
- pub fn probe_target_info(&mut self) -> CargoResult<()> {
+ fn probe_target_info(&mut self) -> CargoResult<()> {
debug!("probe_target_info");
let host_target_same = match self.requested_target() {
Some(s) if s != self.config.rustc()?.host => false,
return Vec::new();
}
}
- self.unit_dependencies.as_ref().unwrap()[unit].clone()
+ self.unit_dependencies[unit].clone()
}
fn dep_platform_activated(&self, dep: &Dependency, kind: Kind) -> bool {
})
.collect::<Vec<_>>();
- let mut cx = Context::new(ws, resolve, packages, config, build_config, profiles)?;
+ let mut cx = Context::new(
+ ws,
+ resolve,
+ packages,
+ config,
+ build_config,
+ profiles,
+ &units,
+ )?;
let mut queue = JobQueue::new(&cx);
cx.prepare()?;
- cx.probe_target_info()?;
- cx.build_unit_dependencies(&units)?;
cx.build_used_in_plugin_map(&units)?;
custom_build::build_map(&mut cx, &units)?;