aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-10 12:13:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-10 12:13:05 +0200
commitcc57f3a59ed7e19d663ed77654de2a5e16e16875 (patch)
tree3f8502b8283fd21df4573de5b9b5b87513031665
parentc36fa865ca63645aa0ee7962a60354da3911f532 (diff)
Add %VCINSTALLDIR%\Tools\Llvm\bin as fallback search directory for Clang
-rw-r--r--libbuild2/cc/guess.cxx34
1 files changed, 28 insertions, 6 deletions
diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx
index b5b791c..40fb14f 100644
--- a/libbuild2/cc/guess.cxx
+++ b/libbuild2/cc/guess.cxx
@@ -351,6 +351,9 @@ namespace build2
assert (!xi || xi->type == pre);
+ using type = compiler_type;
+ const type invalid = invalid_compiler_type;
+
guess_result r;
process_path xp;
@@ -361,18 +364,37 @@ namespace build2
dr << info << "use config." << xm << " to override";
});
+ // If we are running in the Visual Studio command prompt, add the
+ // potentially bundled Clang directory as a fallback (for some reason
+ // the Visual Studio prompts don't add it to PATH themselves).
+ //
+ dir_path fallback;
+
+#ifdef _WIN32
+ if (pre == type::clang)
+ {
+ if (optional<string> v = getenv ("VCINSTALLDIR"))
+ {
+ try
+ {
+ fallback = ((dir_path (move (*v)) /= "Tools") /= "Llvm") /= "bin";
+ }
+ catch (const invalid_path&)
+ {
+ // Ignore it.
+ }
+ }
+ }
+#endif
// Only search in PATH (specifically, omitting the current
// executable's directory on Windows).
//
xp = run_search (xc,
- false /* init */, // Note: result is cached.
- dir_path () /* fallback */,
- true /* path_only */);
+ false /* init (note: result is cached) */,
+ fallback,
+ true /* path_only */);
}
- using type = compiler_type;
- const type invalid = invalid_compiler_type;
-
// Start with -v. This will cover gcc and clang.
//
// While icc also writes what may seem like something we can use to