about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2016-10-27 11:41:56 +1300
committerNick Cameron <ncameron@mozilla.com>2016-12-09 08:37:42 -1000
commitc49ba058a0d61b929975f47daf25f19dd22de9c6 (patch)
treefe9edd3f30292327882e50e7dd063165eaf21529 /src/bootstrap
parentbd148d220e976330672c9f5b5a9720701079b8e8 (diff)
downloadrust-c49ba058a0d61b929975f47daf25f19dd22de9c6.tar.gz
rust-c49ba058a0d61b929975f47daf25f19dd22de9c6.zip
Create tar balls of save-analysis-api metadata for the standard libraries as part of `make dist`.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/bin/rustc.rs5
-rw-r--r--src/bootstrap/dist.rs46
-rw-r--r--src/bootstrap/lib.rs4
-rw-r--r--src/bootstrap/step.rs4
4 files changed, 58 insertions, 1 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 879eca60cc7..2f674a311fe 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -125,6 +125,11 @@ fn main() {
             cmd.arg("-C").arg(format!("codegen-units={}", s));
         }
 
+        // Emit save-analysis info.
+        if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) {
+            cmd.arg("-Zsave-analysis-api");
+        }
+
         // Dealing with rpath here is a little special, so let's go into some
         // detail. First off, `-rpath` is a linker option on Unix platforms
         // which adds to the runtime dynamic loader path when looking for
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 2fcd45f751c..1d3445a9eac 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -23,7 +23,7 @@ use std::io::Write;
 use std::path::{PathBuf, Path};
 use std::process::Command;
 
-use {Build, Compiler};
+use {Build, Compiler, Mode};
 use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
 
 pub fn package_vers(build: &Build) -> &str {
@@ -289,6 +289,50 @@ pub fn rust_src_location(build: &Build) -> PathBuf {
     distdir(build).join(&format!("{}.tar.gz", plain_name))
 }
 
+/// Creates a tarball of save-analysis metadata, if available.
+pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
+    println!("Dist analysis");
+
+    if build.config.channel != "nightly" {
+        println!("Skipping dist-analysis - not on nightly channel");
+        return;
+    }
+    if compiler.stage != 2 {
+        return
+    }
+
+    let name = format!("rust-analysis-{}", package_vers(build));
+    let image = tmpdir(build).join(format!("{}-{}-image", name, target));
+
+    let src = build.stage_out(compiler, Mode::Libstd).join(target).join("release").join("deps");
+
+    let image_src = src.join("save-analysis");
+    let dst = image.join("lib/rustlib").join(target).join("analysis");
+    t!(fs::create_dir_all(&dst));
+    cp_r(&image_src, &dst);
+
+    let mut cmd = Command::new("sh");
+    cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
+       .arg("--product-name=Rust")
+       .arg("--rel-manifest-dir=rustlib")
+       .arg("--success-message=save-analysis-saved.")
+       .arg(format!("--image-dir={}", sanitize_sh(&image)))
+       .arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
+       .arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
+       .arg(format!("--package-name={}-{}", name, target))
+       .arg(format!("--component-name=rust-analysis-{}", target))
+       .arg("--legacy-manifest-dirs=rustlib,cargo");
+    build.run(&mut cmd);
+    t!(fs::remove_dir_all(&image));
+
+    // Create plain source tarball
+    let mut cmd = Command::new("tar");
+    cmd.arg("-czf").arg(sanitize_sh(&distdir(build).join(&format!("{}.tar.gz", name))))
+       .arg("analysis")
+       .current_dir(&src);
+    build.run(&mut cmd);
+}
+
 /// Creates the `rust-src` installer component and the plain source tarball
 pub fn rust_src(build: &Build) {
     println!("Dist src");
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 912b5864c81..cd80c4298dc 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -507,6 +507,10 @@ impl Build {
                  .env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
         }
 
+        if self.config.channel == "nightly" && compiler.stage == 2 {
+            cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
+        }
+
         // Environment variables *required* needed throughout the build
         //
         // FIXME: should update code to not require this env var
diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs
index efa3e4e5ea1..884cc7da8ea 100644
--- a/src/bootstrap/step.rs
+++ b/src/bootstrap/step.rs
@@ -499,6 +499,10 @@ pub fn build_rules(build: &Build) -> Rules {
          .default(true)
          .dep(|s| s.name("default:doc"))
          .run(move |s| dist::docs(build, s.stage, s.target));
+    rules.dist("dist-analysis", "src/libstd")
+         .dep(|s| s.name("dist-std"))
+         .default(true)
+         .run(move |s| dist::analysis(build, &s.compiler(), s.target));
     rules.dist("install", "src")
          .dep(|s| s.name("default:dist"))
          .run(move |s| install::install(build, s.stage, s.target));