bootstrap: convert rust-std to use Tarball

This commit is contained in:
Pietro Albini
2020-11-26 22:54:35 +01:00
parent fd4515cb3f
commit 79f60fbd04
2 changed files with 18 additions and 30 deletions
+8 -30
View File
@@ -559,7 +559,7 @@ pub struct Std {
}
impl Step for Std {
type Output = PathBuf;
type Output = Option<PathBuf>;
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -577,46 +577,24 @@ fn make_run(run: RunConfig<'_>) {
});
}
fn run(self, builder: &Builder<'_>) -> PathBuf {
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
let compiler = self.compiler;
let target = self.target;
let name = pkgname(builder, "rust-std");
let archive = distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple));
if skip_host_target_lib(builder, compiler) {
return archive;
return None;
}
builder.ensure(compile::Std { compiler, target });
let image = tmpdir(builder).join(format!("{}-{}-image", name, target.triple));
let _ = fs::remove_dir_all(&image);
let mut tarball = Tarball::new(builder, "rust-std", &target.triple);
tarball.include_target_in_component_name(true);
let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);
let stamp = compile::libstd_stamp(builder, compiler_to_use, target);
copy_target_libs(builder, target, &image, &stamp);
copy_target_libs(builder, target, &tarball.image_dir(), &stamp);
let mut cmd = rust_installer(builder);
cmd.arg("generate")
.arg("--product-name=Rust")
.arg("--rel-manifest-dir=rustlib")
.arg("--success-message=std-is-standing-at-the-ready.")
.arg("--image-dir")
.arg(&image)
.arg("--work-dir")
.arg(&tmpdir(builder))
.arg("--output-dir")
.arg(&distdir(builder))
.arg(format!("--package-name={}-{}", name, target.triple))
.arg(format!("--component-name=rust-std-{}", target.triple))
.arg("--legacy-manifest-dirs=rustlib,cargo");
builder
.info(&format!("Dist std stage{} ({} -> {})", compiler.stage, &compiler.host, target));
let _time = timeit(builder);
builder.run(&mut cmd);
builder.remove_dir(&image);
archive
Some(tarball.generate())
}
}
@@ -1699,7 +1677,7 @@ fn run(self, builder: &Builder<'_>) {
tarballs.extend(rustfmt_installer.clone());
tarballs.extend(llvm_tools_installer);
tarballs.push(analysis_installer);
tarballs.push(std_installer);
tarballs.push(std_installer.expect("missing std"));
if let Some(docs_installer) = docs_installer {
tarballs.push(docs_installer);
}
+10
View File
@@ -35,6 +35,7 @@ pub(crate) struct Tarball<'a> {
overlay_dir: PathBuf,
work_dir: PathBuf,
include_target_in_component_name: bool,
is_preview: bool,
}
@@ -63,6 +64,7 @@ pub(crate) fn new(builder: &'a Builder<'a>, component: &str, target: &str) -> Se
overlay_dir,
work_dir,
include_target_in_component_name: false,
is_preview: false,
}
}
@@ -75,6 +77,10 @@ pub(crate) fn set_product_name(&mut self, name: &str) {
self.product_name = name.into();
}
pub(crate) fn include_target_in_component_name(&mut self, include: bool) {
self.include_target_in_component_name = include;
}
pub(crate) fn is_preview(&mut self, is: bool) {
self.is_preview = is;
}
@@ -123,6 +129,10 @@ pub(crate) fn generate(self) -> PathBuf {
if self.is_preview {
component_name.push_str("-preview");
}
if self.include_target_in_component_name {
component_name.push('-');
component_name.push_str(&self.target);
}
let distdir = crate::dist::distdir(self.builder);
cmd.arg("generate")