@@ -39,9 +39,6 @@ fn prepare_stdlib(dirs: &Dirs, rustc: &Path) {
39
39
let rustc_version = get_rustc_version ( rustc) ;
40
40
fs:: write ( SYSROOT_RUSTC_VERSION . to_path ( dirs) , & rustc_version) . unwrap ( ) ;
41
41
42
- eprintln ! ( "[GIT] init" ) ;
43
- init_git_repo ( & SYSROOT_SRC . to_path ( dirs) ) ;
44
-
45
42
apply_patches ( dirs, "stdlib" , & SYSROOT_SRC . to_path ( dirs) ) ;
46
43
}
47
44
@@ -51,15 +48,13 @@ fn prepare_coretests(dirs: &Dirs, rustc: &Path) {
51
48
52
49
eprintln ! ( "[COPY] coretests src" ) ;
53
50
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) ;
55
53
copy_dir_recursively (
56
54
& sysroot_src_orig. join ( "library/core/tests" ) ,
57
55
& LIBCORE_TESTS_SRC . to_path ( dirs) ,
58
56
) ;
59
57
60
- eprintln ! ( "[GIT] init" ) ;
61
- init_git_repo ( & LIBCORE_TESTS_SRC . to_path ( dirs) ) ;
62
-
63
58
apply_patches ( dirs, "coretests" , & LIBCORE_TESTS_SRC . to_path ( dirs) ) ;
64
59
}
65
60
@@ -85,23 +80,23 @@ impl GitRepo {
85
80
86
81
pub ( crate ) const fn source_dir ( & self ) -> RelPath {
87
82
match self . url {
88
- GitRepoUrl :: Github { user : _, repo } => RelPath :: DOWNLOAD . join ( repo) ,
83
+ GitRepoUrl :: Github { user : _, repo } => RelPath :: BUILD . join ( repo) ,
89
84
}
90
85
}
91
86
92
87
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 ( ) ;
93
92
match self . url {
94
93
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 ) ;
102
95
}
103
96
}
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) ) ;
105
100
}
106
101
}
107
102
@@ -118,6 +113,8 @@ fn clone_repo(download_dir: &Path, repo: &str, rev: &str) {
118
113
let mut checkout_cmd = git_command ( download_dir, "checkout" ) ;
119
114
checkout_cmd. arg ( "-q" ) . arg ( rev) ;
120
115
spawn_and_wait ( checkout_cmd) ;
116
+
117
+ std:: fs:: remove_dir_all ( download_dir. join ( ".git" ) ) . unwrap ( ) ;
121
118
}
122
119
123
120
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:
165
162
// Rename unpacked dir to the expected name
166
163
std:: fs:: rename ( archive_dir, & download_dir) . unwrap ( ) ;
167
164
168
- init_git_repo ( & download_dir) ;
169
-
170
165
// Cleanup
171
166
std:: fs:: remove_file ( archive_file) . unwrap ( ) ;
172
167
}
@@ -206,6 +201,8 @@ fn get_patches(dirs: &Dirs, crate_name: &str) -> Vec<PathBuf> {
206
201
}
207
202
208
203
fn apply_patches ( dirs : & Dirs , crate_name : & str , target_dir : & Path ) {
204
+ init_git_repo ( & target_dir) ;
205
+
209
206
if crate_name == "<none>" {
210
207
return ;
211
208
}
0 commit comments