diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-09-12 13:13:42 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-10-13 13:21:55 +0000 |
| commit | 24198ce6b4937b52203f2b54e31c66b9932ee645 (patch) | |
| tree | ef529b10d469cc8032a900a5308f845ae744de04 | |
| parent | f1dc206c4f87ba637200dc65d6c125534dcf13eb (diff) | |
| download | rust-24198ce6b4937b52203f2b54e31c66b9932ee645.tar.gz rust-24198ce6b4937b52203f2b54e31c66b9932ee645.zip | |
Move all downloaded repos to the downloads/ dir
| -rw-r--r-- | .gitignore | 7 | ||||
| -rw-r--r-- | build_system/abi_cafe.rs | 6 | ||||
| -rw-r--r-- | build_system/prepare.rs | 27 | ||||
| -rw-r--r-- | build_system/tests.rs | 48 | ||||
| -rwxr-xr-x | clean_all.sh | 4 |
5 files changed, 53 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore index 9a4c54f08ca..fae09592c6a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index c2944ce6262..fae5b271636 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -3,6 +3,7 @@ use std::path::Path; 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"]; diff --git a/build_system/prepare.rs b/build_system/prepare.rs index 5c68d7ac972..f9ab8ae7041 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -35,6 +35,11 @@ pub(crate) const SIMPLE_RAYTRACER: GitRepo = GitRepo::github( ); 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 @@ impl GitRepo { 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 diff --git a/build_system/tests.rs b/build_system/tests.rs index d4f393fc7ff..a414b60f4e0 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -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 BASE_SYSROOT_SUITE: &[TestCase] = &[ 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 EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ }); }), 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 EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ }); }), 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 EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ }); }), 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 EXTENDED_SYSROOT_SUITE: &[TestCase] = &[ }); }), 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 @@ impl TestRunner { } } - 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); diff --git a/clean_all.sh b/clean_all.sh index 0fd9b9455a3..fedab2433aa 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -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/ |
