aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/tools/msvcinfo.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2016-11-07 18:16:51 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2016-11-10 15:13:21 +0000
commit684548e2634ca620ae24b73f7715b70ac90cbb76 (patch)
tree44f4b7d5716cf8b8ac896646eb3aa2b5223b95ca /src/lib/corelib/tools/msvcinfo.cpp
parent171a104ec567d660fd3ac44cfc2031ac748f6d56 (diff)
Refactor MSVC toolchain detection
Have one MSVC object per MSVC installation instead of one MSVC per VS installation with some list members. This cleans up the code quite a bit and prepares for VS 15 support and speed improvements. Change-Id: Idf6759e5b05584532f56be4036c87df310363bd3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/tools/msvcinfo.cpp')
-rw-r--r--src/lib/corelib/tools/msvcinfo.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/lib/corelib/tools/msvcinfo.cpp b/src/lib/corelib/tools/msvcinfo.cpp
index ce3a540a4..e2862a591 100644
--- a/src/lib/corelib/tools/msvcinfo.cpp
+++ b/src/lib/corelib/tools/msvcinfo.cpp
@@ -167,8 +167,8 @@ static QVariantMap getMsvcDefines(const QString &hostCompilerFilePath,
// The host compiler is the x86 compiler, which will execute on any edition of Windows
// for which host compilers have been released so far (x86, x86_64, ia64)
MSVC msvc2(hostCompilerFilePath);
- VsEnvironmentDetector envdetector(&msvc2);
- if (!envdetector.start())
+ VsEnvironmentDetector envdetector;
+ if (!envdetector.start(&msvc2))
throw ErrorInfo(QStringLiteral("Detecting the MSVC build environment failed: ")
+ envdetector.errorString());
runProcess(hostCompilerFilePath, QStringList()
@@ -177,7 +177,7 @@ static QVariantMap getMsvcDefines(const QString &hostCompilerFilePath,
<< (QStringLiteral("/Fo") + qbsClFrontendObj)
<< nativeDummyFilePath
<< QStringLiteral("/link")
- << (QStringLiteral("/out:") + qbsClFrontend), msvc2.environments[QString()]);
+ << (QStringLiteral("/out:") + qbsClFrontend), msvc2.environment);
QStringList out = QString::fromLocal8Bit(runProcess(compilerFilePath, QStringList()
<< QStringLiteral("/nologo")
@@ -209,11 +209,22 @@ static QVariantMap getMsvcDefines(const QString &hostCompilerFilePath,
return map;
}
-QVariantMap MSVC::compilerDefines(const QString &compilerFilePath) const
+QString MSVC::binPathForArchitecture(const QString &arch) const
{
- // Should never happen
- if (architectures.size() != 1)
- throw ErrorInfo(mkStr("Unexpected number of architectures"));
+ QString archSubDir;
+ if (arch != QStringLiteral("x86"))
+ archSubDir = arch;
+ return QDir::cleanPath(vcInstallPath + QLatin1Char('/') + pathPrefix + QLatin1Char('/')
+ + archSubDir);
+}
- return getMsvcDefines(clPath(), compilerFilePath, environments[architectures.first()]);
+QString MSVC::clPathForArchitecture(const QString &arch) const
+{
+ return binPathForArchitecture(arch) + QLatin1String("/cl.exe");
+}
+
+QVariantMap MSVC::compilerDefines(const QString &compilerFilePath) const
+{
+ return getMsvcDefines(clPathForArchitecture(QStringLiteral("x86")), compilerFilePath,
+ environment);
}