Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bootstrap: convert rust-analyzer to use Tarball
  • Loading branch information
pietroalbini committed Dec 23, 2020
1 parent cfb23e8 commit 2e0a16c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 50 deletions.
56 changes: 6 additions & 50 deletions src/bootstrap/dist.rs
Expand Up @@ -1122,60 +1122,16 @@ impl Step for RustAnalyzer {
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())
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/tarball.rs
Expand Up @@ -13,6 +13,7 @@ pub(crate) enum OverlayKind {
Miri,
Rustfmt,
RLS,
RustAnalyzer,
}

impl OverlayKind {
Expand Down Expand Up @@ -48,6 +49,11 @@ impl OverlayKind {
"src/tools/rls/LICENSE-APACHE",
"src/tools/rls/LICENSE-MIT",
],
OverlayKind::RustAnalyzer => &[
"src/tools/rust-analyzer/README.md",
"src/tools/rust-analyzer/LICENSE-APACHE",
"src/tools/rust-analyzer/LICENSE-MIT",
],
}
}

Expand All @@ -66,6 +72,9 @@ impl OverlayKind {
builder.rustfmt_info.version(builder, &builder.release_num("rustfmt"))
}
OverlayKind::RLS => builder.rls_info.version(builder, &builder.release_num("rls")),
OverlayKind::RustAnalyzer => builder
.rust_analyzer_info
.version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),
}
}
}
Expand Down

0 comments on commit 2e0a16c

Please sign in to comment.