diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-31 09:26:35 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-31 09:26:35 +0100 |
commit | 8e20daae9fee5f3b999daffce0d7156015ee974b (patch) | |
tree | 7adcc397fd378cbb97c186ddb78c226b61906583 /tools | |
parent | 5545e5aa6e265469d278e1fb576a737535784422 (diff) | |
parent | 694702e09d9b17d91db282784f009178cfb1059b (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
Change-Id: Ia6ab42a6daadbf8abc085c971545904d49ea4b56
Diffstat (limited to 'tools')
-rw-r--r-- | tools/configure/environment.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index bf82f14159..8f18f3c489 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -36,6 +36,7 @@ #include <qfile.h> #include <qfileinfo.h> #include <qstandardpaths.h> +#include <qtemporaryfile.h> #include <process.h> #include <errno.h> @@ -150,25 +151,23 @@ QString Environment::gccVersion() QString Environment::msvcVersion() { int returnValue = 0; - // Extract version from standard error output of "cl /?" - const QString command = QFile::decodeName(qgetenv("ComSpec")) - + QLatin1String(" /c ") + QLatin1String(compilerInfo(CC_MSVC2015)->executable) - + QLatin1String(" /? 2>&1"); - SetEnvironmentVariable(L"CL", NULL); // May contain /nologo, which suppresses the version. - QString version = execute(command, &returnValue); - if (returnValue != 0) { - cout << "Could not get cl version" << returnValue << qPrintable(version) << '\n';; - version.clear(); - } else { - QRegExp versionRegexp(QStringLiteral("^.*\\b(\\d{2,2}\\.\\d{2,2}\\.\\d{5,5})\\b.*$")); - Q_ASSERT(versionRegexp.isValid()); - if (versionRegexp.exactMatch(version)) { - version = versionRegexp.cap(1); - } else { - cout << "Unable to determine cl version from the output of \"" - << qPrintable(command) << "\"\n"; - } + QString tempSourceName; + { // QTemporaryFile needs to go out of scope, otherwise cl.exe refuses to open it. + QTemporaryFile tempSource(QDir::tempPath() + QLatin1String("/XXXXXX.cpp")); + tempSource.setAutoRemove(false); + if (!tempSource.open()) + return QString(); + tempSource.write("_MSC_FULL_VER\n"); + tempSourceName = tempSource.fileName(); } + QString version = execute(QLatin1String("cl /nologo /EP \"") + + QDir::toNativeSeparators(tempSourceName) + QLatin1Char('"'), + &returnValue).trimmed(); + QFile::remove(tempSourceName); + if (returnValue || version.size() < 9 || !version.at(0).isDigit()) + return QString(); + version.insert(4, QLatin1Char('.')); + version.insert(2, QLatin1Char('.')); return version; } |