allow bypassing the build directory lock · rust-lang/rust@6860654 (original) (raw)
`@@ -23,35 +23,40 @@ fn main() {
`
23
23
`let mut build_lock;
`
24
24
`#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
`
25
25
`let _build_lock_guard;
`
26
``
`-
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
`
27
``
`-
// Display PID of process holding the lock
`
28
``
`-
// PID will be stored in a lock file
`
29
``
`-
{
`
30
``
`-
let path = config.out.join("lock");
`
31
``
`-
let pid = match fs::read_to_string(&path) {
`
32
``
`-
Ok(contents) => contents,
`
33
``
`-
Err(_) => String::new(),
`
34
``
`-
};
`
35
``
-
36
``
`-
build_lock =
`
37
``
`-
fd_lock::RwLock::new(t!(fs::OpenOptions::new().write(true).create(true).open(&path)));
`
38
``
`-
_build_lock_guard = match build_lock.try_write() {
`
39
``
`-
Ok(mut lock) => {
`
40
``
`-
t!(lock.write(&process::id().to_string().as_ref()));
`
41
``
`-
lock
`
42
``
`-
}
`
43
``
`-
err => {
`
44
``
`-
drop(err);
`
45
``
`-
println!("WARNING: build directory locked by process {pid}, waiting for lock");
`
46
``
`-
let mut lock = t!(build_lock.write());
`
47
``
`-
t!(lock.write(&process::id().to_string().as_ref()));
`
48
``
`-
lock
`
49
``
`-
}
`
50
``
`-
};
`
51
``
`-
}
`
52
26
``
53
``
`-
#[cfg(any(not(any(unix, windows)), target_os = "solaris"))]
`
54
``
`-
println!("WARNING: file locking not supported for target, not locking build directory");
`
``
27
`+
if !config.bypass_bootstrap_lock {
`
``
28
`+
// Display PID of process holding the lock
`
``
29
`+
// PID will be stored in a lock file
`
``
30
`+
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
`
``
31
`+
{
`
``
32
`+
let path = config.out.join("lock");
`
``
33
`+
let pid = match fs::read_to_string(&path) {
`
``
34
`+
Ok(contents) => contents,
`
``
35
`+
Err(_) => String::new(),
`
``
36
`+
};
`
``
37
+
``
38
`+
build_lock = fd_lock::RwLock::new(t!(fs::OpenOptions::new()
`
``
39
`+
.write(true)
`
``
40
`+
.create(true)
`
``
41
`+
.open(&path)));
`
``
42
`+
_build_lock_guard = match build_lock.try_write() {
`
``
43
`+
Ok(mut lock) => {
`
``
44
`+
t!(lock.write(&process::id().to_string().as_ref()));
`
``
45
`+
lock
`
``
46
`+
}
`
``
47
`+
err => {
`
``
48
`+
drop(err);
`
``
49
`+
println!("WARNING: build directory locked by process {pid}, waiting for lock");
`
``
50
`+
let mut lock = t!(build_lock.write());
`
``
51
`+
t!(lock.write(&process::id().to_string().as_ref()));
`
``
52
`+
lock
`
``
53
`+
}
`
``
54
`+
};
`
``
55
`+
}
`
``
56
+
``
57
`+
#[cfg(any(not(any(unix, windows)), target_os = "solaris"))]
`
``
58
`+
println!("WARNING: file locking not supported for target, not locking build directory");
`
``
59
`+
}
`
55
60
``
56
61
`// check_version warnings are not printed during setup
`
57
62
`let changelog_suggestion =
`