]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/dist.rs
Deal with spaces in the rust version.
[rust.git] / src / bootstrap / dist.rs
index c64934cd6c9ded20f166b32e7988f80eb94eb68c..98b6be29c073b80d337744658f75f50ad74e2ced 100644 (file)
@@ -688,7 +688,7 @@ impl Step for Std {
     const DEFAULT: bool = true;
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
-        run.path("src/libstd")
+        run.path("library/std")
     }
 
     fn make_run(run: RunConfig<'_>) {
@@ -895,7 +895,15 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
     }
 }
 
-fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) {
+/// Use the `builder` to make a filtered copy of `base`/X for X in (`src_dirs` - `exclude_dirs`) to
+/// `dst_dir`.
+fn copy_src_dirs(
+    builder: &Builder<'_>,
+    base: &Path,
+    src_dirs: &[&str],
+    exclude_dirs: &[&str],
+    dst_dir: &Path,
+) {
     fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
         let spath = match path.to_str() {
             Some(path) => path,
@@ -968,8 +976,7 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
     for item in src_dirs {
         let dst = &dst_dir.join(item);
         t!(fs::create_dir_all(dst));
-        builder
-            .cp_filtered(&builder.src.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
+        builder.cp_filtered(&base.join(item), dst, &|path| filter_fn(exclude_dirs, item, path));
     }
 }
 
@@ -996,32 +1003,30 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
         let image = tmpdir(builder).join(format!("{}-image", name));
         let _ = fs::remove_dir_all(&image);
 
-        let dst = image.join("lib/rustlib/src");
-        let dst_src = dst.join("rust");
+        // A lot of tools expect the rust-src component to be entirely in this directory, so if you
+        // change that (e.g. by adding another directory `lib/rustlib/src/foo` or
+        // `lib/rustlib/src/rust/foo`), you will need to go around hunting for implicit assumptions
+        // and fix them...
+        //
+        // NOTE: if you update the paths here, you also should update the "virtual" path
+        // translation code in `imported_source_files` in `src/librustc_metadata/rmeta/decoder.rs`
+        let dst_src = image.join("lib/rustlib/src/rust");
         t!(fs::create_dir_all(&dst_src));
 
         let src_files = ["Cargo.lock"];
         // This is the reduced set of paths which will become the rust-src component
-        // (essentially libstd and all of its path dependencies)
-        let std_src_dirs = [
-            "src/build_helper",
-            "src/liballoc",
-            "src/libcore",
-            "src/libpanic_abort",
-            "src/libpanic_unwind",
-            "src/libstd",
-            "src/libunwind",
-            "src/libtest",
-            "src/libterm",
-            "src/libprofiler_builtins",
-            "src/stdarch",
-            "src/libproc_macro",
-            "src/tools/rustc-std-workspace-core",
-            "src/tools/rustc-std-workspace-alloc",
-            "src/tools/rustc-std-workspace-std",
-        ];
-
-        copy_src_dirs(builder, &std_src_dirs[..], &[], &dst_src);
+        // (essentially libstd and all of its path dependencies).
+        copy_src_dirs(
+            builder,
+            &builder.src,
+            &["library"],
+            &[
+                // not needed and contains symlinks which rustup currently
+                // chokes on when unpacking.
+                "library/backtrace/crates",
+            ],
+            &dst_src,
+        );
         for file in src_files.iter() {
             builder.copy(&builder.src.join(file), &dst_src.join(file));
         }
@@ -1091,9 +1096,9 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
             "Cargo.toml",
             "Cargo.lock",
         ];
-        let src_dirs = ["src"];
+        let src_dirs = ["src", "library"];
 
-        copy_src_dirs(builder, &src_dirs[..], &[], &plain_dst_src);
+        copy_src_dirs(builder, &builder.src, &src_dirs, &[], &plain_dst_src);
 
         // Copy the files normally
         for item in &src_files {
@@ -1350,7 +1355,7 @@ pub struct RustAnalyzer {
 }
 
 impl Step for RustAnalyzer {
-    type Output = PathBuf;
+    type Output = Option<PathBuf>;
     const ONLY_HOSTS: bool = true;
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1368,11 +1373,17 @@ fn make_run(run: RunConfig<'_>) {
         });
     }
 
-    fn run(self, builder: &Builder<'_>) -> PathBuf {
+    fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
         let compiler = self.compiler;
         let target = self.target;
         assert!(builder.config.extended);
 
+        if target.contains("riscv64") {
+            // riscv64 currently has an LLVM bug that makes rust-analyzer unable
+            // to build. See #74813 for details.
+            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");
@@ -1426,7 +1437,7 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
         builder.info(&format!("Dist rust-analyzer stage{} ({})", compiler.stage, target));
         let _time = timeit(builder);
         builder.run(&mut cmd);
-        distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
+        Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
     }
 }
 
@@ -1784,7 +1795,7 @@ fn run(self, builder: &Builder<'_>) {
         tarballs.push(rustc_installer);
         tarballs.push(cargo_installer);
         tarballs.extend(rls_installer.clone());
-        tarballs.push(rust_analyzer_installer.clone());
+        tarballs.extend(rust_analyzer_installer.clone());
         tarballs.push(clippy_installer);
         tarballs.extend(miri_installer.clone());
         tarballs.extend(rustfmt_installer.clone());
@@ -1862,7 +1873,9 @@ fn filter(contents: &str, marker: &str) -> String {
             if rls_installer.is_none() {
                 contents = filter(&contents, "rls");
             }
-            contents = filter(&contents, "rust-analyzer");
+            if rust_analyzer_installer.is_none() {
+                contents = filter(&contents, "rust-analyzer");
+            }
             if miri_installer.is_none() {
                 contents = filter(&contents, "miri");
             }
@@ -1909,7 +1922,9 @@ fn filter(contents: &str, marker: &str) -> String {
             if rls_installer.is_some() {
                 prepare("rls");
             }
-            prepare("rust-analyzer");
+            if rust_analyzer_installer.is_some() {
+                prepare("rust-analyzer");
+            }
             if miri_installer.is_some() {
                 prepare("miri");
             }
@@ -1971,7 +1986,9 @@ fn filter(contents: &str, marker: &str) -> String {
             if rls_installer.is_some() {
                 prepare("rls");
             }
-            prepare("rust-analyzer");
+            if rust_analyzer_installer.is_some() {
+                prepare("rust-analyzer");
+            }
             if miri_installer.is_some() {
                 prepare("miri");
             }
@@ -2071,23 +2088,25 @@ fn filter(contents: &str, marker: &str) -> String {
                         .arg(etc.join("msi/remove-duplicates.xsl")),
                 );
             }
-            builder.run(
-                Command::new(&heat)
-                    .current_dir(&exe)
-                    .arg("dir")
-                    .arg("rust-analyzer")
-                    .args(&heat_flags)
-                    .arg("-cg")
-                    .arg("RustAnalyzerGroup")
-                    .arg("-dr")
-                    .arg("RustAnalyzer")
-                    .arg("-var")
-                    .arg("var.RustAnalyzerDir")
-                    .arg("-out")
-                    .arg(exe.join("RustAnalyzerGroup.wxs"))
-                    .arg("-t")
-                    .arg(etc.join("msi/remove-duplicates.xsl")),
-            );
+            if rust_analyzer_installer.is_some() {
+                builder.run(
+                    Command::new(&heat)
+                        .current_dir(&exe)
+                        .arg("dir")
+                        .arg("rust-analyzer")
+                        .args(&heat_flags)
+                        .arg("-cg")
+                        .arg("RustAnalyzerGroup")
+                        .arg("-dr")
+                        .arg("RustAnalyzer")
+                        .arg("-var")
+                        .arg("var.RustAnalyzerDir")
+                        .arg("-out")
+                        .arg(exe.join("RustAnalyzerGroup.wxs"))
+                        .arg("-t")
+                        .arg(etc.join("msi/remove-duplicates.xsl")),
+                );
+            }
             builder.run(
                 Command::new(&heat)
                     .current_dir(&exe)
@@ -2181,7 +2200,9 @@ fn filter(contents: &str, marker: &str) -> String {
                 if rls_installer.is_some() {
                     cmd.arg("-dRlsDir=rls");
                 }
-                cmd.arg("-dRustAnalyzerDir=rust-analyzer");
+                if rust_analyzer_installer.is_some() {
+                    cmd.arg("-dRustAnalyzerDir=rust-analyzer");
+                }
                 if miri_installer.is_some() {
                     cmd.arg("-dMiriDir=miri");
                 }
@@ -2201,7 +2222,9 @@ fn filter(contents: &str, marker: &str) -> String {
             if rls_installer.is_some() {
                 candle("RlsGroup.wxs".as_ref());
             }
-            candle("RustAnalyzerGroup.wxs".as_ref());
+            if rust_analyzer_installer.is_some() {
+                candle("RustAnalyzerGroup.wxs".as_ref());
+            }
             if miri_installer.is_some() {
                 candle("MiriGroup.wxs".as_ref());
             }
@@ -2239,7 +2262,9 @@ fn filter(contents: &str, marker: &str) -> String {
             if rls_installer.is_some() {
                 cmd.arg("RlsGroup.wixobj");
             }
-            cmd.arg("RustAnalyzerGroup.wixobj");
+            if rust_analyzer_installer.is_some() {
+                cmd.arg("RustAnalyzerGroup.wixobj");
+            }
             if miri_installer.is_some() {
                 cmd.arg("MiriGroup.wixobj");
             }