5
5
//! parent directory, and otherwise documentation can be found throughout the `build`
6
6
//! directory in each respective module.
7
7
8
- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
9
8
use std:: io:: Write ;
10
- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
11
9
use std:: process;
12
10
use std:: {
13
11
env, fs,
@@ -22,39 +20,29 @@ fn main() {
22
20
let args = env:: args ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
23
21
let config = Config :: parse ( & args) ;
24
22
25
- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
26
- let mut build_lock;
27
- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
28
- let _build_lock_guard;
29
- #[ cfg( all( any( unix, windows) , not( target_os = "solaris" ) ) ) ]
30
23
// Display PID of process holding the lock
31
24
// PID will be stored in a lock file
32
- {
33
- let path = config. out . join ( "lock" ) ;
34
- let pid = match fs:: read_to_string ( & path) {
35
- Ok ( contents) => contents,
36
- Err ( _) => String :: new ( ) ,
37
- } ;
38
-
39
- build_lock =
40
- fd_lock:: RwLock :: new ( t ! ( fs:: OpenOptions :: new( ) . write( true ) . create( true ) . open( & path) ) ) ;
41
- _build_lock_guard = match build_lock. try_write ( ) {
42
- Ok ( mut lock) => {
43
- t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
44
- lock
45
- }
46
- err => {
47
- drop ( err) ;
48
- println ! ( "WARNING: build directory locked by process {pid}, waiting for lock" ) ;
49
- let mut lock = t ! ( build_lock. write( ) ) ;
50
- t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
51
- lock
52
- }
53
- } ;
54
- }
25
+ let lock_path = config. out . join ( "lock" ) ;
26
+ let pid = match fs:: read_to_string ( & lock_path) {
27
+ Ok ( contents) => contents,
28
+ Err ( _) => String :: new ( ) ,
29
+ } ;
55
30
56
- #[ cfg( any( not( any( unix, windows) ) , target_os = "solaris" ) ) ]
57
- println ! ( "WARNING: file locking not supported for target, not locking build directory" ) ;
31
+ let mut build_lock =
32
+ fd_lock:: RwLock :: new ( t ! ( fs:: OpenOptions :: new( ) . write( true ) . create( true ) . open( & lock_path) ) ) ;
33
+ let _build_lock_guard = match build_lock. try_write ( ) {
34
+ Ok ( mut lock) => {
35
+ t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
36
+ lock
37
+ }
38
+ err => {
39
+ drop ( err) ;
40
+ println ! ( "WARNING: build directory locked by process {pid}, waiting for lock" ) ;
41
+ let mut lock = t ! ( build_lock. write( ) ) ;
42
+ t ! ( lock. write( & process:: id( ) . to_string( ) . as_ref( ) ) ) ;
43
+ lock
44
+ }
45
+ } ;
58
46
59
47
// check_version warnings are not printed during setup
60
48
let changelog_suggestion =
0 commit comments