Commit 2d2db831 authored by Thomas Epting's avatar Thomas Epting

MSVC: Ensure the correct MSVC installation folder is detected

With this change, tools like Bullseye Coverage that wrap cl.exe are
disregarded. Only true MSVC installation folders are considered now,
which allows using Creator+Qbs with such tools again.

Task-number: QBS-1000
Change-Id: Ifb49b3c032359aa4ba1bc702de0dc3d30d3b6075
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <>
parent 3b8087a8
......@@ -273,7 +273,8 @@ QStringList Environment::appendExeExtensions(const QString &executable) const
FileName Environment::searchInPath(const QString &executable,
const QStringList &additionalDirs) const
const QStringList &additionalDirs,
bool (*func)(const QString &name)) const
if (executable.isEmpty())
return FileName();
......@@ -296,7 +297,7 @@ FileName Environment::searchInPath(const QString &executable,
FileName tmp = searchInDirectory(execs, dir);
if (!tmp.isEmpty())
if (!tmp.isEmpty() && (!func || func(tmp.toString())))
return tmp;
......@@ -308,7 +309,7 @@ FileName Environment::searchInPath(const QString &executable,
FileName tmp = searchInDirectory(execs, QDir::fromNativeSeparators(p));
if (!tmp.isEmpty())
if (!tmp.isEmpty() && (!func || func(tmp.toString())))
return tmp;
return FileName();
......@@ -100,7 +100,9 @@ public:
Environment::const_iterator constFind(const QString &name) const;
FileName searchInPath(const QString &executable,
const QStringList &additionalDirs = QStringList()) const;
const QStringList &additionalDirs = QStringList(),
bool (*func)(const QString &name) = nullptr) const;
QStringList path() const;
QStringList appendExeExtensions(const QString &executable) const;
......@@ -201,7 +201,16 @@ Utils::FileName AbstractMsvcToolChain::compilerCommand() const
Utils::Environment env = Utils::Environment::systemEnvironment();
return env.searchInPath(QLatin1String("cl.exe"));
Utils::FileName clexe = env.searchInPath(QLatin1String("cl.exe"), QStringList(), [](const QString &name) {
QDir dir(QDir::cleanPath(QFileInfo(name).absolutePath() + QStringLiteral("/..")));
do {
if (QFile::exists(dir.absoluteFilePath(QStringLiteral("vcvarsall.bat"))))
return true;
} while (dir.cdUp() && !dir.isRoot());
return false;
return clexe;
IOutputParser *AbstractMsvcToolChain::outputParser() const
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment