66//! directory in each respective module.
77
88use std:: io:: Write ;
9- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
109use std:: process;
1110use std:: {
1211 env,
@@ -22,43 +21,35 @@ fn main() {
2221 let args = env:: args ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
2322 let config = Config :: parse ( & args) ;
2423
25- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
2624 let mut build_lock;
27- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
2825 let _build_lock_guard;
2926
3027 if !config. bypass_bootstrap_lock {
3128 // Display PID of process holding the lock
3229 // PID will be stored in a lock file
33- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
34- {
35- let path = config. out . join ( "lock" ) ;
36- let pid = match fs:: read_to_string ( & path) {
37- Ok ( contents) => contents,
38- Err ( _) => String :: new ( ) ,
39- } ;
40-
41- build_lock = fd_lock:: RwLock :: new ( t ! ( fs:: OpenOptions :: new( )
42- . write( true )
43- . create( true )
44- . open( & path) ) ) ;
45- _build_lock_guard = match build_lock. try_write ( ) {
46- Ok ( mut lock) => {
47- t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
48- lock
49- }
50- err => {
51- drop ( err) ;
52- println ! ( "WARNING: build directory locked by process {pid}, waiting for lock" ) ;
53- let mut lock = t ! ( build_lock. write( ) ) ;
54- t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
55- lock
56- }
57- } ;
58- }
59-
60- #[ cfg( any( not( any( unix, windows) ) , target_os = "solaris" ) ) ]
61- println ! ( "WARNING: file locking not supported for target, not locking build directory" ) ;
30+ let lock_path = config. out . join ( "lock" ) ;
31+ let pid = match fs:: read_to_string ( & lock_path) {
32+ Ok ( contents) => contents,
33+ Err ( _) => String :: new ( ) ,
34+ } ;
35+
36+ build_lock = fd_lock:: RwLock :: new ( t ! ( fs:: OpenOptions :: new( )
37+ . write( true )
38+ . create( true )
39+ . open( & lock_path) ) ) ;
40+ _build_lock_guard = match build_lock. try_write ( ) {
41+ Ok ( mut lock) => {
42+ t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
43+ lock
44+ }
45+ err => {
46+ drop ( err) ;
47+ println ! ( "WARNING: build directory locked by process {pid}, waiting for lock" ) ;
48+ let mut lock = t ! ( build_lock. write( ) ) ;
49+ t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
50+ lock
51+ }
52+ } ;
6253 }
6354
6455 // check_version warnings are not printed during setup
0 commit comments