]> git.lizzy.rs Git - rust.git/commitdiff
Move all downloaded repos to the downloads/ dir
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>
Mon, 12 Sep 2022 13:13:42 +0000 (13:13 +0000)
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>
Thu, 13 Oct 2022 13:21:55 +0000 (13:21 +0000)
.gitignore
build_system/abi_cafe.rs
build_system/prepare.rs
build_system/tests.rs
clean_all.sh

index 9a4c54f08ca8cd6fc4c2dae7e26ce298d6885b23..fae09592c6ac0dc91be2641093896c0adc9559d8 100644 (file)
@@ -15,9 +15,4 @@ perf.data.old
 /build_sysroot/compiler-builtins
 /build_sysroot/rustc_version
 /rust
-/rand
-/regex
-/simple-raytracer
-/portable-simd
-/abi-cafe
-/abi-checker
+/download
index c2944ce62623a600b36ffbdf2e97bbfbb8ab73ed..fae5b27163680badc511023892f92fe462ddfbaf 100644 (file)
@@ -3,6 +3,7 @@
 
 use super::build_sysroot;
 use super::config;
+use super::prepare;
 use super::utils::{cargo_command, spawn_and_wait};
 use super::SysrootKind;
 
@@ -35,9 +36,8 @@ pub(crate) fn run(
     );
 
     eprintln!("Running abi-cafe");
-    let mut abi_cafe_path = env::current_dir().unwrap();
-    abi_cafe_path.push("abi-cafe");
-    env::set_current_dir(&abi_cafe_path.clone()).unwrap();
+    let abi_cafe_path = prepare::ABI_CAFE.source_dir();
+    env::set_current_dir(abi_cafe_path.clone()).unwrap();
 
     let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
 
index 5c68d7ac97283d02f3351ae6872528dc5d3a6003..f9ab8ae70412b0ec2d909767557777f268755cc3 100644 (file)
 );
 
 pub(crate) fn prepare() {
+    if Path::new("download").exists() {
+        std::fs::remove_dir_all(Path::new("download")).unwrap();
+    }
+    std::fs::create_dir_all(Path::new("download")).unwrap();
+
     prepare_sysroot();
 
     // FIXME maybe install this only locally?
@@ -48,11 +53,15 @@ pub(crate) fn prepare() {
     SIMPLE_RAYTRACER.fetch();
 
     eprintln!("[LLVM BUILD] simple-raytracer");
-    let build_cmd = cargo_command("cargo", "build", None, Path::new("simple-raytracer"));
+    let build_cmd = cargo_command("cargo", "build", None, &SIMPLE_RAYTRACER.source_dir());
     spawn_and_wait(build_cmd);
     fs::copy(
-        Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin")),
-        Path::new("simple-raytracer").join(get_file_name("raytracer_cg_llvm", "bin")),
+        SIMPLE_RAYTRACER
+            .source_dir()
+            .join("target")
+            .join("debug")
+            .join(get_file_name("main", "bin")),
+        SIMPLE_RAYTRACER.source_dir().join(get_file_name("raytracer_cg_llvm", "bin")),
     )
     .unwrap();
 }
@@ -106,7 +115,9 @@ const fn github(
 
     pub(crate) fn source_dir(&self) -> PathBuf {
         match self.url {
-            GitRepoUrl::Github { user: _, repo } => PathBuf::from(format!("{}", repo)),
+            GitRepoUrl::Github { user: _, repo } => {
+                std::env::current_dir().unwrap().join("download").join(repo)
+            }
         }
     }
 
@@ -142,9 +153,11 @@ fn clone_repo_shallow_github(download_dir: &Path, user: &str, repo: &str, rev: &
         return;
     }
 
+    let downloads_dir = std::env::current_dir().unwrap().join("download");
+
     let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", user, repo, rev);
-    let archive_file = format!("{}.tar.gz", rev);
-    let archive_dir = format!("{}-{}", repo, rev);
+    let archive_file = downloads_dir.join(format!("{}.tar.gz", rev));
+    let archive_dir = downloads_dir.join(format!("{}-{}", repo, rev));
 
     eprintln!("[DOWNLOAD] {}/{} from {}", user, repo, archive_url);
 
@@ -160,7 +173,7 @@ fn clone_repo_shallow_github(download_dir: &Path, user: &str, repo: &str, rev: &
 
     // Unpack tar archive
     let mut unpack_cmd = Command::new("tar");
-    unpack_cmd.arg("xf").arg(&archive_file);
+    unpack_cmd.arg("xf").arg(&archive_file).current_dir(downloads_dir);
     spawn_and_wait(unpack_cmd);
 
     // Rename unpacked dir to the expected name
index d4f393fc7ff92865ea2c176e2fea961a882276b3..a414b60f4e06b2b79dccc1ee64bc233f32ae6ba1 100644 (file)
@@ -1,5 +1,6 @@
 use super::build_sysroot;
 use super::config;
+use super::prepare;
 use super::rustc_info::get_wrapper_file_name;
 use super::utils::{cargo_command, hyperfine_command, spawn_and_wait, spawn_and_wait_with_input};
 use build_system::SysrootKind;
@@ -217,7 +218,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
 
 const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
     TestCase::new("test.rust-random/rand", &|runner| {
-        runner.in_dir(["rand"], |runner| {
+        runner.in_dir(prepare::RAND.source_dir(), |runner| {
             runner.run_cargo("clean", []);
 
             if runner.host_triple == runner.target_triple {
@@ -230,7 +231,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
         });
     }),
     TestCase::new("bench.simple-raytracer", &|runner| {
-        runner.in_dir(["simple-raytracer"], |runner| {
+        runner.in_dir(prepare::SIMPLE_RAYTRACER.source_dir(), |runner| {
             let run_runs = env::var("RUN_RUNS").unwrap_or("10".to_string()).parse().unwrap();
 
             if runner.host_triple == runner.target_triple {
@@ -273,19 +274,28 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
         });
     }),
     TestCase::new("test.libcore", &|runner| {
-        runner.in_dir(["build_sysroot", "sysroot_src", "library", "core", "tests"], |runner| {
-            runner.run_cargo("clean", []);
+        runner.in_dir(
+            std::env::current_dir()
+                .unwrap()
+                .join("build_sysroot")
+                .join("sysroot_src")
+                .join("library")
+                .join("core")
+                .join("tests"),
+            |runner| {
+                runner.run_cargo("clean", []);
 
-            if runner.host_triple == runner.target_triple {
-                runner.run_cargo("test", []);
-            } else {
-                eprintln!("Cross-Compiling: Not running tests");
-                runner.run_cargo("build", ["--tests"]);
-            }
-        });
+                if runner.host_triple == runner.target_triple {
+                    runner.run_cargo("test", []);
+                } else {
+                    eprintln!("Cross-Compiling: Not running tests");
+                    runner.run_cargo("build", ["--tests"]);
+                }
+            },
+        );
     }),
     TestCase::new("test.regex-shootout-regex-dna", &|runner| {
-        runner.in_dir(["regex"], |runner| {
+        runner.in_dir(prepare::REGEX.source_dir(), |runner| {
             runner.run_cargo("clean", []);
 
             // newer aho_corasick versions throw a deprecation warning
@@ -336,7 +346,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
         });
     }),
     TestCase::new("test.regex", &|runner| {
-        runner.in_dir(["regex"], |runner| {
+        runner.in_dir(prepare::REGEX.source_dir(), |runner| {
             runner.run_cargo("clean", []);
 
             // newer aho_corasick versions throw a deprecation warning
@@ -367,7 +377,7 @@ const fn new(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
         });
     }),
     TestCase::new("test.portable-simd", &|runner| {
-        runner.in_dir(["portable-simd"], |runner| {
+        runner.in_dir(prepare::PORTABLE_SIMD.source_dir(), |runner| {
             runner.run_cargo("clean", []);
             runner.run_cargo("build", ["--all-targets", "--target", &runner.target_triple]);
 
@@ -506,16 +516,8 @@ pub fn run_testsuite(&self, tests: &[TestCase]) {
         }
     }
 
-    fn in_dir<'a, I, F>(&self, dir: I, callback: F)
-    where
-        I: IntoIterator<Item = &'a str>,
-        F: FnOnce(&TestRunner),
-    {
+    fn in_dir(&self, new: impl AsRef<Path>, callback: impl FnOnce(&TestRunner)) {
         let current = env::current_dir().unwrap();
-        let mut new = current.clone();
-        for d in dir {
-            new.push(d);
-        }
 
         env::set_current_dir(new).unwrap();
         callback(self);
index 0fd9b9455a3f11d2384e354b3ec7479cd55171ca..fedab2433aa05f66f33949f35ea62cd88ec3f4ed 100755 (executable)
@@ -3,4 +3,8 @@ set -e
 
 rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version}
 rm -rf target/ build/ perf.data{,.old} y.bin
+rm -rf download/
+
+# Kept for now in case someone updates their checkout of cg_clif before running clean_all.sh
+# FIXME remove at some point in the future
 rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/