aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Weickelt <richard@weickelt.de>2019-12-15 19:08:11 +0100
committerRichard Weickelt <richard@weickelt.de>2019-12-15 19:08:56 +0100
commit72be773e12177620a4f49e25da06d85d58642f68 (patch)
treeba6be891231fbb50727cd533770511272b21e5d9 /src
parentf7117d080ddce4b5f692e3a60ceddc9fe1761888 (diff)
parenta499ac2a80967da83cd39d66d64f88c6b3d57205 (diff)
Merge branch '1.15' into master
Diffstat (limited to 'src')
-rw-r--r--src/app/qbs-setup-toolchains/clangclprobe.cpp29
-rw-r--r--src/lib/corelib/buildgraph/rulesapplicator.cpp9
-rw-r--r--src/lib/corelib/buildgraph/rulesapplicator.h4
3 files changed, 30 insertions, 12 deletions
diff --git a/src/app/qbs-setup-toolchains/clangclprobe.cpp b/src/app/qbs-setup-toolchains/clangclprobe.cpp
index 4cb38b774..07e45d8d4 100644
--- a/src/app/qbs-setup-toolchains/clangclprobe.cpp
+++ b/src/app/qbs-setup-toolchains/clangclprobe.cpp
@@ -107,9 +107,9 @@ std::vector<MSVCInstallInfo> compatibleMsvcs()
return msvcs;
}
-QString findCompatibleVcsarsallBat()
+QString findCompatibleVcsarsallBat(const std::vector<MSVCInstallInfo> &msvcs)
{
- for (const auto &msvc: compatibleMsvcs()) {
+ for (const auto &msvc: msvcs) {
const auto vcvarsallPath = msvc.findVcvarsallBat();
if (!vcvarsallPath.isEmpty())
return vcvarsallPath;
@@ -126,8 +126,12 @@ QString wow6432Key()
#endif
}
-QString findClangCl()
+// Function can modify passed list in case it has found clang in one of the VS installation -
+// in that case, there's no point in looking for vcvarsall.bat among all installed VSs, we just
+// use .bat file corresponding to that particular VS installation
+QString findClangCl(std::vector<MSVCInstallInfo> *msvcs)
{
+ Q_ASSERT(msvcs);
const auto compilerName = HostOsInfo::appendExecutableSuffix(QStringLiteral("clang-cl"));
const auto compilerFromPath = findExecutable(compilerName);
if (!compilerFromPath.isEmpty())
@@ -154,6 +158,17 @@ QString findClangCl()
if (QFileInfo(compilerPath).exists())
return compilerPath;
}
+
+ // If we didn't find custom LLVM installation, try to find if it's installed with Visual Studio
+ for (const auto &msvc : *msvcs) {
+ const auto compilerPath = QStringLiteral("%1/VC/Tools/Llvm/bin/%2")
+ .arg(msvc.installDir, compilerName);
+ if (QFileInfo(compilerPath).exists()) {
+ *msvcs = {msvc}; // reduce list to one installation
+ return compilerPath;
+ }
+ }
+
return {};
}
@@ -163,7 +178,7 @@ void createClangClProfile(const QFileInfo &compiler, Settings *settings,
const QString &profileName)
{
const auto compilerName = QStringLiteral("clang-cl");
- const auto vcvarsallPath = findCompatibleVcsarsallBat();
+ const auto vcvarsallPath = findCompatibleVcsarsallBat(compatibleMsvcs());
if (vcvarsallPath.isEmpty()) {
qbsWarning()
<< Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.")
@@ -182,15 +197,17 @@ void createClangClProfile(const QFileInfo &compiler, Settings *settings,
*/
void clangClProbe(Settings *settings, std::vector<Profile> &profiles)
{
+ auto msvcs = compatibleMsvcs();
+
const auto compilerName = QStringLiteral("clang-cl");
qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName);
- const QString compilerFilePath = findClangCl();
+ const QString compilerFilePath = findClangCl(&msvcs);
if (compilerFilePath.isEmpty()) {
qbsInfo() << Tr::tr("%1 was not found.").arg(compilerName);
return;
}
const QFileInfo compiler(compilerFilePath);
- const auto vcvarsallPath = findCompatibleVcsarsallBat();
+ const auto vcvarsallPath = findCompatibleVcsarsallBat(msvcs);
if (vcvarsallPath.isEmpty()) {
qbsWarning()
<< Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.")
diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp
index 437e3f4da..5d1144636 100644
--- a/src/lib/corelib/buildgraph/rulesapplicator.cpp
+++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp
@@ -79,12 +79,13 @@ namespace Internal {
RulesApplicator::RulesApplicator(
ResolvedProductPtr product,
- std::unordered_map<QString, const ResolvedProduct *> productsByName,
- std::unordered_map<QString, const ResolvedProject *> projectsByName,
+ const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
+ const std::unordered_map<QString, const ResolvedProject *> &projectsByName,
Logger logger)
: m_product(std::move(product))
- , m_productsByName(std::move(productsByName))
- , m_projectsByName(std::move(projectsByName))
+ // m_productsByName and m_projectsByName are references, cannot move-construct
+ , m_productsByName(productsByName)
+ , m_projectsByName(projectsByName)
, m_mocScanner(nullptr)
, m_logger(std::move(logger))
{
diff --git a/src/lib/corelib/buildgraph/rulesapplicator.h b/src/lib/corelib/buildgraph/rulesapplicator.h
index 1160f3d09..da7815014 100644
--- a/src/lib/corelib/buildgraph/rulesapplicator.h
+++ b/src/lib/corelib/buildgraph/rulesapplicator.h
@@ -63,8 +63,8 @@ class RulesApplicator
{
public:
RulesApplicator(ResolvedProductPtr product,
- std::unordered_map<QString, const ResolvedProduct *> productsByName,
- std::unordered_map<QString, const ResolvedProject *> projectsByName,
+ const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
+ const std::unordered_map<QString, const ResolvedProject *> &projectsByName,
Logger logger);
~RulesApplicator();