Auto merge of #38256 - alexcrichton:distcheck, r=brson

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.
This commit is contained in:
bors 2016-12-09 07:08:29 +00:00
commit adb4279e54
4 changed files with 42 additions and 9 deletions

View File

@ -23,6 +23,7 @@ use std::process::Command;
use build_helper::output; use build_helper::output;
use {Build, Compiler, Mode}; use {Build, Compiler, Mode};
use dist;
use util::{self, dylib_path, dylib_path_var}; use util::{self, dylib_path, dylib_path_var};
const ADB_TEST_DIR: &'static str = "/data/tmp"; 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));
}

View File

@ -284,6 +284,11 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) {
t!(fs::remove_dir_all(&image)); 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 /// Creates the `rust-src` installer component and the plain source tarball
pub fn rust_src(build: &Build) { pub fn rust_src(build: &Build) {
println!("Dist src"); println!("Dist src");
@ -374,7 +379,7 @@ pub fn rust_src(build: &Build) {
// Create plain source tarball // Create plain source tarball
let mut cmd = Command::new("tar"); 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) .arg(&plain_name)
.current_dir(&dst); .current_dir(&dst);
build.run(&mut cmd); build.run(&mut cmd);

View File

@ -55,6 +55,8 @@ check-cargotest:
$(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS) $(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS)
dist: dist:
$(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS) $(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
distcheck:
$(Q)$(BOOTSTRAP) test distcheck
install: install:
$(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS) $(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
tidy: tidy:

View File

@ -198,14 +198,6 @@ pub fn build_rules(build: &Build) -> Rules {
}); });
} }
for (krate, path, default) in krates("rustc-main") { 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) rules.build(&krate.build_step, path)
.dep(|s| s.name("libtest")) .dep(|s| s.name("libtest"))
.dep(move |s| s.name("llvm").host(&build.config.build).stage(0)) .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) .default(true)
.host(true) .host(true)
.run(move |s| check::docs(build, &s.compiler())); .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") rules.build("test-helpers", "src/rt/rust_test_helpers.c")
.run(move |s| native::test_helpers(build, s.target)); .run(move |s| native::test_helpers(build, s.target));