Skip to content

Commit 24198ce

Browse files
committed
Move all downloaded repos to the downloads/ dir
1 parent f1dc206 commit 24198ce

File tree

5 files changed

+53
-39
lines changed

5 files changed

+53
-39
lines changed

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,4 @@ perf.data.old
1515
/build_sysroot/compiler-builtins
1616
/build_sysroot/rustc_version
1717
/rust
18-
/rand
19-
/regex
20-
/simple-raytracer
21-
/portable-simd
22-
/abi-cafe
23-
/abi-checker
18+
/download

build_system/abi_cafe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::path::Path;
33

44
use super::build_sysroot;
55
use super::config;
6+
use super::prepare;
67
use super::utils::{cargo_command, spawn_and_wait};
78
use super::SysrootKind;
89

@@ -35,9 +36,8 @@ pub(crate) fn run(
3536
);
3637

3738
eprintln!("Running abi-cafe");
38-
let mut abi_cafe_path = env::current_dir().unwrap();
39-
abi_cafe_path.push("abi-cafe");
40-
env::set_current_dir(&abi_cafe_path.clone()).unwrap();
39+
let abi_cafe_path = prepare::ABI_CAFE.source_dir();
40+
env::set_current_dir(abi_cafe_path.clone()).unwrap();
4141

4242
let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
4343

build_system/prepare.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pub(crate) const SIMPLE_RAYTRACER: GitRepo = GitRepo::github(
3535
);
3636

3737
pub(crate) fn prepare() {
38+
if Path::new("download").exists() {
39+
std::fs::remove_dir_all(Path::new("download")).unwrap();
40+
}
41+
std::fs::create_dir_all(Path::new("download")).unwrap();
42+
3843
prepare_sysroot();
3944

4045
// FIXME maybe install this only locally?
@@ -48,11 +53,15 @@ pub(crate) fn prepare() {
4853
SIMPLE_RAYTRACER.fetch();
4954

5055
eprintln!("[LLVM BUILD] simple-raytracer");
51-
let build_cmd = cargo_command("cargo", "build", None, Path::new("simple-raytracer"));
56+
let build_cmd = cargo_command("cargo", "build", None, &SIMPLE_RAYTRACER.source_dir());
5257
spawn_and_wait(build_cmd);
5358
fs::copy(
54-
Path::new("simple-raytracer/target/debug").join(get_file_name("main", "bin")),
55-
Path::new("simple-raytracer").join(get_file_name("raytracer_cg_llvm", "bin")),
59+
SIMPLE_RAYTRACER
60+
.source_dir()
61+
.join("target")
62+
.join("debug")
63+
.join(get_file_name("main", "bin")),
64+
SIMPLE_RAYTRACER.source_dir().join(get_file_name("raytracer_cg_llvm", "bin")),
5665
)
5766
.unwrap();
5867
}
@@ -106,7 +115,9 @@ impl GitRepo {
106115

107116
pub(crate) fn source_dir(&self) -> PathBuf {
108117
match self.url {
109-
GitRepoUrl::Github { user: _, repo } => PathBuf::from(format!("{}", repo)),
118+
GitRepoUrl::Github { user: _, repo } => {
119+
std::env::current_dir().unwrap().join("download").join(repo)
120+
}
110121
}
111122
}
112123

@@ -142,9 +153,11 @@ fn clone_repo_shallow_github(download_dir: &Path, user: &str, repo: &str, rev: &
142153
return;
143154
}
144155

156+
let downloads_dir = std::env::current_dir().unwrap().join("download");
157+
145158
let archive_url = format!("https://github.com/{}/{}/archive/{}.tar.gz", user, repo, rev);
146-
let archive_file = format!("{}.tar.gz", rev);
147-
let archive_dir = format!("{}-{}", repo, rev);
159+
let archive_file = downloads_dir.join(format!("{}.tar.gz", rev));
160+
let archive_dir = downloads_dir.join(format!("{}-{}", repo, rev));
148161

149162
eprintln!("[DOWNLOAD] {}/{} from {}", user, repo, archive_url);
150163

@@ -160,7 +173,7 @@ fn clone_repo_shallow_github(download_dir: &Path, user: &str, repo: &str, rev: &
160173

161174
// Unpack tar archive
162175
let mut unpack_cmd = Command::new("tar");
163-
unpack_cmd.arg("xf").arg(&archive_file);
176+
unpack_cmd.arg("xf").arg(&archive_file).current_dir(downloads_dir);
164177
spawn_and_wait(unpack_cmd);
165178

166179
// Rename unpacked dir to the expected name

build_system/tests.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::build_sysroot;
22
use super::config;
3+
use super::prepare;
34
use super::rustc_info::get_wrapper_file_name;
45
use super::utils::{cargo_command, hyperfine_command, spawn_and_wait, spawn_and_wait_with_input};
56
use build_system::SysrootKind;
@@ -217,7 +218,7 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
217218

218219
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
219220
TestCase::new("test.rust-random/rand", &|runner| {
220-
runner.in_dir(["rand"], |runner| {
221+
runner.in_dir(prepare::RAND.source_dir(), |runner| {
221222
runner.run_cargo("clean", []);
222223

223224
if runner.host_triple == runner.target_triple {
@@ -230,7 +231,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
230231
});
231232
}),
232233
TestCase::new("bench.simple-raytracer", &|runner| {
233-
runner.in_dir(["simple-raytracer"], |runner| {
234+
runner.in_dir(prepare::SIMPLE_RAYTRACER.source_dir(), |runner| {
234235
let run_runs = env::var("RUN_RUNS").unwrap_or("10".to_string()).parse().unwrap();
235236

236237
if runner.host_triple == runner.target_triple {
@@ -273,19 +274,28 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
273274
});
274275
}),
275276
TestCase::new("test.libcore", &|runner| {
276-
runner.in_dir(["build_sysroot", "sysroot_src", "library", "core", "tests"], |runner| {
277-
runner.run_cargo("clean", []);
277+
runner.in_dir(
278+
std::env::current_dir()
279+
.unwrap()
280+
.join("build_sysroot")
281+
.join("sysroot_src")
282+
.join("library")
283+
.join("core")
284+
.join("tests"),
285+
|runner| {
286+
runner.run_cargo("clean", []);
278287

279-
if runner.host_triple == runner.target_triple {
280-
runner.run_cargo("test", []);
281-
} else {
282-
eprintln!("Cross-Compiling: Not running tests");
283-
runner.run_cargo("build", ["--tests"]);
284-
}
285-
});
288+
if runner.host_triple == runner.target_triple {
289+
runner.run_cargo("test", []);
290+
} else {
291+
eprintln!("Cross-Compiling: Not running tests");
292+
runner.run_cargo("build", ["--tests"]);
293+
}
294+
},
295+
);
286296
}),
287297
TestCase::new("test.regex-shootout-regex-dna", &|runner| {
288-
runner.in_dir(["regex"], |runner| {
298+
runner.in_dir(prepare::REGEX.source_dir(), |runner| {
289299
runner.run_cargo("clean", []);
290300

291301
// newer aho_corasick versions throw a deprecation warning
@@ -336,7 +346,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
336346
});
337347
}),
338348
TestCase::new("test.regex", &|runner| {
339-
runner.in_dir(["regex"], |runner| {
349+
runner.in_dir(prepare::REGEX.source_dir(), |runner| {
340350
runner.run_cargo("clean", []);
341351

342352
// newer aho_corasick versions throw a deprecation warning
@@ -367,7 +377,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
367377
});
368378
}),
369379
TestCase::new("test.portable-simd", &|runner| {
370-
runner.in_dir(["portable-simd"], |runner| {
380+
runner.in_dir(prepare::PORTABLE_SIMD.source_dir(), |runner| {
371381
runner.run_cargo("clean", []);
372382
runner.run_cargo("build", ["--all-targets", "--target", &runner.target_triple]);
373383

@@ -506,16 +516,8 @@ impl TestRunner {
506516
}
507517
}
508518

509-
fn in_dir<'a, I, F>(&self, dir: I, callback: F)
510-
where
511-
I: IntoIterator<Item = &'a str>,
512-
F: FnOnce(&TestRunner),
513-
{
519+
fn in_dir(&self, new: impl AsRef<Path>, callback: impl FnOnce(&TestRunner)) {
514520
let current = env::current_dir().unwrap();
515-
let mut new = current.clone();
516-
for d in dir {
517-
new.push(d);
518-
}
519521

520522
env::set_current_dir(new).unwrap();
521523
callback(self);

clean_all.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ set -e
33

44
rm -rf build_sysroot/{sysroot_src/,target/,compiler-builtins/,rustc_version}
55
rm -rf target/ build/ perf.data{,.old} y.bin
6+
rm -rf download/
7+
8+
# Kept for now in case someone updates their checkout of cg_clif before running clean_all.sh
9+
# FIXME remove at some point in the future
610
rm -rf rand/ regex/ simple-raytracer/ portable-simd/ abi-checker/ abi-cafe/

0 commit comments

Comments
 (0)