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

Commit 79f60fb

Browse files
committed
bootstrap: convert rust-std to use Tarball
1 parent fd4515c commit 79f60fb

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

src/bootstrap/dist.rs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub struct Std {
559559
}
560560

561561
impl Step for Std {
562-
type Output = PathBuf;
562+
type Output = Option<PathBuf>;
563563
const DEFAULT: bool = true;
564564

565565
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -577,46 +577,24 @@ impl Step for Std {
577577
});
578578
}
579579

580-
fn run(self, builder: &Builder<'_>) -> PathBuf {
580+
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
581581
let compiler = self.compiler;
582582
let target = self.target;
583583

584-
let name = pkgname(builder, "rust-std");
585-
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple));
586584
if skip_host_target_lib(builder, compiler) {
587-
return archive;
585+
return None;
588586
}
589587

590588
builder.ensure(compile::Std { compiler, target });
591589

592-
let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple));
593-
let _ = fs::remove_dir_all(&image);
590+
let mut tarball = Tarball::new(builder, "rust-std", &target.triple);
591+
tarball.include_target_in_component_name(true);
594592

595593
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
596594
let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
597-
copy_target_libs(builder, target, &image, &stamp);
598-
599-
let mut cmd = rust_installer(builder);
600-
cmd.arg("generate")
601-
.arg("--product-name=Rust")
602-
.arg("--rel-manifest-dir=rustlib")
603-
.arg("--success-message=std-is-standing-at-the-ready.")
604-
.arg("--image-dir")
605-
.arg(&image)
606-
.arg("--work-dir")
607-
.arg(&tmpdir(builder))
608-
.arg("--output-dir")
609-
.arg(&distdir(builder))
610-
.arg(format!("--package-name={}-{}", name, target.triple))
611-
.arg(format!("--component-name=rust-std-{}", target.triple))
612-
.arg("--legacy-manifest-dirs=rustlib,cargo");
595+
copy_target_libs(builder, target, &tarball.image_dir(), &stamp);
613596

614-
builder
615-
.info(&format!("Dist std stage{} ({} -> {})", compiler.stage, &compiler.host, target));
616-
let _time = timeit(builder);
617-
builder.run(&mut cmd);
618-
builder.remove_dir(&image);
619-
archive
597+
Some(tarball.generate())
620598
}
621599
}
622600

@@ -1699,7 +1677,7 @@ impl Step for Extended {
16991677
tarballs.extend(rustfmt_installer.clone());
17001678
tarballs.extend(llvm_tools_installer);
17011679
tarballs.push(analysis_installer);
1702-
tarballs.push(std_installer);
1680+
tarballs.push(std_installer.expect("missing std"));
17031681
if let Some(docs_installer) = docs_installer {
17041682
tarballs.push(docs_installer);
17051683
}

src/bootstrap/tarball.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(crate) struct Tarball<'a> {
3535
overlay_dir: PathBuf,
3636
work_dir: PathBuf,
3737

38+
include_target_in_component_name: bool,
3839
is_preview: bool,
3940
}
4041

@@ -63,6 +64,7 @@ impl<'a> Tarball<'a> {
6364
overlay_dir,
6465
work_dir,
6566

67+
include_target_in_component_name: false,
6668
is_preview: false,
6769
}
6870
}
@@ -75,6 +77,10 @@ impl<'a> Tarball<'a> {
7577
self.product_name = name.into();
7678
}
7779

80+
pub(crate) fn include_target_in_component_name(&mut self, include: bool) {
81+
self.include_target_in_component_name = include;
82+
}
83+
7884
pub(crate) fn is_preview(&mut self, is: bool) {
7985
self.is_preview = is;
8086
}
@@ -123,6 +129,10 @@ impl<'a> Tarball<'a> {
123129
if self.is_preview {
124130
component_name.push_str("-preview");
125131
}
132+
if self.include_target_in_component_name {
133+
component_name.push('-');
134+
component_name.push_str(&self.target);
135+
}
126136

127137
let distdir = crate::dist::distdir(self.builder);
128138
cmd.arg("generate")

0 commit comments

Comments
 (0)