]> git.lizzy.rs Git - rust.git/commitdiff
Permit constructing Build without executing
authorMark Simulacrum <mark.simulacrum@gmail.com>
Sat, 10 Mar 2018 02:19:59 +0000 (19:19 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Tue, 3 Apr 2018 17:39:16 +0000 (11:39 -0600)
src/bootstrap/lib.rs

index cbe19aeb63353b3f9c7de56665dd1fbbc91c6b80..cad4a794cf00592b03fade3abfdc52db24dccd8e 100644 (file)
@@ -326,7 +326,7 @@ pub fn new(config: Config) -> Build {
         let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls"));
         let rustfmt_info = channel::GitInfo::new(&config, &src.join("src/tools/rustfmt"));
 
-        Build {
+        let mut build = Build {
             initial_rustc: config.initial_rustc.clone(),
             initial_cargo: config.initial_cargo.clone(),
             local_rebuild: config.local_rebuild,
@@ -357,7 +357,27 @@ pub fn new(config: Config) -> Build {
             delayed_failures: RefCell::new(Vec::new()),
             prerelease_version: Cell::new(None),
             tool_artifacts: Default::default(),
+        };
+
+        build.verbose("finding compilers");
+        cc_detect::find(&mut build);
+        build.verbose("running sanity check");
+        sanity::check(&mut build);
+        // If local-rust is the same major.minor as the current version, then force a local-rebuild
+        let local_version_verbose = output(
+            Command::new(&build.initial_rustc).arg("--version").arg("--verbose"));
+        let local_release = local_version_verbose
+            .lines().filter(|x| x.starts_with("release:"))
+            .next().unwrap().trim_left_matches("release:").trim();
+        let my_version = channel::CFG_RELEASE_NUM;
+        if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
+            build.verbose(&format!("auto-detected local-rebuild {}", local_release));
+            build.local_rebuild = true;
         }
+        build.verbose("learning about cargo");
+        metadata::build(&mut build);
+
+        build
     }
 
     pub fn build_triple(&self) -> &[Interned<String>] {
@@ -376,24 +396,6 @@ pub fn build(&mut self) {
             return clean::clean(self, all);
         }
 
-        self.verbose("finding compilers");
-        cc_detect::find(self);
-        self.verbose("running sanity check");
-        sanity::check(self);
-        // If local-rust is the same major.minor as the current version, then force a local-rebuild
-        let local_version_verbose = output(
-            Command::new(&self.initial_rustc).arg("--version").arg("--verbose"));
-        let local_release = local_version_verbose
-            .lines().filter(|x| x.starts_with("release:"))
-            .next().unwrap().trim_left_matches("release:").trim();
-        let my_version = channel::CFG_RELEASE_NUM;
-        if local_release.split('.').take(2).eq(my_version.split('.').take(2)) {
-            self.verbose(&format!("auto-detected local-rebuild {}", local_release));
-            self.local_rebuild = true;
-        }
-        self.verbose("learning about cargo");
-        metadata::build(self);
-
         let builder = builder::Builder::new(&self);
         if let Some(path) = builder.paths.get(0) {
             if path == Path::new("nonexistent/path/to/trigger/cargo/metadata") {