Skip to content

Create tar balls of save-analysis-api metadata for the standard libra… #38102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ fn main() {
cmd.arg("-C").arg(format!("codegen-units={}", s));
}

// Emit save-analysis info.
if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) {
cmd.arg("-Zsave-analysis-api");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this conditionalized on an env var?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, this env var is also set by bootstrap. What all does this env var do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nvm I see what's going on. bootstrap is using this to communicate with the shim.


// Dealing with rpath here is a little special, so let's go into some
// detail. First off, `-rpath` is a linker option on Unix platforms
// which adds to the runtime dynamic loader path when looking for
Expand Down
46 changes: 45 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::io::Write;
use std::path::{PathBuf, Path};
use std::process::Command;

use {Build, Compiler};
use {Build, Compiler, Mode};
use util::{cp_r, libdir, is_dylib, cp_filtered, copy};

pub fn package_vers(build: &Build) -> &str {
Expand Down Expand Up @@ -289,6 +289,50 @@ pub fn rust_src_location(build: &Build) -> PathBuf {
distdir(build).join(&format!("{}.tar.gz", plain_name))
}

/// Creates a tarball of save-analysis metadata, if available.
pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
println!("Dist analysis");

if build.config.channel != "nightly" {
println!("Skipping dist-analysis - not on nightly channel");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this on nightlies I guess is just a conservative precaution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

if compiler.stage != 2 {
return
}

let name = format!("rust-analysis-{}", package_vers(build));
let image = tmpdir(build).join(format!("{}-{}-image", name, target));

let src = build.stage_out(compiler, Mode::Libstd).join(target).join("release").join("deps");

let image_src = src.join("save-analysis");
let dst = image.join("lib/rustlib").join(target).join("analysis");
t!(fs::create_dir_all(&dst));
cp_r(&image_src, &dst);

let mut cmd = Command::new("sh");
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
.arg("--product-name=Rust")
.arg("--rel-manifest-dir=rustlib")
.arg("--success-message=save-analysis-saved.")
.arg(format!("--image-dir={}", sanitize_sh(&image)))
.arg(format!("--work-dir={}", sanitize_sh(&tmpdir(build))))
.arg(format!("--output-dir={}", sanitize_sh(&distdir(build))))
.arg(format!("--package-name={}-{}", name, target))
.arg(format!("--component-name=rust-analysis-{}", target))
.arg("--legacy-manifest-dirs=rustlib,cargo");
build.run(&mut cmd);
t!(fs::remove_dir_all(&image));

// Create plain source tarball
let mut cmd = Command::new("tar");
cmd.arg("-czf").arg(sanitize_sh(&distdir(build).join(&format!("{}.tar.gz", name))))
.arg("analysis")
.current_dir(&src);
build.run(&mut cmd);
}

/// Creates the `rust-src` installer component and the plain source tarball
pub fn rust_src(build: &Build) {
println!("Dist src");
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ impl Build {
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
}

if self.config.channel == "nightly" && compiler.stage == 2 {
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
}

// Environment variables *required* needed throughout the build
//
// FIXME: should update code to not require this env var
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ pub fn build_rules(build: &Build) -> Rules {
.default(true)
.dep(|s| s.name("default:doc"))
.run(move |s| dist::docs(build, s.stage, s.target));
rules.dist("dist-analysis", "src/libstd")
.dep(|s| s.name("dist-std"))
.default(true)
.run(move |s| dist::analysis(build, &s.compiler(), s.target));
rules.dist("install", "src")
.dep(|s| s.name("default:dist"))
.run(move |s| install::install(build, s.stage, s.target));
Expand Down