diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-04-14 13:17:11 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-06-13 16:39:59 +0000 |
| commit | 0e4139922e08c306620cf5c43721670c55f3684f (patch) | |
| tree | 4c806dfa81e294871fd8436b4fc5a60785da3572 | |
| parent | d0b8896189f5b2fb472d54ed389681dff97d907b (diff) | |
| download | rust-0e4139922e08c306620cf5c43721670c55f3684f.tar.gz rust-0e4139922e08c306620cf5c43721670c55f3684f.zip | |
Put patched sources in build/ instead of download/
| -rw-r--r-- | build_system/abi_cafe.rs | 2 | ||||
| -rw-r--r-- | build_system/build_sysroot.rs | 2 | ||||
| -rw-r--r-- | build_system/prepare.rs | 33 | ||||
| -rw-r--r-- | build_system/tests.rs | 8 |
4 files changed, 21 insertions, 24 deletions
diff --git a/build_system/abi_cafe.rs b/build_system/abi_cafe.rs index 9634430d116..ba15db9f966 100644 --- a/build_system/abi_cafe.rs +++ b/build_system/abi_cafe.rs @@ -7,7 +7,7 @@ use super::{CodegenBackend, SysrootKind}; static ABI_CAFE_REPO: GitRepo = GitRepo::github("Gankra", "abi-cafe", "4c6dc8c9c687e2b3a760ff2176ce236872b37212", "abi-cafe"); -static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe"); +static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target"); pub(crate) fn run( channel: &str, diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 2ed6272b2c5..7ceda34bfac 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -156,7 +156,7 @@ impl SysrootTarget { } pub(crate) static ORIG_BUILD_SYSROOT: RelPath = RelPath::SOURCE.join("build_sysroot"); -pub(crate) static BUILD_SYSROOT: RelPath = RelPath::DOWNLOAD.join("sysroot"); +pub(crate) static BUILD_SYSROOT: RelPath = RelPath::BUILD.join("sysroot"); pub(crate) static SYSROOT_RUSTC_VERSION: RelPath = BUILD_SYSROOT.join("rustc_version"); pub(crate) static SYSROOT_SRC: RelPath = BUILD_SYSROOT.join("sysroot_src"); pub(crate) static STANDARD_LIBRARY: CargoProject = diff --git a/build_system/prepare.rs b/build_system/prepare.rs index ac2dc47dd7f..7bb9eca2945 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -39,9 +39,6 @@ fn prepare_stdlib(dirs: &Dirs, rustc: &Path) { let rustc_version = get_rustc_version(rustc); fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap(); - eprintln!("[GIT] init"); - init_git_repo(&SYSROOT_SRC.to_path(dirs)); - apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs)); } @@ -51,15 +48,13 @@ fn prepare_coretests(dirs: &Dirs, rustc: &Path) { eprintln!("[COPY] coretests src"); - fs::create_dir_all(LIBCORE_TESTS_SRC.to_path(dirs)).unwrap(); + // FIXME ensure builds error out or update the copy if any of the files copied here change + LIBCORE_TESTS_SRC.ensure_fresh(dirs); copy_dir_recursively( &sysroot_src_orig.join("library/core/tests"), &LIBCORE_TESTS_SRC.to_path(dirs), ); - eprintln!("[GIT] init"); - init_git_repo(&LIBCORE_TESTS_SRC.to_path(dirs)); - apply_patches(dirs, "coretests", &LIBCORE_TESTS_SRC.to_path(dirs)); } @@ -85,23 +80,23 @@ impl GitRepo { pub(crate) const fn source_dir(&self) -> RelPath { match self.url { - GitRepoUrl::Github { user: _, repo } => RelPath::DOWNLOAD.join(repo), + GitRepoUrl::Github { user: _, repo } => RelPath::BUILD.join(repo), } } pub(crate) fn fetch(&self, dirs: &Dirs) { + let download_dir = match self.url { + GitRepoUrl::Github { user: _, repo } => RelPath::DOWNLOAD.join(repo).to_path(dirs), + }; + let source_dir = self.source_dir(); match self.url { GitRepoUrl::Github { user, repo } => { - clone_repo_shallow_github( - dirs, - &self.source_dir().to_path(dirs), - user, - repo, - self.rev, - ); + clone_repo_shallow_github(dirs, &download_dir, user, repo, self.rev); } } - apply_patches(dirs, self.patch_name, &self.source_dir().to_path(dirs)); + source_dir.ensure_fresh(dirs); + copy_dir_recursively(&download_dir, &source_dir.to_path(dirs)); + apply_patches(dirs, self.patch_name, &source_dir.to_path(dirs)); } } @@ -118,6 +113,8 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) { let mut checkout_cmd = git_command(download_dir, "checkout"); checkout_cmd.arg("-q").arg(rev); spawn_and_wait(checkout_cmd); + + std::fs::remove_dir_all(download_dir.join(".git")).unwrap(); } 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: // Rename unpacked dir to the expected name std::fs::rename(archive_dir, &download_dir).unwrap(); - init_git_repo(&download_dir); - // Cleanup std::fs::remove_file(archive_file).unwrap(); } @@ -206,6 +201,8 @@ fn get_patches(dirs: &Dirs, crate_name: &str) -> Vec<PathBuf> { } fn apply_patches(dirs: &Dirs, crate_name: &str, target_dir: &Path) { + init_git_repo(&target_dir); + if crate_name == "<none>" { return; } diff --git a/build_system/tests.rs b/build_system/tests.rs index 7efb960697e..f975e43b13d 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -97,12 +97,12 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[ pub(crate) static RAND_REPO: GitRepo = GitRepo::github("rust-random", "rand", "50b9a447410860af8d6db9a208c3576886955874", "rand"); -pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand"); +pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target"); pub(crate) static REGEX_REPO: GitRepo = GitRepo::github("rust-lang", "regex", "32fed9429eafba0ae92a64b01796a0c5a75b88c8", "regex"); -pub(crate) static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex"); +pub(crate) static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex_target"); pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github( "rust-lang", @@ -112,9 +112,9 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github( ); pub(crate) static PORTABLE_SIMD: CargoProject = - CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd"); + CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd_target"); -pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::DOWNLOAD.join("coretests_src"); +pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests_src"); pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests"); |
