bootstrap: convert rust-src to use Tarball
This commit is contained in:
parent
2e0a16cf0d
commit
1906c42962
2 changed files with 28 additions and 33 deletions
|
@ -814,9 +814,7 @@ impl Step for Src {
|
|||
|
||||
/// Creates the `rust-src` installer component
|
||||
fn run(self, builder: &Builder<'_>) -> PathBuf {
|
||||
let name = pkgname(builder, "rust-src");
|
||||
let image = tmpdir(builder).join(format!("{}-image", name));
|
||||
let _ = fs::remove_dir_all(&image);
|
||||
let tarball = Tarball::new_targetless(builder, "rust-src");
|
||||
|
||||
// A lot of tools expect the rust-src component to be entirely in this directory, so if you
|
||||
// change that (e.g. by adding another directory `lib/rustlib/src/foo` or
|
||||
|
@ -825,8 +823,7 @@ impl Step for Src {
|
|||
//
|
||||
// NOTE: if you update the paths here, you also should update the "virtual" path
|
||||
// translation code in `imported_source_files` in `src/librustc_metadata/rmeta/decoder.rs`
|
||||
let dst_src = image.join("lib/rustlib/src/rust");
|
||||
t!(fs::create_dir_all(&dst_src));
|
||||
let dst_src = tarball.image_dir().join("lib/rustlib/src/rust");
|
||||
|
||||
let src_files = ["Cargo.lock"];
|
||||
// This is the reduced set of paths which will become the rust-src component
|
||||
|
@ -846,28 +843,7 @@ impl Step for Src {
|
|||
builder.copy(&builder.src.join(file), &dst_src.join(file));
|
||||
}
|
||||
|
||||
// Create source tarball in rust-installer format
|
||||
let mut cmd = rust_installer(builder);
|
||||
cmd.arg("generate")
|
||||
.arg("--product-name=Rust")
|
||||
.arg("--rel-manifest-dir=rustlib")
|
||||
.arg("--success-message=Awesome-Source.")
|
||||
.arg("--image-dir")
|
||||
.arg(&image)
|
||||
.arg("--work-dir")
|
||||
.arg(&tmpdir(builder))
|
||||
.arg("--output-dir")
|
||||
.arg(&distdir(builder))
|
||||
.arg(format!("--package-name={}", name))
|
||||
.arg("--component-name=rust-src")
|
||||
.arg("--legacy-manifest-dirs=rustlib,cargo");
|
||||
|
||||
builder.info("Dist src");
|
||||
let _time = timeit(builder);
|
||||
builder.run(&mut cmd);
|
||||
|
||||
builder.remove_dir(&image);
|
||||
distdir(builder).join(&format!("{}.tar.gz", name))
|
||||
tarball.generate()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ pub(crate) struct Tarball<'a> {
|
|||
|
||||
pkgname: String,
|
||||
component: String,
|
||||
target: String,
|
||||
target: Option<String>,
|
||||
product_name: String,
|
||||
overlay: OverlayKind,
|
||||
|
||||
|
@ -99,6 +99,14 @@ pub(crate) struct Tarball<'a> {
|
|||
|
||||
impl<'a> Tarball<'a> {
|
||||
pub(crate) fn new(builder: &'a Builder<'a>, component: &str, target: &str) -> Self {
|
||||
Self::new_inner(builder, component, Some(target.into()))
|
||||
}
|
||||
|
||||
pub(crate) fn new_targetless(builder: &'a Builder<'a>, component: &str) -> Self {
|
||||
Self::new_inner(builder, component, None)
|
||||
}
|
||||
|
||||
fn new_inner(builder: &'a Builder<'a>, component: &str, target: Option<String>) -> Self {
|
||||
let pkgname = crate::dist::pkgname(builder, component);
|
||||
|
||||
let temp_dir = builder.out.join("tmp").join("tarball").join(component);
|
||||
|
@ -113,7 +121,7 @@ impl<'a> Tarball<'a> {
|
|||
|
||||
pkgname,
|
||||
component: component.into(),
|
||||
target: target.into(),
|
||||
target,
|
||||
product_name: "Rust".into(),
|
||||
overlay: OverlayKind::Rust,
|
||||
|
||||
|
@ -197,7 +205,14 @@ impl<'a> Tarball<'a> {
|
|||
|
||||
let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller);
|
||||
|
||||
self.builder.info(&format!("Dist {} ({})", self.component, self.target));
|
||||
let package_name = if let Some(target) = &self.target {
|
||||
self.builder.info(&format!("Dist {} ({})", self.component, target));
|
||||
format!("{}-{}", self.pkgname, target)
|
||||
} else {
|
||||
self.builder.info(&format!("Dist {}", self.component));
|
||||
self.pkgname.clone()
|
||||
};
|
||||
|
||||
let _time = crate::util::timeit(self.builder);
|
||||
|
||||
let mut component_name = self.component.clone();
|
||||
|
@ -206,7 +221,11 @@ impl<'a> Tarball<'a> {
|
|||
}
|
||||
if self.include_target_in_component_name {
|
||||
component_name.push('-');
|
||||
component_name.push_str(&self.target);
|
||||
component_name.push_str(
|
||||
&self
|
||||
.target
|
||||
.expect("include_target_in_component_name used in a targetless tarball"),
|
||||
);
|
||||
}
|
||||
|
||||
let distdir = crate::dist::distdir(self.builder);
|
||||
|
@ -222,12 +241,12 @@ impl<'a> Tarball<'a> {
|
|||
.arg(&distdir)
|
||||
.arg("--non-installed-overlay")
|
||||
.arg(self.overlay_dir)
|
||||
.arg(format!("--package-name={}-{}", self.pkgname, self.target))
|
||||
.arg(format!("--package-name={}", package_name))
|
||||
.arg("--legacy-manifest-dirs=rustlib,cargo")
|
||||
.arg(format!("--component-name={}", component_name));
|
||||
self.builder.run(&mut cmd);
|
||||
t!(std::fs::remove_dir_all(&self.temp_dir));
|
||||
|
||||
distdir.join(format!("{}-{}.tar.gz", self.pkgname, self.target))
|
||||
distdir.join(format!("{}.tar.gz", package_name))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue