]> git.proxmox.com Git - cargo.git/commitdiff
Pass Workspace directly into Config::rustc()
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 3 May 2018 08:42:45 +0000 (10:42 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 3 May 2018 19:54:49 +0000 (21:54 +0200)
This means we can store the cache file name in one place.

src/cargo/core/compiler/build_config.rs
src/cargo/ops/cargo_compile.rs
src/cargo/util/config.rs

index 61e5cebe4da5ae4265e6835745b242b370917faa..abd71e0fe2de65c28fedc8519a3c21652dd2696e 100644 (file)
@@ -1,6 +1,7 @@
 use std::collections::HashMap;
 use std::path::{Path, PathBuf};
 use util::{CargoResult, CargoResultExt, Config, Rustc};
+use core::Workspace;
 use super::BuildOutput;
 
 /// Configuration information for a rustc build.
@@ -35,7 +36,7 @@ impl BuildConfig {
         config: &Config,
         jobs: Option<u32>,
         requested_target: &Option<String>,
-        rustc_info_cache: Option<PathBuf>,
+        ws: Option<&Workspace>,
         mode: CompileMode,
     ) -> CargoResult<BuildConfig> {
         let requested_target = match requested_target {
@@ -88,7 +89,7 @@ impl BuildConfig {
             None => None,
         };
         let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32);
-        let rustc = config.rustc(rustc_info_cache)?;
+        let rustc = config.rustc(ws)?;
         let host_config = TargetConfig::new(config, &rustc.host)?;
         let target_config = match target.as_ref() {
             Some(triple) => TargetConfig::new(config, triple)?,
index ec031b526aeeac9ccd4e223162ebf1064ba5598c..c2dad7a780088a10ee2cae7cfed936a2d24ccc3b 100644 (file)
@@ -229,10 +229,7 @@ pub fn compile_ws<'a>(
         ref export_dir,
     } = *options;
 
-    let rustc_info_cache = ws.target_dir()
-        .join(".rustc_info.json")
-        .into_path_unlocked();
-    let mut build_config = BuildConfig::new(config, jobs, &target, Some(rustc_info_cache), mode)?;
+    let mut build_config = BuildConfig::new(config, jobs, &target, Some(ws), mode)?;
     build_config.release = release;
     build_config.message_format = message_format;
     let default_arch_kind = if build_config.requested_target.is_some() {
index 91cf39cc7a8ce92393bd898eb4064a9de5c29449..f3a1d7968108b23048e0a7cc9e5927d9155fc3ef 100644 (file)
@@ -20,7 +20,7 @@ use toml;
 use lazycell::LazyCell;
 
 use core::shell::Verbosity;
-use core::{CliUnstable, Shell, SourceId};
+use core::{CliUnstable, Shell, SourceId, Workspace};
 use ops;
 use url::Url;
 use util::ToUrl;
@@ -170,7 +170,12 @@ impl Config {
     }
 
     /// Get the path to the `rustc` executable
-    pub fn rustc(&self, cache_location: Option<PathBuf>) -> CargoResult<Rustc> {
+    pub fn rustc(&self, ws: Option<&Workspace>) -> CargoResult<Rustc> {
+        let cache_location = ws.map(|ws| {
+            ws.target_dir()
+                .join(".rustc_info.json")
+                .into_path_unlocked()
+        });
         Rustc::new(
             self.get_tool("rustc")?,
             self.maybe_get_tool("rustc_wrapper")?,