Move ninja requirements to a dynamic check, when actually building
It isn't practical to determine whether we'll build LLVM very early in the pipeline, so move the ninja checking to a dynamic check.
This commit is contained in:
@@ -650,7 +650,7 @@ impl Build {
|
||||
}
|
||||
} else {
|
||||
let base = self.llvm_out(self.config.build).join("build");
|
||||
let base = if !self.config.ninja && self.config.build.contains("msvc") {
|
||||
let base = if !self.ninja() && self.config.build.contains("msvc") {
|
||||
if self.config.llvm_optimize {
|
||||
if self.config.llvm_release_debuginfo {
|
||||
base.join("RelWithDebInfo")
|
||||
@@ -1328,6 +1328,43 @@ impl Build {
|
||||
}
|
||||
fs::remove_file(f).unwrap_or_else(|_| panic!("failed to remove {:?}", f));
|
||||
}
|
||||
|
||||
/// Returns if config.ninja is enabled, and checks for ninja existence,
|
||||
/// exiting with a nicer error message if not.
|
||||
fn ninja(&self) -> bool {
|
||||
let mut cmd_finder = crate::sanity::Finder::new();
|
||||
|
||||
if self.config.ninja_in_file {
|
||||
// Some Linux distros rename `ninja` to `ninja-build`.
|
||||
// CMake can work with either binary name.
|
||||
if cmd_finder.maybe_have("ninja-build").is_none()
|
||||
&& cmd_finder.maybe_have("ninja").is_none()
|
||||
{
|
||||
eprintln!(
|
||||
"
|
||||
Couldn't find required command: ninja
|
||||
You should install ninja, or set ninja=false in config.toml
|
||||
"
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// If ninja isn't enabled but we're building for MSVC then we try
|
||||
// doubly hard to enable it. It was realized in #43767 that the msbuild
|
||||
// CMake generator for MSVC doesn't respect configuration options like
|
||||
// disabling LLVM assertions, which can often be quite important!
|
||||
//
|
||||
// In these cases we automatically enable Ninja if we find it in the
|
||||
// environment.
|
||||
if !self.config.ninja_in_file && self.config.build.contains("msvc") {
|
||||
if cmd_finder.maybe_have("ninja").is_some() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
self.config.ninja_in_file
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user