Skip to content

Commit c3d05d5

Browse files
committed
Put patched sources in build/ instead of download/
1 parent 9f6d65f commit c3d05d5

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

build_system/abi_cafe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{CodegenBackend, SysrootKind};
77
static ABI_CAFE_REPO: GitRepo =
88
GitRepo::github("Gankra", "abi-cafe", "4c6dc8c9c687e2b3a760ff2176ce236872b37212", "abi-cafe");
99

10-
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe");
10+
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target");
1111

1212
pub(crate) fn run(
1313
channel: &str,

build_system/build_sysroot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl SysrootTarget {
156156
}
157157

158158
pub(crate) static ORIG_BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot");
159-
pub(crate) static BUILD_SYSROOT: RelPath = RelPath::DOWNLOAD.join("sysroot");
159+
pub(crate) static BUILD_SYSROOT: RelPath = RelPath::BUILD.join("sysroot");
160160
pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = BUILD_SYSROOT.join("rustc_version");
161161
pub(crate) static SYSROOT_SRC: RelPath = BUILD_SYSROOT.join("sysroot_src");
162162
pub(crate) static STANDARD_LIBRARY: CargoProject =

build_system/prepare.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ fn prepare_stdlib(dirs: &Dirs, rustc: &Path) {
3939
let rustc_version = get_rustc_version(rustc);
4040
fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap();
4141

42-
eprintln!("[GIT] init");
43-
init_git_repo(&SYSROOT_SRC.to_path(dirs));
44-
4542
apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs));
4643
}
4744

@@ -51,15 +48,13 @@ fn prepare_coretests(dirs: &Dirs, rustc: &Path) {
5148

5249
eprintln!("[COPY] coretests src");
5350

54-
fs::create_dir_all(LIBCORE_TESTS_SRC.to_path(dirs)).unwrap();
51+
// FIXME ensure builds error out or update the copy if any of the files copied here change
52+
LIBCORE_TESTS_SRC.ensure_fresh(dirs);
5553
copy_dir_recursively(
5654
&sysroot_src_orig.join("library/core/tests"),
5755
&LIBCORE_TESTS_SRC.to_path(dirs),
5856
);
5957

60-
eprintln!("[GIT] init");
61-
init_git_repo(&LIBCORE_TESTS_SRC.to_path(dirs));
62-
6358
apply_patches(dirs, "coretests", &LIBCORE_TESTS_SRC.to_path(dirs));
6459
}
6560

@@ -85,23 +80,23 @@ impl GitRepo {
8580

8681
pub(crate) const fn source_dir(&self) -> RelPath {
8782
match self.url {
88-
GitRepoUrl::Github { user: _, repo } => RelPath::DOWNLOAD.join(repo),
83+
GitRepoUrl::Github { user: _, repo } => RelPath::BUILD.join(repo),
8984
}
9085
}
9186

9287
pub(crate) fn fetch(&self, dirs: &Dirs) {
88+
let download_dir = match self.url {
89+
GitRepoUrl::Github { user: _, repo } => RelPath::DOWNLOAD.join(repo).to_path(dirs),
90+
};
91+
let source_dir = self.source_dir();
9392
match self.url {
9493
GitRepoUrl::Github { user, repo } => {
95-
clone_repo_shallow_github(
96-
dirs,
97-
&self.source_dir().to_path(dirs),
98-
user,
99-
repo,
100-
self.rev,
101-
);
94+
clone_repo_shallow_github(dirs, &download_dir, user, repo, self.rev);
10295
}
10396
}
104-
apply_patches(dirs, self.patch_name, &self.source_dir().to_path(dirs));
97+
source_dir.ensure_fresh(dirs);
98+
copy_dir_recursively(&download_dir, &source_dir.to_path(dirs));
99+
apply_patches(dirs, self.patch_name, &source_dir.to_path(dirs));
105100
}
106101
}
107102

@@ -118,6 +113,8 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
118113
let mut checkout_cmd = git_command(download_dir, "checkout");
119114
checkout_cmd.arg("-q").arg(rev);
120115
spawn_and_wait(checkout_cmd);
116+
117+
std::fs::remove_dir_all(download_dir.join(".git")).unwrap();
121118
}
122119

123120
fn clone_repo_shallow_github(dirs: &Dirs, download_dir: &Path, user: &str, repo: &str, rev: &str) {
@@ -165,8 +162,6 @@ fn clone_repo_shallow_github(dirs: &Dirs, download_dir: &Path, user: &str, repo:
165162
// Rename unpacked dir to the expected name
166163
std::fs::rename(archive_dir, &download_dir).unwrap();
167164

168-
init_git_repo(&download_dir);
169-
170165
// Cleanup
171166
std::fs::remove_file(archive_file).unwrap();
172167
}
@@ -206,6 +201,8 @@ fn get_patches(dirs: &Dirs, crate_name: &str) -> Vec<PathBuf> {
206201
}
207202

208203
fn apply_patches(dirs: &Dirs, crate_name: &str, target_dir: &Path) {
204+
init_git_repo(&target_dir);
205+
209206
if crate_name == "<none>" {
210207
return;
211208
}

build_system/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
9797
pub(crate) static RAND_REPO: GitRepo =
9898
GitRepo::github("rust-random", "rand", "50b9a447410860af8d6db9a208c3576886955874", "rand");
9999

100-
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand");
100+
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target");
101101

102102
pub(crate) static REGEX_REPO: GitRepo =
103103
GitRepo::github("rust-lang", "regex", "32fed9429eafba0ae92a64b01796a0c5a75b88c8", "regex");
104104

105-
pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex");
105+
pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target");
106106

107107
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
108108
"rust-lang",
@@ -112,9 +112,9 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
112112
);
113113

114114
pub(crate) static PORTABLE_SIMD: CargoProject =
115-
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
115+
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd_target");
116116

117-
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::DOWNLOAD.join("coretests_src");
117+
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests_src");
118118

119119
pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
120120

0 commit comments

Comments
 (0)