about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-04-12 05:26:10 +0000
committerbors <bors@rust-lang.org>2017-04-12 05:26:10 +0000
commit8c6e2ff45248dde631ff93f6fc21049dbafd5cba (patch)
treeed124cc3405275ab7c6cb3b88365efb2184943d3 /src
parentda32752d92589e99feab80921b9eecb6090cf310 (diff)
parent13d008d1e8b671e78c92e61b42ae7b82f5736121 (diff)
downloadrust-8c6e2ff45248dde631ff93f6fc21049dbafd5cba.tar.gz
rust-8c6e2ff45248dde631ff93f6fc21049dbafd5cba.zip
Auto merge of #40584 - nrc:rls-submod, r=alexcrichton
Add the RLS as a submodule and build a package out of it

r? @brson (and cc @alexcrichton) Please review closely, I am not at all convinced I've done the right things here. I did run `x.py dist` and it makes an rls package which looks right to my eyes, but I haven't tested on non-linux platforms nor am I really sure what it should look like.

This does not attempt to run tests for the RLS yet.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/config.rs4
-rw-r--r--src/bootstrap/config.toml.example3
-rw-r--r--src/bootstrap/dist.rs74
-rw-r--r--src/bootstrap/install.rs5
-rw-r--r--src/bootstrap/lib.rs16
-rw-r--r--src/bootstrap/step.rs18
-rwxr-xr-xsrc/ci/run.sh1
-rw-r--r--src/tools/build-manifest/src/main.rs30
8 files changed, 113 insertions, 38 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 52ebf401aef..693114d01ad 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -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,
@@ -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.
@@ -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);
@@ -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),
diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example
index 6b2cc6eb647..fad79022043 100644
--- a/src/bootstrap/config.toml.example
+++ b/src/bootstrap/config.toml.example
@@ -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
 #
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 6472b1a928c..4328c4e3f1d 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -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())
@@ -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
@@ -393,6 +392,7 @@ pub fn rust_src(build: &Build) {
         "man",
         "src",
         "cargo",
+        "rls",
     ];
 
     let filter_fn = move |path: &Path| {
@@ -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);
 
@@ -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);
@@ -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));
@@ -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") {
@@ -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)));
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 25082e3a9d0..d508616e4b1 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -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));
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 8303a40bb69..d711b63ea2e 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -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
@@ -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 {
@@ -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(),
@@ -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());
         }
 
@@ -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
@@ -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 = "\"";
@@ -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
diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs
index 5560b5b0333..596cbcf01bb 100644
--- a/src/bootstrap/step.rs
+++ b/src/bootstrap/step.rs
@@ -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
@@ -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));
@@ -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")
diff --git a/src/ci/run.sh b/src/ci/run.sh
index 6c6a49ada15..c6510120b47 100755
--- a/src/ci/run.sh
+++ b/src/ci/run.sh
@@ -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"
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
index a7a43e6858e..28c8d227073 100644
--- a/src/tools/build-manifest/src/main.rs
+++ b/src/tools/build-manifest/src/main.rs
@@ -135,6 +135,7 @@ macro_rules! t {
 struct Builder {
     rust_release: String,
     cargo_release: String,
+    rls_release: String,
     input: PathBuf,
     output: PathBuf,
     gpg_passphrase: String,
@@ -143,6 +144,7 @@ struct Builder {
     date: String,
     rust_version: String,
     cargo_version: String,
+    rls_version: String,
 }
 
 fn main() {
@@ -152,6 +154,7 @@ fn main() {
     let date = args.next().unwrap();
     let rust_release = args.next().unwrap();
     let cargo_release = args.next().unwrap();
+    let rls_release = args.next().unwrap();
     let s3_address = args.next().unwrap();
     let mut passphrase = String::new();
     t!(io::stdin().read_to_string(&mut passphrase));
@@ -159,6 +162,7 @@ fn main() {
     Builder {
         rust_release: rust_release,
         cargo_release: cargo_release,
+        rls_release: rls_release,
         input: input,
         output: output,
         gpg_passphrase: passphrase,
@@ -167,6 +171,7 @@ fn main() {
         date: date,
         rust_version: String::new(),
         cargo_version: String::new(),
+        rls_version: String::new(),
     }.build();
 }
 
@@ -174,6 +179,7 @@ impl Builder {
     fn build(&mut self) {
         self.rust_version = self.version("rust", "x86_64-unknown-linux-gnu");
         self.cargo_version = self.version("cargo", "x86_64-unknown-linux-gnu");
+        self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu");
 
         self.digest_and_sign();
         let Manifest { manifest_version, date, pkg } = self.build_manifest();
@@ -223,10 +229,8 @@ impl Builder {
         self.package("rust-std", &mut manifest.pkg, TARGETS);
         self.package("rust-docs", &mut manifest.pkg, TARGETS);
         self.package("rust-src", &mut manifest.pkg, &["*"]);
-
-        if self.rust_release == "nightly" {
-            self.package("rust-analysis", &mut manifest.pkg, TARGETS);
-        }
+        self.package("rls", &mut manifest.pkg, HOSTS);
+        self.package("rust-analysis", &mut manifest.pkg, TARGETS);
 
         let mut pkg = Package {
             version: self.cached_version("rust").to_string(),
@@ -265,6 +269,14 @@ impl Builder {
                 });
             }
 
+            extensions.push(Component {
+                pkg: "rls".to_string(),
+                target: host.to_string(),
+            });
+            extensions.push(Component {
+                pkg: "rust-analysis".to_string(),
+                target: host.to_string(),
+            });
             for target in TARGETS {
                 if target != host {
                     extensions.push(Component {
@@ -272,12 +284,6 @@ impl Builder {
                         target: target.to_string(),
                     });
                 }
-                if self.rust_release == "nightly" {
-                    extensions.push(Component {
-                        pkg: "rust-analysis".to_string(),
-                        target: target.to_string(),
-                    });
-                }
             }
             extensions.push(Component {
                 pkg: "rust-src".to_string(),
@@ -343,6 +349,8 @@ impl Builder {
             format!("rust-src-{}.tar.gz", self.rust_release)
         } else if component == "cargo" {
             format!("cargo-{}-{}.tar.gz", self.cargo_release, target)
+        } else if component == "rls" {
+            format!("rls-{}-{}.tar.gz", self.rls_release, target)
         } else {
             format!("{}-{}-{}.tar.gz", component, self.rust_release, target)
         }
@@ -351,6 +359,8 @@ impl Builder {
     fn cached_version(&self, component: &str) -> &str {
         if component == "cargo" {
             &self.cargo_version
+        } else if component == "rls" {
+            &self.rls_version
         } else {
             &self.rust_version
         }