@@ -30,7 +30,7 @@ use build_helper::{output, mtime, up_to_date};
30
30
use filetime:: FileTime ;
31
31
use serde_json;
32
32
33
- use util:: { exe, libdir, is_dylib, copy , read_stamp_file , CiEnv } ;
33
+ use util:: { exe, libdir, is_dylib, CiEnv } ;
34
34
use { Build , Compiler , Mode } ;
35
35
use native;
36
36
use tool;
@@ -130,7 +130,7 @@ fn copy_musl_third_party_objects(build: &Build,
130
130
target : Interned < String > ,
131
131
into : & Path ) {
132
132
for & obj in & [ "crt1.o" , "crti.o" , "crtn.o" ] {
133
- copy ( & build. musl_root ( target) . unwrap ( ) . join ( "lib" ) . join ( obj) , & into. join ( obj) ) ;
133
+ build . copy ( & build. musl_root ( target) . unwrap ( ) . join ( "lib" ) . join ( obj) , & into. join ( obj) ) ;
134
134
}
135
135
}
136
136
@@ -220,13 +220,13 @@ impl Step for StdLink {
220
220
target_compiler. host,
221
221
target) ;
222
222
let libdir = builder. sysroot_libdir ( target_compiler, target) ;
223
- add_to_sysroot ( & libdir, & libstd_stamp ( build, compiler, target) ) ;
223
+ add_to_sysroot ( & build , & libdir, & libstd_stamp ( build, compiler, target) ) ;
224
224
225
225
if build. config . sanitizers && compiler. stage != 0 && target == "x86_64-apple-darwin" {
226
226
// The sanitizers are only built in stage1 or above, so the dylibs will
227
227
// be missing in stage0 and causes panic. See the `std()` function above
228
228
// for reason why the sanitizers are not built in stage0.
229
- copy_apple_sanitizer_dylibs ( & build. native_dir ( target) , "osx" , & libdir) ;
229
+ copy_apple_sanitizer_dylibs ( & build, & build . native_dir ( target) , "osx" , & libdir) ;
230
230
}
231
231
232
232
builder. ensure ( tool:: CleanTools {
@@ -237,15 +237,15 @@ impl Step for StdLink {
237
237
}
238
238
}
239
239
240
- fn copy_apple_sanitizer_dylibs ( native_dir : & Path , platform : & str , into : & Path ) {
240
+ fn copy_apple_sanitizer_dylibs ( build : & Build , native_dir : & Path , platform : & str , into : & Path ) {
241
241
for & sanitizer in & [ "asan" , "tsan" ] {
242
242
let filename = format ! ( "libclang_rt.{}_{}_dynamic.dylib" , sanitizer, platform) ;
243
243
let mut src_path = native_dir. join ( sanitizer) ;
244
244
src_path. push ( "build" ) ;
245
245
src_path. push ( "lib" ) ;
246
246
src_path. push ( "darwin" ) ;
247
247
src_path. push ( & filename) ;
248
- copy ( & src_path, & into. join ( filename) ) ;
248
+ build . copy ( & src_path, & into. join ( filename) ) ;
249
249
}
250
250
}
251
251
@@ -301,15 +301,15 @@ impl Step for StartupObjects {
301
301
. arg ( src_file) ) ;
302
302
}
303
303
304
- copy ( dst_file, & sysroot_dir. join ( file. to_string ( ) + ".o" ) ) ;
304
+ build . copy ( dst_file, & sysroot_dir. join ( file. to_string ( ) + ".o" ) ) ;
305
305
}
306
306
307
307
for obj in [ "crt2.o" , "dllcrt2.o" ] . iter ( ) {
308
308
let src = compiler_file ( build,
309
309
build. cc ( target) ,
310
310
target,
311
311
obj) ;
312
- copy ( & src, & sysroot_dir. join ( obj) ) ;
312
+ build . copy ( & src, & sysroot_dir. join ( obj) ) ;
313
313
}
314
314
}
315
315
}
@@ -420,7 +420,7 @@ impl Step for TestLink {
420
420
& compiler. host,
421
421
target_compiler. host,
422
422
target) ;
423
- add_to_sysroot ( & builder. sysroot_libdir ( target_compiler, target) ,
423
+ add_to_sysroot ( & build , & builder. sysroot_libdir ( target_compiler, target) ,
424
424
& libtest_stamp ( build, compiler, target) ) ;
425
425
builder. ensure ( tool:: CleanTools {
426
426
compiler : target_compiler,
@@ -575,7 +575,7 @@ impl Step for RustcLink {
575
575
& compiler. host,
576
576
target_compiler. host,
577
577
target) ;
578
- add_to_sysroot ( & builder. sysroot_libdir ( target_compiler, target) ,
578
+ add_to_sysroot ( & build , & builder. sysroot_libdir ( target_compiler, target) ,
579
579
& librustc_stamp ( build, compiler, target) ) ;
580
580
builder. ensure ( tool:: CleanTools {
581
581
compiler : target_compiler,
@@ -690,7 +690,7 @@ impl Step for CodegenBackend {
690
690
cargo. arg ( "--features" ) . arg ( features) ,
691
691
& tmp_stamp,
692
692
false ) ;
693
- if cfg ! ( test ) {
693
+ if builder . config . dry_run {
694
694
return ;
695
695
}
696
696
let mut files = files. into_iter ( )
@@ -736,6 +736,10 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
736
736
let dst = builder. sysroot_codegen_backends ( target_compiler) ;
737
737
t ! ( fs:: create_dir_all( & dst) ) ;
738
738
739
+ if builder. config . dry_run {
740
+ return ;
741
+ }
742
+
739
743
for backend in builder. config . rust_codegen_backends . iter ( ) {
740
744
let stamp = codegen_backend_stamp ( build, compiler, target, * backend) ;
741
745
let mut dylib = String :: new ( ) ;
@@ -751,7 +755,7 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
751
755
backend,
752
756
& filename[ dot..] )
753
757
} ;
754
- copy ( & file, & dst. join ( target_filename) ) ;
758
+ build . copy ( & file, & dst. join ( target_filename) ) ;
755
759
}
756
760
}
757
761
@@ -767,7 +771,7 @@ fn copy_lld_to_sysroot(builder: &Builder,
767
771
t ! ( fs:: create_dir_all( & dst) ) ;
768
772
769
773
let exe = exe ( "lld" , & target) ;
770
- copy ( & lld_install_root. join ( "bin" ) . join ( & exe) , & dst. join ( & exe) ) ;
774
+ builder . copy ( & lld_install_root. join ( "bin" ) . join ( & exe) , & dst. join ( & exe) ) ;
771
775
}
772
776
773
777
/// Cargo's output path for the standard library in a given stage, compiled
@@ -936,10 +940,10 @@ impl Step for Assemble {
936
940
let sysroot_libdir = sysroot. join ( libdir ( & * host) ) ;
937
941
t ! ( fs:: create_dir_all( & sysroot_libdir) ) ;
938
942
let src_libdir = builder. sysroot_libdir ( build_compiler, host) ;
939
- for f in t ! ( fs :: read_dir( & src_libdir) ) . map ( |f| t ! ( f ) ) {
943
+ for f in builder . read_dir ( & src_libdir) {
940
944
let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
941
945
if is_dylib ( & filename) {
942
- copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
946
+ builder . copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
943
947
}
944
948
}
945
949
@@ -957,7 +961,7 @@ impl Step for Assemble {
957
961
t ! ( fs:: create_dir_all( & bindir) ) ;
958
962
let compiler = builder. rustc ( target_compiler) ;
959
963
let _ = fs:: remove_file ( & compiler) ;
960
- copy ( & rustc, & compiler) ;
964
+ builder . copy ( & rustc, & compiler) ;
961
965
962
966
target_compiler
963
967
}
@@ -967,10 +971,10 @@ impl Step for Assemble {
967
971
///
968
972
/// For a particular stage this will link the file listed in `stamp` into the
969
973
/// `sysroot_dst` provided.
970
- pub fn add_to_sysroot ( sysroot_dst : & Path , stamp : & Path ) {
974
+ pub fn add_to_sysroot ( build : & Build , sysroot_dst : & Path , stamp : & Path ) {
971
975
t ! ( fs:: create_dir_all( & sysroot_dst) ) ;
972
- for path in read_stamp_file ( stamp) {
973
- copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
976
+ for path in build . read_stamp_file ( stamp) {
977
+ build . copy ( & path, & sysroot_dst. join ( path. file_name ( ) . unwrap ( ) ) ) ;
974
978
}
975
979
}
976
980
@@ -1000,6 +1004,10 @@ fn stderr_isatty() -> bool {
1000
1004
pub fn run_cargo ( build : & Build , cargo : & mut Command , stamp : & Path , is_check : bool )
1001
1005
-> Vec < PathBuf >
1002
1006
{
1007
+ if build. config . dry_run {
1008
+ return Vec :: new ( ) ;
1009
+ }
1010
+
1003
1011
// `target_root_dir` looks like $dir/$target/release
1004
1012
let target_root_dir = stamp. parent ( ) . unwrap ( ) ;
1005
1013
// `target_deps_dir` looks like $dir/$target/release/deps
@@ -1141,6 +1149,9 @@ pub fn stream_cargo(
1141
1149
cargo : & mut Command ,
1142
1150
cb : & mut FnMut ( CargoMessage ) ,
1143
1151
) -> bool {
1152
+ if build. config . dry_run {
1153
+ return true ;
1154
+ }
1144
1155
// Instruct Cargo to give us json messages on stdout, critically leaving
1145
1156
// stderr as piped so we can get those pretty colors.
1146
1157
cargo. arg ( "--message-format" ) . arg ( "json" )
0 commit comments