@@ -6,7 +6,7 @@ use collector::{command_output, robocopy};
6
6
use database:: { PatchName , QueryLabel } ;
7
7
use futures:: stream:: FuturesUnordered ;
8
8
use futures:: stream:: StreamExt ;
9
- use std:: cmp;
9
+ use std:: { cmp, ffi :: OsStr , path :: Component } ;
10
10
use std:: collections:: HashMap ;
11
11
use std:: env;
12
12
use std:: fmt;
@@ -58,29 +58,48 @@ fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> anyhow::Result<()>
58
58
Ok ( ( ) )
59
59
}
60
60
61
- fn touch ( root : & Path , path : & Path ) -> anyhow:: Result < ( ) > {
62
- let joined = root . join ( path) ;
61
+ fn touch ( path : & Path ) -> anyhow:: Result < ( ) > {
62
+ log :: info! ( "touching file {:?}" , path) ;
63
63
64
- log:: info!( "touching file {:?}" , joined) ;
65
-
66
- filetime:: set_file_mtime ( & joined, filetime:: FileTime :: now ( ) ) . with_context ( || format ! ( "touching file {:?}" , joined) ) ?;
64
+ filetime:: set_file_mtime ( path, filetime:: FileTime :: now ( ) ) . with_context ( || format ! ( "touching file {:?}" , path) ) ?;
67
65
68
66
Ok ( ( ) )
69
67
}
70
68
71
69
fn touch_all ( path : & Path ) -> anyhow:: Result < ( ) > {
72
- let mut cmd = Command :: new ( "bash" ) ;
73
- // Don't touch files in `target/`, since they're likely generated by build scripts and might be from a dependency.
74
- // Don't touch build scripts, which confuses the wrapped rustc.
75
- cmd. current_dir ( path)
76
- . args ( & [ "-c" , "find . -path ./target -prune -false -o -name '*.rs' | grep -v '^./build.rs$' | xargs touch" ] ) ;
77
- command_output ( & mut cmd) . with_context ( || format ! ( "touching all .rs in {:?}" , path) ) ?;
78
- // We also delete the cmake caches to avoid errors when moving directories around.
79
- // This might be a bit slower but at least things build
80
- let mut cmd = Command :: new ( "bash" ) ;
81
- cmd. current_dir ( path)
82
- . args ( & [ "-c" , "find . -name 'CMakeCache.txt' -delete" ] ) ;
83
- command_output ( & mut cmd) . with_context ( || format ! ( "deleting cmake caches in {:?}" , path) ) ?;
70
+ fn is_valid ( path : & Path ) -> bool {
71
+ let target_dir = Component :: Normal ( OsStr :: new ( "target" ) ) ;
72
+
73
+ // Don't touch files in `target/`, since they're likely generated by build scripts and might be from a dependency.
74
+ if path. components ( ) . any ( |component| component == target_dir) {
75
+ return false ;
76
+ }
77
+
78
+ if let Some ( extn) = path. extension ( ) {
79
+ if extn. to_str ( ) == Some ( "rs" ) {
80
+ // Don't touch build scripts, which confuses the wrapped rustc.
81
+ return path. file_name ( ) != Some ( OsStr :: new ( "build.rs" ) ) ;
82
+ }
83
+ }
84
+
85
+ false
86
+ }
87
+
88
+ for entry in walkdir:: WalkDir :: new ( path) {
89
+ let entry = entry?;
90
+ let path = entry. path ( ) ;
91
+
92
+ // We also delete the cmake caches to avoid errors when moving directories around.
93
+ // This might be a bit slower but at least things build
94
+ if path. file_name ( ) == Some ( OsStr :: new ( "CMakeCache.txt" ) ) {
95
+ fs:: remove_file ( path) . with_context ( || format ! ( "deleting cmake caches in {:?}" , path) ) ?;
96
+ }
97
+
98
+ if is_valid ( path) {
99
+ touch ( path) ?;
100
+ }
101
+ }
102
+
84
103
Ok ( ( ) )
85
104
}
86
105
@@ -397,7 +416,7 @@ impl<'a> CargoProcess<'a> {
397
416
// in-tree (e.g., in the case of the servo crates there are a lot of
398
417
// other components).
399
418
if let Some ( file) = & self . touch_file {
400
- touch ( & self . cwd , Path :: new ( & file) ) ?;
419
+ touch ( & self . cwd . join ( Path :: new ( & file) ) ) ?;
401
420
} else {
402
421
touch_all (
403
422
& self . cwd . join (
0 commit comments