Add bootstrap support for rust-installer

This commit is contained in:
Mark Rousskov 2023-02-28 21:19:07 -05:00
parent 8d9cef4709
commit ddc2d1e806
7 changed files with 60 additions and 10 deletions

View File

@ -711,6 +711,7 @@ macro_rules! describe {
test::RustdocUi,
test::RustdocJson,
test::HtmlCheck,
test::RustInstaller,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows

View File

@ -482,12 +482,7 @@ pub fn new(mut config: Config) -> Build {
// Make sure we update these before gathering metadata so we don't get an error about missing
// Cargo.toml files.
let rust_submodules = [
"src/tools/rust-installer",
"src/tools/cargo",
"library/backtrace",
"library/stdarch",
];
let rust_submodules = ["src/tools/cargo", "library/backtrace", "library/stdarch"];
for s in rust_submodules {
build.update_submodule(Path::new(s));
}

View File

@ -2695,3 +2695,58 @@ fn run(self, builder: &Builder<'_>) {
});
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct RustInstaller;
impl Step for RustInstaller {
type Output = ();
const ONLY_HOSTS: bool = true;
const DEFAULT: bool = true;
/// Ensure the version placeholder replacement tool builds
fn run(self, builder: &Builder<'_>) {
builder.info("test rust-installer");
let bootstrap_host = builder.config.build;
let compiler = builder.compiler(0, bootstrap_host);
let cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolBootstrap,
bootstrap_host,
"test",
"src/tools/rust-installer",
SourceType::InTree,
&[],
);
try_run(builder, &mut cargo.into());
// We currently don't support running the test.sh script outside linux(?) environments.
// Eventually this should likely migrate to #[test]s in rust-installer proper rather than a
// set of scripts, which will likely allow dropping this if.
if bootstrap_host != "x86_64-unknown-linux-gnu" {
return;
}
let mut cmd =
std::process::Command::new(builder.src.join("src/tools/rust-installer/test.sh"));
let tmpdir = testdir(builder, compiler.host).join("rust-installer");
let _ = std::fs::remove_dir_all(&tmpdir);
let _ = std::fs::create_dir_all(&tmpdir);
cmd.current_dir(&tmpdir);
cmd.env("CARGO_TARGET_DIR", tmpdir.join("cargo-target"));
cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir);
try_run(builder, &mut cmd);
}
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/rust-installer")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Self);
}
}

View File

@ -21,4 +21,4 @@ abs_path() {
}
src_dir="$(abs_path $(dirname "$0"))"
cargo run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- combine "$@"

View File

@ -21,4 +21,4 @@ abs_path() {
}
src_dir="$(abs_path $(dirname "$0"))"
cargo run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- generate "$@"

View File

@ -21,4 +21,4 @@ abs_path() {
}
src_dir="$(abs_path $(dirname "$0"))"
cargo run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"
$CARGO run --manifest-path="$src_dir/Cargo.toml" -- tarball "$@"

View File

@ -20,7 +20,6 @@ abs_path() {
S="$(abs_path $(dirname $0))"
TEST_DIR="$S/test"
TMP_DIR="$S/tmp"
WORK_DIR="$TMP_DIR/workdir"
OUT_DIR="$TMP_DIR/outdir"
PREFIX_DIR="$TMP_DIR/prefix"