bootstrap: simplify including licenses and readmes to tarballs

This commit is contained in:
Pietro Albini 2020-11-27 17:56:22 +01:00
parent 521b884913
commit 32afb3c436
No known key found for this signature in database
GPG Key ID: 3E06ABE80BAAF19C
2 changed files with 10 additions and 10 deletions

View File

@ -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()
}
}

View File

@ -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<Path>) {
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<Path>, dest: impl AsRef<Path>) {
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);
}