Skip to content

Commit 1520e42

Browse files
committed
Split distcheck logic into functions
1 parent f6df223 commit 1520e42

File tree

1 file changed

+60
-58
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+60
-58
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,64 +3236,66 @@ impl Step for Distcheck {
32363236
// local source code, built artifacts or configuration by accident
32373237
let root_dir = std::env::temp_dir().join("distcheck");
32383238

3239-
// Check that we can build some basic things from the plain source tarball
3240-
builder.info("Distcheck plain source tarball");
3241-
let plain_src_tarball = builder.ensure(dist::PlainSourceTarball);
3242-
let plain_src_dir = root_dir.join("distcheck-plain-src");
3243-
builder.clear_dir(&plain_src_dir);
3244-
3245-
let configure_args: Vec<String> = std::env::var("DISTCHECK_CONFIGURE_ARGS")
3246-
.map(|args| args.split(" ").map(|s| s.to_string()).collect::<Vec<String>>())
3247-
.unwrap_or_default();
3248-
3249-
// FIXME: unpack the source tarballs into a directory outside the source checkout, to
3250-
// ensure that it cannot access any local state
3251-
// Also ensure that it doesn't use download-ci-llvm
3252-
command("tar")
3253-
.arg("-xf")
3254-
.arg(plain_src_tarball.tarball())
3255-
.arg("--strip-components=1")
3256-
.current_dir(&plain_src_dir)
3257-
.run(builder);
3258-
command("./configure")
3259-
.arg("--set")
3260-
.arg("rust.omit-git-hash=false")
3261-
.args(&configure_args)
3262-
.arg("--enable-vendor")
3263-
.current_dir(&plain_src_dir)
3264-
.run(builder);
3265-
command(helpers::make(&builder.config.host_target.triple))
3266-
.arg("check")
3267-
// Do not run the build as if we were in CI, otherwise git would be assumed to be
3268-
// present, but we build from a tarball here
3269-
.env("GITHUB_ACTIONS", "0")
3270-
.current_dir(&plain_src_dir)
3271-
.run(builder);
3272-
3273-
// Now make sure that rust-src has all of libstd's dependencies
3274-
builder.info("Distcheck rust-src");
3275-
let src_tarball = builder.ensure(dist::Src);
3276-
let src_dir = root_dir.join("distcheck-src");
3277-
builder.clear_dir(&src_dir);
3278-
3279-
command("tar")
3280-
.arg("-xf")
3281-
.arg(src_tarball.tarball())
3282-
.arg("--strip-components=1")
3283-
.current_dir(&src_dir)
3284-
.run(builder);
3285-
3286-
let toml = src_dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
3287-
command(&builder.initial_cargo)
3288-
// Will read the libstd Cargo.toml
3289-
// which uses the unstable `public-dependency` feature.
3290-
.env("RUSTC_BOOTSTRAP", "1")
3291-
.arg("generate-lockfile")
3292-
.arg("--manifest-path")
3293-
.arg(&toml)
3294-
.current_dir(&src_dir)
3295-
.run(builder);
3296-
}
3239+
distcheck_plain_source_tarball(builder, &root_dir.join("distcheck-plain-src"));
3240+
distcheck_rust_src(builder, &root_dir.join("distcheck-src"));
3241+
}
3242+
}
3243+
3244+
fn distcheck_plain_source_tarball(builder: &Builder<'_>, plain_src_dir: &Path) {
3245+
// Check that we can build some basic things from the plain source tarball
3246+
builder.info("Distcheck plain source tarball");
3247+
let plain_src_tarball = builder.ensure(dist::PlainSourceTarball);
3248+
builder.clear_dir(&plain_src_dir);
3249+
3250+
let configure_args: Vec<String> = std::env::var("DISTCHECK_CONFIGURE_ARGS")
3251+
.map(|args| args.split(" ").map(|s| s.to_string()).collect::<Vec<String>>())
3252+
.unwrap_or_default();
3253+
3254+
command("tar")
3255+
.arg("-xf")
3256+
.arg(plain_src_tarball.tarball())
3257+
.arg("--strip-components=1")
3258+
.current_dir(&plain_src_dir)
3259+
.run(builder);
3260+
command("./configure")
3261+
.arg("--set")
3262+
.arg("rust.omit-git-hash=false")
3263+
.args(&configure_args)
3264+
.arg("--enable-vendor")
3265+
.current_dir(&plain_src_dir)
3266+
.run(builder);
3267+
command(helpers::make(&builder.config.host_target.triple))
3268+
.arg("check")
3269+
// Do not run the build as if we were in CI, otherwise git would be assumed to be
3270+
// present, but we build from a tarball here
3271+
.env("GITHUB_ACTIONS", "0")
3272+
.current_dir(&plain_src_dir)
3273+
.run(builder);
3274+
}
3275+
3276+
fn distcheck_rust_src(builder: &Builder<'_>, src_dir: &Path) {
3277+
// Now make sure that rust-src has all of libstd's dependencies
3278+
builder.info("Distcheck rust-src");
3279+
let src_tarball = builder.ensure(dist::Src);
3280+
builder.clear_dir(&src_dir);
3281+
3282+
command("tar")
3283+
.arg("-xf")
3284+
.arg(src_tarball.tarball())
3285+
.arg("--strip-components=1")
3286+
.current_dir(&src_dir)
3287+
.run(builder);
3288+
3289+
let toml = src_dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
3290+
command(&builder.initial_cargo)
3291+
// Will read the libstd Cargo.toml
3292+
// which uses the unstable `public-dependency` feature.
3293+
.env("RUSTC_BOOTSTRAP", "1")
3294+
.arg("generate-lockfile")
3295+
.arg("--manifest-path")
3296+
.arg(&toml)
3297+
.current_dir(&src_dir)
3298+
.run(builder);
32973299
}
32983300

32993301
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)