@@ -30,7 +30,7 @@ use build_helper::{output, mtime, up_to_date};
3030use filetime:: FileTime ;
3131use serde_json;
3232
33- use util:: { exe, libdir, is_dylib, copy , read_stamp_file , CiEnv } ;
33+ use util:: { exe, libdir, is_dylib, CiEnv } ;
3434use { Build , Compiler , Mode } ;
3535use native;
3636use tool;
@@ -130,7 +130,7 @@ fn copy_musl_third_party_objects(build: &Build,
130130 target : Interned < String > ,
131131 into : & Path ) {
132132 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) ) ;
134134 }
135135}
136136
@@ -220,13 +220,13 @@ impl Step for StdLink {
220220 target_compiler. host,
221221 target) ;
222222 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) ) ;
224224
225225 if build. config . sanitizers && compiler. stage != 0 && target == "x86_64-apple-darwin" {
226226 // The sanitizers are only built in stage1 or above, so the dylibs will
227227 // be missing in stage0 and causes panic. See the `std()` function above
228228 // 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) ;
230230 }
231231
232232 builder. ensure ( tool:: CleanTools {
@@ -237,15 +237,15 @@ impl Step for StdLink {
237237 }
238238}
239239
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 ) {
241241 for & sanitizer in & [ "asan" , "tsan" ] {
242242 let filename = format ! ( "libclang_rt.{}_{}_dynamic.dylib" , sanitizer, platform) ;
243243 let mut src_path = native_dir. join ( sanitizer) ;
244244 src_path. push ( "build" ) ;
245245 src_path. push ( "lib" ) ;
246246 src_path. push ( "darwin" ) ;
247247 src_path. push ( & filename) ;
248- copy ( & src_path, & into. join ( filename) ) ;
248+ build . copy ( & src_path, & into. join ( filename) ) ;
249249 }
250250}
251251
@@ -301,15 +301,15 @@ impl Step for StartupObjects {
301301 . arg ( src_file) ) ;
302302 }
303303
304- copy ( dst_file, & sysroot_dir. join ( file. to_string ( ) + ".o" ) ) ;
304+ build . copy ( dst_file, & sysroot_dir. join ( file. to_string ( ) + ".o" ) ) ;
305305 }
306306
307307 for obj in [ "crt2.o" , "dllcrt2.o" ] . iter ( ) {
308308 let src = compiler_file ( build,
309309 build. cc ( target) ,
310310 target,
311311 obj) ;
312- copy ( & src, & sysroot_dir. join ( obj) ) ;
312+ build . copy ( & src, & sysroot_dir. join ( obj) ) ;
313313 }
314314 }
315315}
@@ -420,7 +420,7 @@ impl Step for TestLink {
420420 & compiler. host,
421421 target_compiler. host,
422422 target) ;
423- add_to_sysroot ( & builder. sysroot_libdir ( target_compiler, target) ,
423+ add_to_sysroot ( & build , & builder. sysroot_libdir ( target_compiler, target) ,
424424 & libtest_stamp ( build, compiler, target) ) ;
425425 builder. ensure ( tool:: CleanTools {
426426 compiler : target_compiler,
@@ -575,7 +575,7 @@ impl Step for RustcLink {
575575 & compiler. host,
576576 target_compiler. host,
577577 target) ;
578- add_to_sysroot ( & builder. sysroot_libdir ( target_compiler, target) ,
578+ add_to_sysroot ( & build , & builder. sysroot_libdir ( target_compiler, target) ,
579579 & librustc_stamp ( build, compiler, target) ) ;
580580 builder. ensure ( tool:: CleanTools {
581581 compiler : target_compiler,
@@ -690,7 +690,7 @@ impl Step for CodegenBackend {
690690 cargo. arg ( "--features" ) . arg ( features) ,
691691 & tmp_stamp,
692692 false ) ;
693- if cfg ! ( test ) {
693+ if builder . config . dry_run {
694694 return ;
695695 }
696696 let mut files = files. into_iter ( )
@@ -736,6 +736,10 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
736736 let dst = builder. sysroot_codegen_backends ( target_compiler) ;
737737 t ! ( fs:: create_dir_all( & dst) ) ;
738738
739+ if builder. config . dry_run {
740+ return ;
741+ }
742+
739743 for backend in builder. config . rust_codegen_backends . iter ( ) {
740744 let stamp = codegen_backend_stamp ( build, compiler, target, * backend) ;
741745 let mut dylib = String :: new ( ) ;
@@ -751,7 +755,7 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
751755 backend,
752756 & filename[ dot..] )
753757 } ;
754- copy ( & file, & dst. join ( target_filename) ) ;
758+ build . copy ( & file, & dst. join ( target_filename) ) ;
755759 }
756760}
757761
@@ -767,7 +771,7 @@ fn copy_lld_to_sysroot(builder: &Builder,
767771 t ! ( fs:: create_dir_all( & dst) ) ;
768772
769773 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) ) ;
771775}
772776
773777/// Cargo's output path for the standard library in a given stage, compiled
@@ -936,10 +940,10 @@ impl Step for Assemble {
936940 let sysroot_libdir = sysroot. join ( libdir ( & * host) ) ;
937941 t ! ( fs:: create_dir_all( & sysroot_libdir) ) ;
938942 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) {
940944 let filename = f. file_name ( ) . into_string ( ) . unwrap ( ) ;
941945 if is_dylib ( & filename) {
942- copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
946+ builder . copy ( & f. path ( ) , & sysroot_libdir. join ( & filename) ) ;
943947 }
944948 }
945949
@@ -957,7 +961,7 @@ impl Step for Assemble {
957961 t ! ( fs:: create_dir_all( & bindir) ) ;
958962 let compiler = builder. rustc ( target_compiler) ;
959963 let _ = fs:: remove_file ( & compiler) ;
960- copy ( & rustc, & compiler) ;
964+ builder . copy ( & rustc, & compiler) ;
961965
962966 target_compiler
963967 }
@@ -967,10 +971,10 @@ impl Step for Assemble {
967971///
968972/// For a particular stage this will link the file listed in `stamp` into the
969973/// `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 ) {
971975 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 ( ) ) ) ;
974978 }
975979}
976980
@@ -1000,6 +1004,10 @@ fn stderr_isatty() -> bool {
10001004pub fn run_cargo ( build : & Build , cargo : & mut Command , stamp : & Path , is_check : bool )
10011005 -> Vec < PathBuf >
10021006{
1007+ if build. config . dry_run {
1008+ return Vec :: new ( ) ;
1009+ }
1010+
10031011 // `target_root_dir` looks like $dir/$target/release
10041012 let target_root_dir = stamp. parent ( ) . unwrap ( ) ;
10051013 // `target_deps_dir` looks like $dir/$target/release/deps
@@ -1141,6 +1149,9 @@ pub fn stream_cargo(
11411149 cargo : & mut Command ,
11421150 cb : & mut FnMut ( CargoMessage ) ,
11431151) -> bool {
1152+ if build. config . dry_run {
1153+ return true ;
1154+ }
11441155 // Instruct Cargo to give us json messages on stdout, critically leaving
11451156 // stderr as piped so we can get those pretty colors.
11461157 cargo. arg ( "--message-format" ) . arg ( "json" )
0 commit comments