Skip to content

Commit

Permalink
bootstrap: convert clippy to use Tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Dec 23, 2020
1 parent 8a711a0 commit 521b884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 48 deletions.
58 changes: 10 additions & 48 deletions src/bootstrap/dist.rs
Expand Up @@ -1256,16 +1256,6 @@ impl Step for Clippy {
let target = self.target;
assert!(builder.config.extended);

let src = builder.src.join("src/tools/clippy");
let release_num = builder.release_num("clippy");
let name = pkgname(builder, "clippy");
let version = builder.clippy_info.version(builder, &release_num);

let tmp = tmpdir(builder);
let image = tmp.join("clippy-image");
drop(fs::remove_dir_all(&image));
builder.create_dir(&image);

// Prepare the image directory
// We expect clippy to build, because we've exited this step above if tool
// state for clippy isn't testing.
Expand All @@ -1275,45 +1265,17 @@ 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");

builder.install(&clippy, &image.join("bin"), 0o755);
builder.install(&cargoclippy, &image.join("bin"), 0o755);
let doc = image.join("share/doc/clippy");
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("clippy-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=clippy-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=clippy-preview");

builder.info(&format!("Dist clippy stage{} ({})", compiler.stage, target));
let _time = timeit(builder);
builder.run(&mut cmd);
distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
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.generate()
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/tarball.rs
Expand Up @@ -9,6 +9,7 @@ pub(crate) enum OverlayKind {
Rust,
LLVM,
Cargo,
Clippy,
}

impl OverlayKind {
Expand All @@ -24,6 +25,11 @@ impl OverlayKind {
"src/tools/cargo/LICENSE-APACHE",
"src/tools/cargo/LICENSE-THIRD-PARTY",
],
OverlayKind::Clippy => &[
"src/tools/clippy/README.md",
"src/tools/clippy/LICENSE-APACHE",
"src/tools/clippy/LICENSE-MIT",
],
}
}

Expand All @@ -34,6 +40,9 @@ impl OverlayKind {
OverlayKind::Cargo => {
builder.cargo_info.version(builder, &builder.release_num("cargo"))
}
OverlayKind::Clippy => {
builder.clippy_info.version(builder, &builder.release_num("clippy"))
}
}
}
}
Expand Down

0 comments on commit 521b884

Please sign in to comment.