diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 47ad8fae26b..aa4d518d014 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1024,13 +1024,10 @@ impl Step for Cargo { tarball.set_overlay(OverlayKind::Cargo); tarball.add_file(&cargo, "bin", 0o755); - tarball.add_file(src.join("README.md"), "share/doc/cargo", 0o644); - tarball.add_file(src.join("LICENSE-MIT"), "share/doc/cargo", 0o644); - tarball.add_file(src.join("LICENSE-APACHE"), "share/doc/cargo", 0o644); - tarball.add_file(src.join("LICENSE-THIRD-PARTY"), "share/doc/cargo", 0o644); tarball.add_file(etc.join("_cargo"), "share/zsh/site-functions", 0o644); tarball.add_renamed_file(etc.join("cargo.bashcomp.sh"), "etc/bash_completion.d", "cargo"); tarball.add_dir(etc.join("man"), "share/man/man1"); + tarball.add_legal_and_readme_to("share/doc/cargo"); for dirent in fs::read_dir(cargo.parent().unwrap()).expect("read_dir") { let dirent = dirent.expect("read dir entry"); @@ -1265,16 +1262,13 @@ impl Step for Clippy { let cargoclippy = builder .ensure(tool::CargoClippy { compiler, target, extra_features: Vec::new() }) .expect("clippy expected to build - essential tool"); - let src = builder.src.join("src/tools/clippy"); let mut tarball = Tarball::new(builder, "clippy", &target.triple); tarball.set_overlay(OverlayKind::Clippy); tarball.is_preview(true); tarball.add_file(clippy, "bin", 0o755); tarball.add_file(cargoclippy, "bin", 0o755); - tarball.add_file(src.join("README.md"), "share/doc/clippy", 0o644); - tarball.add_file(src.join("LICENSE-APACHE"), "share/doc/clippy", 0o644); - tarball.add_file(src.join("LICENSE-MIT"), "share/doc/clippy", 0o644); + tarball.add_legal_and_readme_to("share/doc/clippy"); tarball.generate() } } diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs index c0c84222e7d..2c8f69e94b3 100644 --- a/src/bootstrap/tarball.rs +++ b/src/bootstrap/tarball.rs @@ -13,7 +13,7 @@ pub(crate) enum OverlayKind { } impl OverlayKind { - fn included_files(&self) -> &[&str] { + fn legal_and_readme(&self) -> &[&str] { match self { OverlayKind::Rust => &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"], OverlayKind::LLVM => { @@ -140,6 +140,12 @@ impl<'a> Tarball<'a> { self.builder.copy(src.as_ref(), &destdir.join(new_name)); } + pub(crate) fn add_legal_and_readme_to(&self, destdir: impl AsRef) { + for file in self.overlay.legal_and_readme() { + self.add_file(self.builder.src.join(file), destdir.as_ref(), 0o644); + } + } + pub(crate) fn add_dir(&self, src: impl AsRef, dest: impl AsRef) { let dest = self.image_dir.join(dest.as_ref()); @@ -153,7 +159,7 @@ impl<'a> Tarball<'a> { if let Some(sha) = self.builder.rust_sha() { self.builder.create(&self.overlay_dir.join("git-commit-hash"), &sha); } - for file in self.overlay.included_files() { + for file in self.overlay.legal_and_readme() { self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644); }