Skip to content

Commit 44a7ec1

Browse files
committed
apply build lock unconditionally
as fd-lock@4.0.2 brings solaris support, we no longer need to conditionally set the build lock. Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent f292217 commit 44a7ec1

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

src/bootstrap/src/bin/main.rs

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
//! parent directory, and otherwise documentation can be found throughout the `build`
66
//! directory in each respective module.
77
8-
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
98
use std::io::Write;
10-
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
119
use std::process;
1210
use std::{
1311
env, fs,
@@ -22,39 +20,29 @@ fn main() {
2220
let args = env::args().skip(1).collect::<Vec<_>>();
2321
let config = Config::parse(&args);
2422

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")))]
3023
// Display PID of process holding the lock
3124
// 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+
};
5530

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+
};
5846

5947
// check_version warnings are not printed during setup
6048
let changelog_suggestion =

0 commit comments

Comments
 (0)