Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0a2e1c5

Browse files
committed
bootstrap: convert rustc to use Tarball
1 parent 82d9eaa commit 0a2e1c5

File tree

2 files changed

+11
-52
lines changed

2 files changed

+11
-52
lines changed

src/bootstrap/dist.rs

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -341,30 +341,13 @@ impl Step for Rustc {
341341
let compiler = self.compiler;
342342
let host = self.compiler.host;
343343

344-
let name = pkgname(builder, "rustc");
345-
let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple));
346-
let _ = fs::remove_dir_all(&image);
347-
let overlay = tmpdir(builder).join(format!("{}-{}-overlay", name, host.triple));
348-
let _ = fs::remove_dir_all(&overlay);
344+
builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host.triple));
345+
let _time = timeit(builder);
349346

350-
// Prepare the rustc "image", what will actually end up getting installed
351-
prepare_image(builder, compiler, &image);
347+
let tarball = Tarball::new(builder, "rustc", &host.triple);
352348

353-
// Prepare the overlay which is part of the tarball but won't actually be
354-
// installed
355-
let cp = |file: &str| {
356-
builder.install(&builder.src.join(file), &overlay, 0o644);
357-
};
358-
cp("COPYRIGHT");
359-
cp("LICENSE-APACHE");
360-
cp("LICENSE-MIT");
361-
cp("README.md");
362-
// tiny morsel of metadata is used by rust-packaging
363-
let version = builder.rust_version();
364-
builder.create(&overlay.join("version"), &version);
365-
if let Some(sha) = builder.rust_sha() {
366-
builder.create(&overlay.join("git-commit-hash"), &sha);
367-
}
349+
// Prepare the rustc "image", what will actually end up getting installed
350+
prepare_image(builder, compiler, tarball.image_dir());
368351

369352
// On MinGW we've got a few runtime DLL dependencies that we need to
370353
// include. The first argument to this script is where to put these DLLs
@@ -377,38 +360,11 @@ impl Step for Rustc {
377360
// install will *also* include the rust-mingw package, which also needs
378361
// licenses, so to be safe we just include it here in all MinGW packages.
379362
if host.contains("pc-windows-gnu") {
380-
make_win_dist(&image, &tmpdir(builder), host, builder);
381-
382-
let dst = image.join("share/doc");
383-
t!(fs::create_dir_all(&dst));
384-
builder.cp_r(&builder.src.join("src/etc/third-party"), &dst);
363+
make_win_dist(tarball.image_dir(), &tmpdir(builder), host, builder);
364+
tarball.add_dir(builder.src.join("src/etc/third-party"), "share/doc");
385365
}
386366

387-
// Finally, wrap everything up in a nice tarball!
388-
let mut cmd = rust_installer(builder);
389-
cmd.arg("generate")
390-
.arg("--product-name=Rust")
391-
.arg("--rel-manifest-dir=rustlib")
392-
.arg("--success-message=Rust-is-ready-to-roll.")
393-
.arg("--image-dir")
394-
.arg(&image)
395-
.arg("--work-dir")
396-
.arg(&tmpdir(builder))
397-
.arg("--output-dir")
398-
.arg(&distdir(builder))
399-
.arg("--non-installed-overlay")
400-
.arg(&overlay)
401-
.arg(format!("--package-name={}-{}", name, host.triple))
402-
.arg("--component-name=rustc")
403-
.arg("--legacy-manifest-dirs=rustlib,cargo");
404-
405-
builder.info(&format!("Dist rustc stage{} ({})", compiler.stage, host.triple));
406-
let _time = timeit(builder);
407-
builder.run(&mut cmd);
408-
builder.remove_dir(&image);
409-
builder.remove_dir(&overlay);
410-
411-
return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple));
367+
return tarball.generate();
412368

413369
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
414370
let host = compiler.host;

src/bootstrap/tarball.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ impl<'a> Tarball<'a> {
107107
pub(crate) fn generate(self) -> PathBuf {
108108
t!(std::fs::create_dir_all(&self.overlay_dir));
109109
self.builder.create(&self.overlay_dir.join("version"), &self.builder.rust_version());
110+
if let Some(sha) = self.builder.rust_sha() {
111+
self.builder.create(&self.overlay_dir.join("git-commit-hash"), &sha);
112+
}
110113
for file in self.overlay.included_files() {
111114
self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644);
112115
}

0 commit comments

Comments
 (0)