Skip to content

Commit ddc2d1e

Browse files
Add bootstrap support for rust-installer
1 parent 8d9cef4 commit ddc2d1e

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ impl<'a> Builder<'a> {
711711
test::RustdocUi,
712712
test::RustdocJson,
713713
test::HtmlCheck,
714+
test::RustInstaller,
714715
// Run bootstrap close to the end as it's unlikely to fail
715716
test::Bootstrap,
716717
// Run run-make last, since these won't pass without make on Windows

src/bootstrap/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,7 @@ impl Build {
482482

483483
// Make sure we update these before gathering metadata so we don't get an error about missing
484484
// Cargo.toml files.
485-
let rust_submodules = [
486-
"src/tools/rust-installer",
487-
"src/tools/cargo",
488-
"library/backtrace",
489-
"library/stdarch",
490-
];
485+
let rust_submodules = ["src/tools/cargo", "library/backtrace", "library/stdarch"];
491486
for s in rust_submodules {
492487
build.update_submodule(Path::new(s));
493488
}

src/bootstrap/test.rs

+55
Original file line numberDiff line numberDiff line change
@@ -2695,3 +2695,58 @@ impl Step for LintDocs {
26952695
});
26962696
}
26972697
}
2698+
2699+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2700+
pub struct RustInstaller;
2701+
2702+
impl Step for RustInstaller {
2703+
type Output = ();
2704+
const ONLY_HOSTS: bool = true;
2705+
const DEFAULT: bool = true;
2706+
2707+
/// Ensure the version placeholder replacement tool builds
2708+
fn run(self, builder: &Builder<'_>) {
2709+
builder.info("test rust-installer");
2710+
2711+
let bootstrap_host = builder.config.build;
2712+
let compiler = builder.compiler(0, bootstrap_host);
2713+
let cargo = tool::prepare_tool_cargo(
2714+
builder,
2715+
compiler,
2716+
Mode::ToolBootstrap,
2717+
bootstrap_host,
2718+
"test",
2719+
"src/tools/rust-installer",
2720+
SourceType::InTree,
2721+
&[],
2722+
);
2723+
try_run(builder, &mut cargo.into());
2724+
2725+
// We currently don't support running the test.sh script outside linux(?) environments.
2726+
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
2727+
// set of scripts, which will likely allow dropping this if.
2728+
if bootstrap_host != "x86_64-unknown-linux-gnu" {
2729+
return;
2730+
}
2731+
2732+
let mut cmd =
2733+
std::process::Command::new(builder.src.join("src/tools/rust-installer/test.sh"));
2734+
let tmpdir = testdir(builder, compiler.host).join("rust-installer");
2735+
let _ = std::fs::remove_dir_all(&tmpdir);
2736+
let _ = std::fs::create_dir_all(&tmpdir);
2737+
cmd.current_dir(&tmpdir);
2738+
cmd.env("CARGO_TARGET_DIR", tmpdir.join("cargo-target"));
2739+
cmd.env("CARGO", &builder.initial_cargo);
2740+
cmd.env("RUSTC", &builder.initial_rustc);
2741+
cmd.env("TMP_DIR", &tmpdir);
2742+
try_run(builder, &mut cmd);
2743+
}
2744+
2745+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2746+
run.path("src/tools/rust-installer")
2747+
}
2748+
2749+
fn make_run(run: RunConfig<'_>) {
2750+
run.builder.ensure(Self);
2751+
}
2752+
}

src/tools/rust-installer/combine-installers.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ abs_path() {
2121
}
2222

2323
src_dir="$(abs_path $(dirname "$0"))"
24-
cargo run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"
24+
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"

src/tools/rust-installer/gen-installer.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ abs_path() {
2121
}
2222

2323
src_dir="$(abs_path $(dirname "$0"))"
24-
cargo run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"
24+
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"

src/tools/rust-installer/make-tarballs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ abs_path() {
2121
}
2222

2323
src_dir="$(abs_path $(dirname "$0"))"
24-
cargo run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"
24+
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"

src/tools/rust-installer/test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ abs_path() {
2020
S="$(abs_path $(dirname $0))"
2121

2222
TEST_DIR="$S/test"
23-
TMP_DIR="$S/tmp"
2423
WORK_DIR="$TMP_DIR/workdir"
2524
OUT_DIR="$TMP_DIR/outdir"
2625
PREFIX_DIR="$TMP_DIR/prefix"

0 commit comments

Comments
 (0)