Auto merge of #109811 - jyn514:symlink-fixes, r=Mark-Simulacrum
Replace any existing `build/host` symlink This has two advantages: 1. If `build.build` changes between runs, the symlink is no longer silently wrong. 2. If the entire build directory is moved, the symlink is no longer broken because it points to the wrong absolute path.
This commit is contained in:
commit
3a8a131e95
@ -21,7 +21,6 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::ErrorKind;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::str;
|
use std::str;
|
||||||
@ -505,16 +504,18 @@ impl Build {
|
|||||||
let build_triple = build.out.join(&build.build.triple);
|
let build_triple = build.out.join(&build.build.triple);
|
||||||
t!(fs::create_dir_all(&build_triple));
|
t!(fs::create_dir_all(&build_triple));
|
||||||
let host = build.out.join("host");
|
let host = build.out.join("host");
|
||||||
if let Err(e) = symlink_dir(&build.config, &build_triple, &host) {
|
if host.is_symlink() {
|
||||||
if e.kind() != ErrorKind::AlreadyExists {
|
// Left over from a previous build; overwrite it.
|
||||||
panic!(
|
// This matters if `build.build` has changed between invocations.
|
||||||
"symlink_dir({} => {}) failed with {}",
|
#[cfg(windows)]
|
||||||
host.display(),
|
t!(fs::remove_dir(&host));
|
||||||
build_triple.display(),
|
#[cfg(not(windows))]
|
||||||
e
|
t!(fs::remove_file(&host));
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
t!(
|
||||||
|
symlink_dir(&build.config, &build_triple, &host),
|
||||||
|
format!("symlink_dir({} => {}) failed", host.display(), build_triple.display())
|
||||||
|
);
|
||||||
|
|
||||||
build
|
build
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user