builder.out.join("tmp/dist")
}
-fn rust_installer(builder: &Builder<'_>) -> Command {
- builder.tool_cmd(Tool::RustInstaller)
-}
-
fn missing_tool(tool_name: &str, skip: bool) {
if skip {
println!("Unable to build {}, skipping dist", tool_name)
/// 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
//
// 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
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()
}
}
/// Creates the plain source tarball
fn run(self, builder: &Builder<'_>) -> PathBuf {
- // Make sure that the root folder of tarball has the correct name
- let plain_name = format!("{}-src", pkgname(builder, "rustc"));
- let plain_dst_src = tmpdir(builder).join(&plain_name);
- let _ = fs::remove_dir_all(&plain_dst_src);
- t!(fs::create_dir_all(&plain_dst_src));
+ let tarball = Tarball::new(builder, "rustc", "src");
+ let plain_dst_src = tarball.image_dir();
// This is the set of root paths which will become part of the source package
let src_files = [
builder.run(&mut cmd);
}
- // Create plain source tarball
- let plain_name = format!("rustc-{}-src", builder.rust_package_vers());
- let mut tarball = distdir(builder).join(&format!("{}.tar.gz", plain_name));
- tarball.set_extension(""); // strip .gz
- tarball.set_extension(""); // strip .tar
- if let Some(dir) = tarball.parent() {
- builder.create_dir(&dir);
- }
- builder.info("running installer");
- let mut cmd = rust_installer(builder);
- cmd.arg("tarball")
- .arg("--input")
- .arg(&plain_name)
- .arg("--output")
- .arg(&tarball)
- .arg("--work-dir=.")
- .current_dir(tmpdir(builder));
-
- builder.info("Create plain source tarball");
- let _time = timeit(builder);
- builder.run(&mut cmd);
- distdir(builder).join(&format!("{}.tar.gz", plain_name))
+ tarball.bare()
}
}
let target = self.target;
assert!(builder.config.extended);
- let src = builder.src.join("src/tools/rls");
- let release_num = builder.release_num("rls");
- let name = pkgname(builder, "rls");
- let version = builder.rls_info.version(builder, &release_num);
-
- let tmp = tmpdir(builder);
- let image = tmp.join("rls-image");
- drop(fs::remove_dir_all(&image));
- t!(fs::create_dir_all(&image));
-
- // Prepare the image directory
- // We expect RLS to build, because we've exited this step above if tool
- // state for RLS isn't testing.
let rls = builder
.ensure(tool::Rls { compiler, target, extra_features: Vec::new() })
.or_else(|| {
None
})?;
- builder.install(&rls, &image.join("bin"), 0o755);
- let doc = image.join("share/doc/rls");
- builder.install(&src.join("README.md"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
-
- // Prepare the overlay
- let overlay = tmp.join("rls-overlay");
- drop(fs::remove_dir_all(&overlay));
- t!(fs::create_dir_all(&overlay));
- builder.install(&src.join("README.md"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
- builder.create(&overlay.join("version"), &version);
-
- // Generate the installer tarball
- let mut cmd = rust_installer(builder);
- cmd.arg("generate")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=RLS-ready-to-serve.")
- .arg("--image-dir")
- .arg(&image)
- .arg("--work-dir")
- .arg(&tmpdir(builder))
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg("--non-installed-overlay")
- .arg(&overlay)
- .arg(format!("--package-name={}-{}", name, target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--component-name=rls-preview");
-
- builder.info(&format!("Dist RLS stage{} ({})", compiler.stage, target.triple));
- let _time = timeit(builder);
- builder.run(&mut cmd);
- Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
+ let mut tarball = Tarball::new(builder, "rls", &target.triple);
+ tarball.set_overlay(OverlayKind::RLS);
+ tarball.is_preview(true);
+ tarball.add_file(rls, "bin", 0o755);
+ tarball.add_legal_and_readme_to("share/doc/rls");
+ Some(tarball.generate())
}
}
return None;
}
- let src = builder.src.join("src/tools/rust-analyzer");
- let release_num = builder.release_num("rust-analyzer/crates/rust-analyzer");
- let name = pkgname(builder, "rust-analyzer");
- let version = builder.rust_analyzer_info.version(builder, &release_num);
-
- let tmp = tmpdir(builder);
- let image = tmp.join("rust-analyzer-image");
- drop(fs::remove_dir_all(&image));
- builder.create_dir(&image);
-
- // Prepare the image directory
- // We expect rust-analyer to always build, as it doesn't depend on rustc internals
- // and doesn't have associated toolstate.
let rust_analyzer = builder
.ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() })
.expect("rust-analyzer always builds");
- builder.install(&rust_analyzer, &image.join("bin"), 0o755);
- let doc = image.join("share/doc/rust-analyzer");
- builder.install(&src.join("README.md"), &doc, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
-
- // Prepare the overlay
- let overlay = tmp.join("rust-analyzer-overlay");
- drop(fs::remove_dir_all(&overlay));
- t!(fs::create_dir_all(&overlay));
- builder.install(&src.join("README.md"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
- builder.create(&overlay.join("version"), &version);
-
- // Generate the installer tarball
- let mut cmd = rust_installer(builder);
- cmd.arg("generate")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=rust-analyzer-ready-to-serve.")
- .arg("--image-dir")
- .arg(&image)
- .arg("--work-dir")
- .arg(&tmpdir(builder))
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg("--non-installed-overlay")
- .arg(&overlay)
- .arg(format!("--package-name={}-{}", name, target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--component-name=rust-analyzer-preview");
-
- builder.info(&format!("Dist rust-analyzer stage{} ({})", compiler.stage, target));
- let _time = timeit(builder);
- builder.run(&mut cmd);
- Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
+ let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);
+ tarball.set_overlay(OverlayKind::RustAnalyzer);
+ tarball.is_preview(true);
+ tarball.add_file(rust_analyzer, "bin", 0o755);
+ tarball.add_legal_and_readme_to("share/doc/rust-analyzer");
+ Some(tarball.generate())
}
}
let target = self.target;
assert!(builder.config.extended);
- let src = builder.src.join("src/tools/miri");
- let release_num = builder.release_num("miri");
- let name = pkgname(builder, "miri");
- let version = builder.miri_info.version(builder, &release_num);
-
- let tmp = tmpdir(builder);
- let image = tmp.join("miri-image");
- drop(fs::remove_dir_all(&image));
- builder.create_dir(&image);
-
- // Prepare the image directory
- // We expect miri to build, because we've exited this step above if tool
- // state for miri isn't testing.
let miri = builder
.ensure(tool::Miri { compiler, target, extra_features: Vec::new() })
.or_else(|| {
None
})?;
- builder.install(&miri, &image.join("bin"), 0o755);
- builder.install(&cargomiri, &image.join("bin"), 0o755);
- let doc = image.join("share/doc/miri");
- builder.install(&src.join("README.md"), &doc, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
-
- // Prepare the overlay
- let overlay = tmp.join("miri-overlay");
- drop(fs::remove_dir_all(&overlay));
- t!(fs::create_dir_all(&overlay));
- builder.install(&src.join("README.md"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
- builder.create(&overlay.join("version"), &version);
-
- // Generate the installer tarball
- let mut cmd = rust_installer(builder);
- cmd.arg("generate")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=miri-ready-to-serve.")
- .arg("--image-dir")
- .arg(&image)
- .arg("--work-dir")
- .arg(&tmpdir(builder))
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg("--non-installed-overlay")
- .arg(&overlay)
- .arg(format!("--package-name={}-{}", name, target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--component-name=miri-preview");
-
- builder.info(&format!("Dist miri stage{} ({})", compiler.stage, target));
- let _time = timeit(builder);
- builder.run(&mut cmd);
- Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
+ let mut tarball = Tarball::new(builder, "miri", &target.triple);
+ tarball.set_overlay(OverlayKind::Miri);
+ tarball.is_preview(true);
+ tarball.add_file(miri, "bin", 0o755);
+ tarball.add_file(cargomiri, "bin", 0o755);
+ tarball.add_legal_and_readme_to("share/doc/miri");
+ Some(tarball.generate())
}
}
let compiler = self.compiler;
let target = self.target;
- let src = builder.src.join("src/tools/rustfmt");
- let release_num = builder.release_num("rustfmt");
- let name = pkgname(builder, "rustfmt");
- let version = builder.rustfmt_info.version(builder, &release_num);
-
- let tmp = tmpdir(builder);
- let image = tmp.join("rustfmt-image");
- drop(fs::remove_dir_all(&image));
- builder.create_dir(&image);
-
- // Prepare the image directory
let rustfmt = builder
.ensure(tool::Rustfmt { compiler, target, extra_features: Vec::new() })
.or_else(|| {
None
})?;
- builder.install(&rustfmt, &image.join("bin"), 0o755);
- builder.install(&cargofmt, &image.join("bin"), 0o755);
- let doc = image.join("share/doc/rustfmt");
- builder.install(&src.join("README.md"), &doc, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &doc, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644);
-
- // Prepare the overlay
- let overlay = tmp.join("rustfmt-overlay");
- drop(fs::remove_dir_all(&overlay));
- builder.create_dir(&overlay);
- builder.install(&src.join("README.md"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-MIT"), &overlay, 0o644);
- builder.install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
- builder.create(&overlay.join("version"), &version);
-
- // Generate the installer tarball
- let mut cmd = rust_installer(builder);
- cmd.arg("generate")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=rustfmt-ready-to-fmt.")
- .arg("--image-dir")
- .arg(&image)
- .arg("--work-dir")
- .arg(&tmpdir(builder))
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg("--non-installed-overlay")
- .arg(&overlay)
- .arg(format!("--package-name={}-{}", name, target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--component-name=rustfmt-preview");
-
- builder.info(&format!("Dist Rustfmt stage{} ({})", compiler.stage, target));
- let _time = timeit(builder);
- builder.run(&mut cmd);
- Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
+ let mut tarball = Tarball::new(builder, "rustfmt", &target.triple);
+ tarball.set_overlay(OverlayKind::Rustfmt);
+ tarball.is_preview(true);
+ tarball.add_file(rustfmt, "bin", 0o755);
+ tarball.add_file(cargofmt, "bin", 0o755);
+ tarball.add_legal_and_readme_to("share/doc/rustfmt");
+ Some(tarball.generate())
}
}
let analysis_installer = builder.ensure(Analysis { compiler, target });
let docs_installer = builder.ensure(Docs { host: target });
- let std_installer =
- builder.ensure(Std { compiler: builder.compiler(stage, target), target });
+ let std_installer = builder.ensure(Std { compiler, target });
- let tmp = tmpdir(builder);
- let overlay = tmp.join("extended-overlay");
let etc = builder.src.join("src/etc/installer");
- let work = tmp.join("work");
-
- let _ = fs::remove_dir_all(&overlay);
- builder.install(&builder.src.join("COPYRIGHT"), &overlay, 0o644);
- builder.install(&builder.src.join("LICENSE-APACHE"), &overlay, 0o644);
- builder.install(&builder.src.join("LICENSE-MIT"), &overlay, 0o644);
- let version = builder.rust_version();
- builder.create(&overlay.join("version"), &version);
- if let Some(sha) = builder.rust_sha() {
- builder.create(&overlay.join("git-commit-hash"), &sha);
+
+ // Avoid producing tarballs during a dry run.
+ if builder.config.dry_run {
+ return;
}
- builder.install(&etc.join("README.md"), &overlay, 0o644);
// When rust-std package split from rustc, we needed to ensure that during
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
if target.contains("pc-windows-gnu") {
tarballs.push(mingw_installer.unwrap());
}
- let mut input_tarballs = tarballs[0].as_os_str().to_owned();
- for tarball in &tarballs[1..] {
- input_tarballs.push(",");
- input_tarballs.push(tarball);
- }
- builder.info("building combined installer");
- let mut cmd = rust_installer(builder);
- cmd.arg("combine")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=Rust-is-ready-to-roll.")
- .arg("--work-dir")
- .arg(&work)
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg(format!("--package-name={}-{}", pkgname(builder, "rust"), target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--input-tarballs")
- .arg(input_tarballs)
- .arg("--non-installed-overlay")
- .arg(&overlay);
- let time = timeit(&builder);
- builder.run(&mut cmd);
- drop(time);
+ let mut tarball = Tarball::new(builder, "rust", &target.triple);
+ let work = tarball.persist_work_dir();
+ tarball.combine(&tarballs);
+
+ let tmp = tmpdir(builder).join("combined-tarball");
let mut license = String::new();
license += &builder.read(&builder.src.join("COPYRIGHT"));
}
fn run(self, builder: &Builder<'_>) -> Self::Output {
- let name = pkgname(builder, "reproducible-artifacts");
- let tmp = tmpdir(builder);
-
- // Prepare the image.
- let image = tmp.join("reproducible-artifacts-image");
- let _ = fs::remove_dir_all(&image);
+ let path = builder.config.rust_profile_use.as_ref()?;
- if let Some(path) = &builder.config.rust_profile_use {
- builder.install(std::path::Path::new(path), &image, 0o644);
- } else {
- return None;
- }
-
- // Prepare the overlay.
- let overlay = tmp.join("reproducible-artifacts-overlay");
- let _ = fs::remove_dir_all(&overlay);
- builder.create_dir(&overlay);
- builder.create(&overlay.join("version"), &builder.rust_version());
- for file in &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"] {
- builder.install(&builder.src.join(file), &overlay, 0o644);
- }
-
- // Create the final tarball.
- let mut cmd = rust_installer(builder);
- cmd.arg("generate")
- .arg("--product-name=Rust")
- .arg("--rel-manifest-dir=rustlib")
- .arg("--success-message=reproducible-artifacts installed.")
- .arg("--image-dir")
- .arg(&image)
- .arg("--work-dir")
- .arg(&tmpdir(builder))
- .arg("--output-dir")
- .arg(&distdir(builder))
- .arg("--non-installed-overlay")
- .arg(&overlay)
- .arg(format!("--package-name={}-{}", name, self.target.triple))
- .arg("--legacy-manifest-dirs=rustlib,cargo")
- .arg("--component-name=reproducible-artifacts");
-
- builder.run(&mut cmd);
- Some(distdir(builder).join(format!("{}-{}.tar.gz", name, self.target.triple)))
+ let tarball = Tarball::new(builder, "reproducible-artifacts", &self.target.triple);
+ tarball.add_file(path, ".", 0o644);
+ Some(tarball.generate())
}
}