]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/tarball.rs
bootstrap: convert miri to use Tarball
[rust.git] / src / bootstrap / tarball.rs
index bde437723bba10d4b23c8ca21611f714c444193f..0e705a93902e81d5d2470e9ec9f4ae65bf128e74 100644 (file)
@@ -8,15 +8,48 @@
 pub(crate) enum OverlayKind {
     Rust,
     LLVM,
+    Cargo,
+    Clippy,
+    Miri,
 }
 
 impl OverlayKind {
-    fn included_files(&self) -> &[&str] {
+    fn legal_and_readme(&self) -> &[&str] {
         match self {
             OverlayKind::Rust => &["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"],
             OverlayKind::LLVM => {
                 &["src/llvm-project/llvm/LICENSE.TXT", "src/llvm-project/llvm/README.txt"]
             }
+            OverlayKind::Cargo => &[
+                "src/tools/cargo/README.md",
+                "src/tools/cargo/LICENSE-MIT",
+                "src/tools/cargo/LICENSE-APACHE",
+                "src/tools/cargo/LICENSE-THIRD-PARTY",
+            ],
+            OverlayKind::Clippy => &[
+                "src/tools/clippy/README.md",
+                "src/tools/clippy/LICENSE-APACHE",
+                "src/tools/clippy/LICENSE-MIT",
+            ],
+            OverlayKind::Miri => &[
+                "src/tools/miri/README.md",
+                "src/tools/miri/LICENSE-APACHE",
+                "src/tools/miri/LICENSE-MIT",
+            ],
+        }
+    }
+
+    fn version(&self, builder: &Builder<'_>) -> String {
+        match self {
+            OverlayKind::Rust => builder.rust_version(),
+            OverlayKind::LLVM => builder.rust_version(),
+            OverlayKind::Cargo => {
+                builder.cargo_info.version(builder, &builder.release_num("cargo"))
+            }
+            OverlayKind::Clippy => {
+                builder.clippy_info.version(builder, &builder.release_num("clippy"))
+            }
+            OverlayKind::Miri => builder.miri_info.version(builder, &builder.release_num("miri")),
         }
     }
 }
@@ -103,6 +136,23 @@ pub(crate) fn add_file(&self, src: impl AsRef<Path>, destdir: impl AsRef<Path>,
         self.builder.install(src.as_ref(), &destdir, perms);
     }
 
+    pub(crate) fn add_renamed_file(
+        &self,
+        src: impl AsRef<Path>,
+        destdir: impl AsRef<Path>,
+        new_name: &str,
+    ) {
+        let destdir = self.image_dir.join(destdir.as_ref());
+        t!(std::fs::create_dir_all(&destdir));
+        self.builder.copy(src.as_ref(), &destdir.join(new_name));
+    }
+
+    pub(crate) fn add_legal_and_readme_to(&self, destdir: impl AsRef<Path>) {
+        for file in self.overlay.legal_and_readme() {
+            self.add_file(self.builder.src.join(file), destdir.as_ref(), 0o644);
+        }
+    }
+
     pub(crate) fn add_dir(&self, src: impl AsRef<Path>, dest: impl AsRef<Path>) {
         let dest = self.image_dir.join(dest.as_ref());
 
@@ -112,11 +162,11 @@ pub(crate) fn add_dir(&self, src: impl AsRef<Path>, dest: impl AsRef<Path>) {
 
     pub(crate) fn generate(self) -> PathBuf {
         t!(std::fs::create_dir_all(&self.overlay_dir));
-        self.builder.create(&self.overlay_dir.join("version"), &self.builder.rust_version());
+        self.builder.create(&self.overlay_dir.join("version"), &self.overlay.version(self.builder));
         if let Some(sha) = self.builder.rust_sha() {
             self.builder.create(&self.overlay_dir.join("git-commit-hash"), &sha);
         }
-        for file in self.overlay.included_files() {
+        for file in self.overlay.legal_and_readme() {
             self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644);
         }