Skip to content

Commit 380f541

Browse files
committed
bootstrap: add disabled by default build-manifest dist component
1 parent c83642c commit 380f541

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ impl<'a> Builder<'a> {
462462
dist::LlvmTools,
463463
dist::RustDev,
464464
dist::Extended,
465+
dist::BuildManifest,
465466
dist::HashSign
466467
),
467468
Kind::Install => describe!(

src/bootstrap/dist.rs

+67
Original file line numberDiff line numberDiff line change
@@ -2584,3 +2584,70 @@ impl Step for RustDev {
25842584
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
25852585
}
25862586
}
2587+
2588+
/// Tarball containing a prebuilt version of the build-manifest tool, intented to be used by the
2589+
/// release process to avoid cloning the monorepo and building stuff.
2590+
///
2591+
/// Should not be considered stable by end users.
2592+
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
2593+
pub struct BuildManifest {
2594+
pub target: TargetSelection,
2595+
}
2596+
2597+
impl Step for BuildManifest {
2598+
type Output = PathBuf;
2599+
const DEFAULT: bool = false;
2600+
const ONLY_HOSTS: bool = true;
2601+
2602+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2603+
run.path("src/tools/build-manifest")
2604+
}
2605+
2606+
fn make_run(run: RunConfig<'_>) {
2607+
run.builder.ensure(BuildManifest { target: run.target });
2608+
}
2609+
2610+
fn run(self, builder: &Builder<'_>) -> PathBuf {
2611+
let build_manifest = builder.tool_exe(Tool::BuildManifest);
2612+
2613+
let name = pkgname(builder, "build-manifest");
2614+
let tmp = tmpdir(builder);
2615+
2616+
// Prepare the image.
2617+
let image = tmp.join("build-manifest-image");
2618+
let image_bin = image.join("bin");
2619+
let _ = fs::remove_dir_all(&image);
2620+
t!(fs::create_dir_all(&image_bin));
2621+
builder.install(&build_manifest, &image_bin.join("build-manifest"), 0o755);
2622+
2623+
// Prepare the overlay.
2624+
let overlay = tmp.join("build-manifest-overlay");
2625+
let _ = fs::remove_dir_all(&overlay);
2626+
builder.create_dir(&overlay);
2627+
builder.create(&overlay.join("version"), &builder.rust_version());
2628+
for file in &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"] {
2629+
builder.install(&builder.src.join(file), &overlay, 0o644);
2630+
}
2631+
2632+
// Create the final tarball.
2633+
let mut cmd = rust_installer(builder);
2634+
cmd.arg("generate")
2635+
.arg("--product-name=Rust")
2636+
.arg("--rel-manifest-dir=rustlib")
2637+
.arg("--success-message=build-manifest installed.")
2638+
.arg("--image-dir")
2639+
.arg(&image)
2640+
.arg("--work-dir")
2641+
.arg(&tmpdir(builder))
2642+
.arg("--output-dir")
2643+
.arg(&distdir(builder))
2644+
.arg("--non-installed-overlay")
2645+
.arg(&overlay)
2646+
.arg(format!("--package-name={}-{}", name, self.target.triple))
2647+
.arg("--legacy-manifest-dirs=rustlib,cargo")
2648+
.arg("--component-name=build-manifest");
2649+
2650+
builder.run(&mut cmd);
2651+
distdir(builder).join(format!("{}-{}.tar.gz", name, self.target.triple))
2652+
}
2653+
}

0 commit comments

Comments
 (0)