Skip to content
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

Add the RLS as a submodule and build a package out of it #40584

Merged
merged 5 commits into from
Apr 12, 2017
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
[submodule "book"]
path = src/doc/book
url = https://github.com/rust-lang/book.git
[submodule "rls"]
path = rls
url = https://github.com/rust-lang-nursery/rls.git

1 change: 0 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ opt dist-host-only 0 "only install bins for the host architecture"
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
opt codegen-tests 1 "run the src/test/codegen tests"
opt save-analysis 0 "save API analysis data"
opt option-checking 1 "complain about unrecognized options in this configure script"
opt ninja 0 "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)"
opt locked-deps 0 "force Cargo.lock to be up to date"
Expand Down
1 change: 1 addition & 0 deletions rls
Submodule rls added at 016cbc
4 changes: 0 additions & 4 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub struct Config {
pub rustc_default_ar: Option<String>,
pub rust_optimize_tests: bool,
pub rust_debuginfo_tests: bool,
pub rust_save_analysis: bool,
pub rust_dist_src: bool,

pub build: String,
Expand Down Expand Up @@ -226,7 +225,6 @@ struct Rust {
optimize_tests: Option<bool>,
debuginfo_tests: Option<bool>,
codegen_tests: Option<bool>,
save_analysis: Option<bool>,
}

/// TOML representation of how each build target is configured.
Expand Down Expand Up @@ -352,7 +350,6 @@ impl Config {
set(&mut config.rust_optimize_tests, rust.optimize_tests);
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
set(&mut config.codegen_tests, rust.codegen_tests);
set(&mut config.rust_save_analysis, rust.save_analysis);
set(&mut config.rust_rpath, rust.rpath);
set(&mut config.debug_jemalloc, rust.debug_jemalloc);
set(&mut config.use_jemalloc, rust.use_jemalloc);
Expand Down Expand Up @@ -460,7 +457,6 @@ impl Config {
("LOCAL_REBUILD", self.local_rebuild),
("NINJA", self.ninja),
("CODEGEN_TESTS", self.codegen_tests),
("SAVE_ANALYSIS", self.rust_save_analysis),
("LOCKED_DEPS", self.locked_deps),
("VENDOR", self.vendor),
("FULL_BOOTSTRAP", self.full_bootstrap),
Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@
# saying that the FileCheck executable is missing, you may want to disable this.
#codegen-tests = true

# Flag indicating whether the API analysis data should be saved.
#save-analysis = false

# =============================================================================
# Options for specific targets
#
Expand Down
74 changes: 66 additions & 8 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ use util::{cp_r, libdir, is_dylib, cp_filtered, copy, exe};
fn pkgname(build: &Build, component: &str) -> String {
if component == "cargo" {
format!("{}-{}", component, build.cargo_package_vers())
} else if component == "rls" {
format!("{}-{}", component, build.package_vers(&build.release_num("rls")))
} else {
assert!(component.starts_with("rust"));
format!("{}-{}", component, build.rust_package_vers())
Expand Down Expand Up @@ -315,15 +317,12 @@ pub fn rust_src_location(build: &Build) -> PathBuf {

/// Creates a tarball of save-analysis metadata, if available.
pub fn analysis(build: &Build, compiler: &Compiler, target: &str) {
if !build.config.rust_save_analysis {
return
}

assert!(build.config.extended);
println!("Dist analysis");

if compiler.host != build.config.build {
println!("\tskipping, not a build host");
return
return;
}

// Package save-analysis from stage1 if not doing a full bootstrap, as the
Expand Down Expand Up @@ -393,6 +392,7 @@ pub fn rust_src(build: &Build) {
"man",
"src",
"cargo",
"rls",
];

let filter_fn = move |path: &Path| {
Expand Down Expand Up @@ -539,7 +539,7 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {

let src = build.src.join("cargo");
let etc = src.join("src/etc");
let release_num = build.cargo_release_num();
let release_num = build.release_num("cargo");
let name = pkgname(build, "cargo");
let version = build.cargo_info.version(build, &release_num);

Expand Down Expand Up @@ -593,6 +593,55 @@ pub fn cargo(build: &Build, stage: u32, target: &str) {
build.run(&mut cmd);
}

pub fn rls(build: &Build, stage: u32, target: &str) {
assert!(build.config.extended);
println!("Dist RLS stage{} ({})", stage, target);
let compiler = Compiler::new(stage, &build.config.build);

let src = build.src.join("rls");
let release_num = build.release_num("rls");
let name = pkgname(build, "rls");
let version = build.rls_info.version(build, &release_num);

let tmp = tmpdir(build);
let image = tmp.join("rls-image");
drop(fs::remove_dir_all(&image));
t!(fs::create_dir_all(&image));

// Prepare the image directory
let rls = build.cargo_out(&compiler, Mode::Tool, target)
.join(exe("rls", target));
install(&rls, &image.join("bin"), 0o755);
let doc = image.join("share/doc/rls");
install(&src.join("README.md"), &doc, 0o644);
install(&src.join("LICENSE-MIT"), &doc, 0o644);
install(&src.join("LICENSE-APACHE"), &doc, 0o644);

// Prepare the overlay
let overlay = tmp.join("rls-overlay");
drop(fs::remove_dir_all(&overlay));
t!(fs::create_dir_all(&overlay));
install(&src.join("README.md"), &overlay, 0o644);
install(&src.join("LICENSE-MIT"), &overlay, 0o644);
install(&src.join("LICENSE-APACHE"), &overlay, 0o644);
t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes()));

// Generate the installer tarball
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=RLS-ready-to-serve.")
.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!("--non-installed-overlay={}", sanitize_sh(&overlay)))
.arg(format!("--package-name={}-{}", name, target))
.arg("--component-name=rls")
.arg("--legacy-manifest-dirs=rustlib,cargo");
build.run(&mut cmd);
}

/// Creates a combined installer for the specified target in the provided stage.
pub fn extended(build: &Build, stage: u32, target: &str) {
println!("Dist extended stage{} ({})", stage, target);
Expand All @@ -604,6 +653,12 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
let cargo_installer = dist.join(format!("{}-{}.tar.gz",
pkgname(build, "cargo"),
target));
let rls_installer = dist.join(format!("{}-{}.tar.gz",
pkgname(build, "rls"),
target));
let analysis_installer = dist.join(format!("{}-{}.tar.gz",
pkgname(build, "rust-analysis"),
target));
let docs_installer = dist.join(format!("{}-{}.tar.gz",
pkgname(build, "rust-docs"),
target));
Expand Down Expand Up @@ -631,9 +686,11 @@ pub fn extended(build: &Build, stage: u32, target: &str) {
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
// the std files during uninstall. To do this ensure that rustc comes
// before rust-std in the list below.
let mut input_tarballs = format!("{},{},{},{}",
let mut input_tarballs = format!("{},{},{},{},{},{}",
sanitize_sh(&rustc_installer),
sanitize_sh(&cargo_installer),
sanitize_sh(&rls_installer),
sanitize_sh(&analysis_installer),
sanitize_sh(&docs_installer),
sanitize_sh(&std_installer));
if target.contains("pc-windows-gnu") {
Expand Down Expand Up @@ -946,7 +1003,8 @@ pub fn hash_and_sign(build: &Build) {
cmd.arg(distdir(build));
cmd.arg(today.trim());
cmd.arg(build.rust_package_vers());
cmd.arg(build.package_vers(&build.cargo_release_num()));
cmd.arg(build.package_vers(&build.release_num("cargo")));
cmd.arg(build.package_vers(&build.release_num("rls")));
cmd.arg(addr);

t!(fs::create_dir_all(distdir(build)));
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ pub fn install(build: &Build, stage: u32, host: &str) {
&docdir, &libdir, &mandir, &empty_dir);
}

if build.config.rust_save_analysis {
install_sh(&build, "analysis", "rust-analysis", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}

install_sh(&build, "rustc", "rustc", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
t!(fs::remove_dir_all(&empty_dir));
Expand Down
16 changes: 10 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ pub struct Build {
out: PathBuf,
rust_info: channel::GitInfo,
cargo_info: channel::GitInfo,
rls_info: channel::GitInfo,
local_rebuild: bool,

// Probed tools at runtime
Expand Down Expand Up @@ -234,6 +235,7 @@ impl Build {
};
let rust_info = channel::GitInfo::new(&src);
let cargo_info = channel::GitInfo::new(&src.join("cargo"));
let rls_info = channel::GitInfo::new(&src.join("rls"));
let src_is_git = src.join(".git").exists();

Build {
Expand All @@ -246,6 +248,7 @@ impl Build {

rust_info: rust_info,
cargo_info: cargo_info,
rls_info: rls_info,
local_rebuild: local_rebuild,
cc: HashMap::new(),
cxx: HashMap::new(),
Expand Down Expand Up @@ -545,7 +548,7 @@ impl Build {
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
}

if self.config.rust_save_analysis && compiler.is_final_stage(self) {
if self.config.extended && compiler.is_final_stage(self) {
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
}

Expand Down Expand Up @@ -1017,7 +1020,7 @@ impl Build {

/// Returns the value of `package_vers` above for Cargo
fn cargo_package_vers(&self) -> String {
self.package_vers(&self.cargo_release_num())
self.package_vers(&self.release_num("cargo"))
}

/// Returns the `version` string associated with this compiler for Rust
Expand All @@ -1029,10 +1032,11 @@ impl Build {
self.rust_info.version(self, channel::CFG_RELEASE_NUM)
}

/// Returns the `a.b.c` version that Cargo is at.
fn cargo_release_num(&self) -> String {
/// Returns the `a.b.c` version that the given package is at.
fn release_num(&self, package: &str) -> String {
let mut toml = String::new();
t!(t!(File::open(self.src.join("cargo/Cargo.toml"))).read_to_string(&mut toml));
let toml_file_name = self.src.join(&format!("{}/Cargo.toml", package));
t!(t!(File::open(toml_file_name)).read_to_string(&mut toml));
for line in toml.lines() {
let prefix = "version = \"";
let suffix = "\"";
Expand All @@ -1041,7 +1045,7 @@ impl Build {
}
}

panic!("failed to find version in cargo's Cargo.toml")
panic!("failed to find version in {}'s Cargo.toml", package)
}

/// Returns whether unstable features should be enabled for the compiler
Expand Down
18 changes: 17 additions & 1 deletion src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.host(&build.config.build)
})
.run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
rules.build("tool-rls", "rls")
.host(true)
.dep(|s| s.name("librustc"))
.dep(move |s| {
// rls, like cargo, uses procedural macros
s.name("librustc-link")
.target(&build.config.build)
.host(&build.config.build)
})
.run(move |s| compile::tool(build, s.stage, s.target, "rls"));

// ========================================================================
// Documentation targets
Expand Down Expand Up @@ -691,9 +701,13 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.run(move |s| dist::docs(build, s.stage, s.target));
rules.dist("dist-analysis", "analysis")
.dep(|s| s.name("dist-std"))
.default(true)
.only_host_build(true)
.run(move |s| dist::analysis(build, &s.compiler(), s.target));
rules.dist("dist-rls", "rls")
.host(true)
.only_host_build(true)
.dep(|s| s.name("tool-rls"))
.run(move |s| dist::rls(build, s.stage, s.target));
rules.dist("install", "path/to/nowhere")
.dep(|s| s.name("default:dist"))
.run(move |s| install::install(build, s.stage, s.target));
Expand All @@ -711,6 +725,8 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
.dep(|d| d.name("dist-mingw"))
.dep(|d| d.name("dist-docs"))
.dep(|d| d.name("dist-cargo"))
.dep(|d| d.name("dist-rls"))
.dep(|d| d.name("dist-analysis"))
.run(move |s| dist::extended(build, s.stage, s.target));

rules.dist("dist-sign", "hash-and-sign")
Expand Down
1 change: 0 additions & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fi
if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=nightly"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-save-analysis"

if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
Expand Down
Loading