Skip to content

Commit

Permalink
rustbuild: Implement distcheck
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Dec 9, 2016
1 parent 97bfead commit d38db82
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
30 changes: 30 additions & 0 deletions src/bootstrap/check.rs
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
}
7 changes: 6 additions & 1 deletion src/bootstrap/dist.rs
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/mk/Makefile.in
Expand Up @@ -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:
Expand Down
12 changes: 4 additions & 8 deletions src/bootstrap/step.rs
Expand Up @@ -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))
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit d38db82

Please sign in to comment.