None => Client::new(build_config.jobs as usize - 1)
.chain_err(|| "failed to create jobserver")?,
};
+
+ let (host_info, target_info) = {
+ 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,
+ _ => true,
+ };
+
+ let host_info = TargetInfo::new(config, &build_config, Kind::Host)?;
+ let target_info = if host_target_same {
+ host_info.clone()
+ } else {
+ TargetInfo::new(config, &build_config, Kind::Target)?
+ };
+ (host_info, target_info)
+ };
+
let mut cx = Context {
ws,
resolve,
packages,
config,
- target_info: TargetInfo::default(),
- host_info: TargetInfo::default(),
+ target_info,
+ host_info,
compilation: Compilation::new(config),
build_state: Arc::new(BuildState::new(&build_config)),
build_config,
files: None,
};
- cx.probe_target_info()?;
+ cx.compilation.host_dylib_path = cx.host_info.sysroot_libdir.clone();
+ cx.compilation.target_dylib_path = cx.target_info.sysroot_libdir.clone();
Ok(cx)
}
Ok(())
}
- /// Ensure that we've collected all target-specific information to compile
- /// all the units mentioned in `units`.
- fn probe_target_info(&mut self) -> CargoResult<()> {
- let _p = profile::start("Context::probe_target_info");
- debug!("probe_target_info");
- let host_target_same = match self.build_config.requested_target {
- Some(ref s) if s != &self.config.rustc()?.host => false,
- _ => true,
- };
-
- self.host_info = TargetInfo::new(self.config, &self.build_config, Kind::Host)?;
- self.target_info = if host_target_same {
- self.host_info.clone()
- } else {
- TargetInfo::new(self.config, &self.build_config, Kind::Target)?
- };
- self.compilation.host_dylib_path = self.host_info.sysroot_libdir.clone();
- self.compilation.target_dylib_path = self.target_info.sysroot_libdir.clone();
- Ok(())
- }
-
/// Builds up the `used_in_plugin` internal to this context from the list of
/// top-level units.
///