Skip to content

Commit adb4279

Browse files
committed
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.
2 parents 6a495f7 + d38db82 commit adb4279

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

src/bootstrap/check.rs

+30
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::process::Command;
2323
use build_helper::output;
2424

2525
use {Build, Compiler, Mode};
26+
use dist;
2627
use util::{self, dylib_path, dylib_path_var};
2728

2829
const ADB_TEST_DIR: &'static str = "/data/tmp";
@@ -517,3 +518,32 @@ pub fn android_copy_libs(build: &Build,
517518
}
518519
}
519520
}
521+
522+
/// Run "distcheck", a 'make check' from a tarball
523+
pub fn distcheck(build: &Build) {
524+
if build.config.build != "x86_64-unknown-linux-gnu" {
525+
return
526+
}
527+
if !build.config.host.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
528+
return
529+
}
530+
if !build.config.target.iter().any(|s| s == "x86_64-unknown-linux-gnu") {
531+
return
532+
}
533+
534+
let dir = build.out.join("tmp").join("distcheck");
535+
let _ = fs::remove_dir_all(&dir);
536+
t!(fs::create_dir_all(&dir));
537+
538+
let mut cmd = Command::new("tar");
539+
cmd.arg("-xzf")
540+
.arg(dist::rust_src_location(build))
541+
.arg("--strip-components=1")
542+
.current_dir(&dir);
543+
build.run(&mut cmd);
544+
build.run(Command::new("./configure")
545+
.current_dir(&dir));
546+
build.run(Command::new("make")
547+
.arg("check")
548+
.current_dir(&dir));
549+
}

src/bootstrap/dist.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) {
284284
t!(fs::remove_dir_all(&image));
285285
}
286286

287+
pub fn rust_src_location(build: &Build) -> PathBuf {
288+
let plain_name = format!("rustc-{}-src", package_vers(build));
289+
distdir(build).join(&format!("{}.tar.gz", plain_name))
290+
}
291+
287292
/// Creates the `rust-src` installer component and the plain source tarball
288293
pub fn rust_src(build: &Build) {
289294
println!("Dist src");
@@ -374,7 +379,7 @@ pub fn rust_src(build: &Build) {
374379

375380
// Create plain source tarball
376381
let mut cmd = Command::new("tar");
377-
cmd.arg("-czf").arg(sanitize_sh(&distdir(build).join(&format!("{}.tar.gz", plain_name))))
382+
cmd.arg("-czf").arg(sanitize_sh(&rust_src_location(build)))
378383
.arg(&plain_name)
379384
.current_dir(&dst);
380385
build.run(&mut cmd);

src/bootstrap/mk/Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ check-cargotest:
5555
$(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS)
5656
dist:
5757
$(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
58+
distcheck:
59+
$(Q)$(BOOTSTRAP) test distcheck
5860
install:
5961
$(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
6062
tidy:

src/bootstrap/step.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,6 @@ pub fn build_rules(build: &Build) -> Rules {
198198
});
199199
}
200200
for (krate, path, default) in krates("rustc-main") {
201-
// We hijacked the `src/rustc` path above for "build just the compiler"
202-
// so let's not reinterpret it here as everything and redirect the
203-
// `src/rustc` path to a nonexistent path.
204-
let path = if path == "src/rustc" {
205-
"path/to/nowhere"
206-
} else {
207-
path
208-
};
209201
rules.build(&krate.build_step, path)
210202
.dep(|s| s.name("libtest"))
211203
.dep(move |s| s.name("llvm").host(&build.config.build).stage(0))
@@ -403,6 +395,10 @@ pub fn build_rules(build: &Build) -> Rules {
403395
.default(true)
404396
.host(true)
405397
.run(move |s| check::docs(build, &s.compiler()));
398+
rules.test("check-distcheck", "distcheck")
399+
.dep(|s| s.name("dist-src"))
400+
.run(move |_| check::distcheck(build));
401+
406402

407403
rules.build("test-helpers", "src/rt/rust_test_helpers.c")
408404
.run(move |s| native::test_helpers(build, s.target));

0 commit comments

Comments
 (0)