about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-12-08 17:13:55 -0800
committerAlex Crichton <alex@alexcrichton.com>2016-12-08 17:14:44 -0800
commitd38db82b291afe172c9477b44ef99f70013010d9 (patch)
tree56bbb25262012eb6743895d40374abdbe43860b8
parent97bfeadfd8eb4db591d9fb0fcfef7472d7480415 (diff)
downloadrust-d38db82b291afe172c9477b44ef99f70013010d9.tar.gz
rust-d38db82b291afe172c9477b44ef99f70013010d9.zip
rustbuild: Implement distcheck
This commit implements the `distcheck` target for rustbuild which is only ever
run on our nightly bots. This essentially just creates a tarball, un-tars it,
and then runs a full build, validating that the release tarballs do indeed have
everything they need to build Rust.
-rw-r--r--src/bootstrap/check.rs30
-rw-r--r--src/bootstrap/dist.rs7
-rw-r--r--src/bootstrap/mk/Makefile.in2
-rw-r--r--src/bootstrap/step.rs12
4 files changed, 42 insertions, 9 deletions
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index c5675fd46cb..46c7fe4753f 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -23,6 +23,7 @@ use std::process::Command;
 use build_helper::output;
 
 use {Build, Compiler, Mode};
+use dist;
 use util::{self, dylib_path, dylib_path_var};
 
 const ADB_TEST_DIR: &'static str = "/data/tmp";
@@ -517,3 +518,32 @@ pub fn android_copy_libs(build: &Build,
         }
     }
 }
+
+/// Run "distcheck", a 'make check' from a tarball
+pub fn distcheck(build: &Build) {
+    if build.config.build != "x86_64-unknown-linux-gnu" {
+        return
+    }
+    if !build.config.host.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
+        return
+    }
+    if !build.config.target.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
+        return
+    }
+
+    let dir = build.out.join("tmp").join("distcheck");
+    let _ = fs::remove_dir_all(&dir);
+    t!(fs::create_dir_all(&dir));
+
+    let mut cmd = Command::new("tar");
+    cmd.arg("-xzf")
+       .arg(dist::rust_src_location(build))
+       .arg("--strip-components=1")
+       .current_dir(&dir);
+    build.run(&mut cmd);
+    build.run(Command::new("./configure")
+                     .current_dir(&dir));
+    build.run(Command::new("make")
+                     .arg("check")
+                     .current_dir(&dir));
+}
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index d603455122e..2fcd45f751c 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -284,6 +284,11 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) {
     t!(fs::remove_dir_all(&image));
 }
 
+pub fn rust_src_location(build: &Build) -> PathBuf {
+    let plain_name = format!("rustc-{}-src", package_vers(build));
+    distdir(build).join(&format!("{}.tar.gz", plain_name))
+}
+
 /// Creates the `rust-src` installer component and the plain source tarball
 pub fn rust_src(build: &Build) {
     println!("Dist src");
@@ -374,7 +379,7 @@ pub fn rust_src(build: &Build) {
 
     // Create plain source tarball
     let mut cmd = Command::new("tar");
-    cmd.arg("-czf").arg(sanitize_sh(&distdir(build).join(&format!("{}.tar.gz", plain_name))))
+    cmd.arg("-czf").arg(sanitize_sh(&rust_src_location(build)))
        .arg(&plain_name)
        .current_dir(&dst);
     build.run(&mut cmd);
diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in
index b165048b7b6..ef02f21a34b 100644
--- a/src/bootstrap/mk/Makefile.in
+++ b/src/bootstrap/mk/Makefile.in
@@ -55,6 +55,8 @@ check-cargotest:
 	$(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS)
 dist:
 	$(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
+distcheck:
+	$(Q)$(BOOTSTRAP) test distcheck
 install:
 	$(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
 tidy:
diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs
index f9eae41a330..efa3e4e5ea1 100644
--- a/src/bootstrap/step.rs
+++ b/src/bootstrap/step.rs
@@ -198,14 +198,6 @@ pub fn build_rules(build: &Build) -> Rules {
              });
     }
     for (krate, path, default) in krates("rustc-main") {
-        // We hijacked the `src/rustc` path above for "build just the compiler"
-        // so let's not reinterpret it here as everything and redirect the
-        // `src/rustc` path to a nonexistent path.
-        let path = if path == "src/rustc" {
-            "path/to/nowhere"
-        } else {
-            path
-        };
         rules.build(&krate.build_step, path)
              .dep(|s| s.name("libtest"))
              .dep(move |s| s.name("llvm").host(&build.config.build).stage(0))
@@ -403,6 +395,10 @@ pub fn build_rules(build: &Build) -> Rules {
          .default(true)
          .host(true)
          .run(move |s| check::docs(build, &s.compiler()));
+    rules.test("check-distcheck", "distcheck")
+         .dep(|s| s.name("dist-src"))
+         .run(move |_| check::distcheck(build));
+
 
     rules.build("test-helpers", "src/rt/rust_test_helpers.c")
          .run(move |s| native::test_helpers(build, s.target));