diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-11-16 08:53:38 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-11-16 13:31:29 (GMT) |
commit | d4150975af620e2889cc58bd476bac6b4d101db3 (patch) | |
tree | 15e000be38cc530e25f68066ade6581d14a4f60d /tools | |
parent | 2326a8d878e0d18473c27ddd54880621518b6e6e (diff) | |
download | Qt-d4150975af620e2889cc58bd476bac6b4d101db3.zip Qt-d4150975af620e2889cc58bd476bac6b4d101db3.tar.gz Qt-d4150975af620e2889cc58bd476bac6b4d101db3.tar.bz2 |
Windows: Add gcc 4.6.
- Add gcc 4.6 mkspec for > 4.4 (win32-g++-4.6)
- Add detection of g++ version and 64bit to configure.
Reviewed-by: mariusSO
Diffstat (limited to 'tools')
-rw-r--r-- | tools/configure/configureapp.cpp | 31 | ||||
-rw-r--r-- | tools/configure/environment.cpp | 86 | ||||
-rw-r--r-- | tools/configure/environment.h | 3 |
3 files changed, 105 insertions, 15 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index e6d8526..60996e3 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1263,17 +1263,18 @@ void Configure::parseCmdLine() } cout << "See the README file for a list of supported operating systems and compilers." << endl; } else { - if (dictionary[ "QMAKESPEC" ].endsWith("-icc") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") || - dictionary[ "QMAKESPEC" ].endsWith("-msvc2010")) { + const QString qmakeSpec = dictionary[ "QMAKESPEC" ]; + if (qmakeSpec.endsWith("-icc") || + qmakeSpec.endsWith("-msvc") || + qmakeSpec.endsWith("-msvc.net") || + qmakeSpec.endsWith("-msvc2002") || + qmakeSpec.endsWith("-msvc2003") || + qmakeSpec.endsWith("-msvc2005") || + qmakeSpec.endsWith("-msvc2008") || + qmakeSpec.endsWith("-msvc2010")) { if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake"; dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32"; - } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) { + } else if (qmakeSpec.contains("win32-g++")) { if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make"; if (Environment::detectExecutable("sh.exe")) { dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-sh"; @@ -1329,7 +1330,7 @@ void Configure::parseCmdLine() } } - useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++"); + useUnixSeparators = dictionary["QMAKESPEC"].contains("win32-g++"); // Allow tests for private classes to be compiled against internal builds if (dictionary["BUILDDEV"] == "yes") @@ -2201,7 +2202,9 @@ bool Configure::checkAvailability(const QString &part) } else if (part == "MULTIMEDIA" || part == "SCRIPT" || part == "SCRIPTTOOLS" || part == "DECLARATIVE") { available = true; } else if (part == "WEBKIT") { - available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-msvc2010") || (dictionary.value("QMAKESPEC") == "win32-g++"); + const QString qmakeSpec = dictionary.value("QMAKESPEC"); + available = qmakeSpec == "win32-msvc2005" || qmakeSpec == "win32-msvc2008" || + qmakeSpec == "win32-msvc2010" || qmakeSpec.startsWith("win32-g++"); if (dictionary[ "SHARED" ] == "no") { cout << endl << "WARNING: Using static linking will disable the WebKit module." << endl << endl; @@ -2376,7 +2379,7 @@ bool Configure::verifyConfiguration() dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue } - if (dictionary["QMAKESPEC"].endsWith("-g++") + if (dictionary["QMAKESPEC"].contains("-g++") && dictionary["SQL_OCI"] != "no") { cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl @@ -2456,7 +2459,7 @@ void Configure::generateBuildKey() QString spec = dictionary["QMAKESPEC"]; QString compiler = "msvc"; // ICC is compatible - if (spec.endsWith("-g++")) + if (spec.contains("-g++")) compiler = "mingw"; else if (spec.endsWith("-borland")) compiler = "borland"; @@ -2874,7 +2877,7 @@ void Configure::generateOutputVars() if (!qmakeStylePlugins.isEmpty()) qmakeVars += QString("style-plugins += ") + qmakeStylePlugins.join(" "); - if (dictionary["QMAKESPEC"].endsWith("-g++")) { + if (dictionary["QMAKESPEC"].contains("-g++")) { QString includepath = qgetenv("INCLUDE"); bool hasSh = Environment::detectExecutable("sh.exe"); QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';')); diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index f9b3e85..78e1d87 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -120,6 +120,9 @@ QString Environment::detectQMakeSpec() spec = "win32-icc"; break; case CC_MINGW: + spec = "win32-g++-4.6"; + break; + case CC_MINGW_44: spec = "win32-g++"; break; case CC_BORLAND: @@ -173,6 +176,12 @@ Compiler Environment::detectCompiler() if (executable.length() && Environment::detectExecutable(executable)) { ++installed; detectedCompiler = compiler_info[i].compiler; + if (detectedCompiler == CC_MINGW) { + bool is64bit; + const int version = detectGPlusPlusVersion(executable, &is64bit); + if (version < 0x040600) + detectedCompiler = CC_MINGW_44; + } break; } } @@ -184,7 +193,7 @@ Compiler Environment::detectCompiler() } return detectedCompiler; #endif -}; +} /*! Returns true if the \a executable could be loaded, else false. @@ -214,6 +223,81 @@ bool Environment::detectExecutable(const QString &executable) } /*! + Determine the g++ version. +*/ + +int Environment::detectGPlusPlusVersion(const QString &executable, + bool *is64bit) +{ + QRegExp regexp(QLatin1String("[gG]\\+\\+[\\.exEX]{0,4} ([^\\s]+) (\\d+)\\.(\\d+)\\.(\\d+)")); + QString stdOut = readProcessStandardOutput(executable + QLatin1String(" --version")); + if (regexp.indexIn(stdOut) != -1) { + const QString compiler = regexp.cap(1); + // Check for "tdm64-1" + *is64bit = compiler.contains(QLatin1String("64")); + const int major = regexp.cap(2).toInt(); + const int minor = regexp.cap(3).toInt(); + const int patch = regexp.cap(4).toInt(); + return (major << 16) + (minor << 8) + patch; + } + *is64bit = false; + return 0; +} + +/*! + Run a process and return its standard output. +*/ + +QString Environment::readProcessStandardOutput(const QString &commandLine) +{ + QString stdOut; + TCHAR tempFileName[MAX_PATH]; + TCHAR tempPathBuffer[MAX_PATH]; + if (!GetTempPath(MAX_PATH, tempPathBuffer) + || !GetTempFileName(tempPathBuffer, TEXT("qtconfigure"), 0, tempFileName)) + return stdOut; + + STARTUPINFO startInfo; + memset(&startInfo, 0, sizeof(startInfo)); + startInfo.cb = sizeof(startInfo); + startInfo.dwFlags |= STARTF_USESTDHANDLES; + + SECURITY_ATTRIBUTES securityAttributes; + securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); + securityAttributes.bInheritHandle = TRUE; + securityAttributes.lpSecurityDescriptor = NULL; + + startInfo.hStdOutput = CreateFile(tempFileName, GENERIC_WRITE, 0, &securityAttributes, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (startInfo.hStdOutput == INVALID_HANDLE_VALUE) + return stdOut; + + PROCESS_INFORMATION procInfo; + memset(&procInfo, 0, sizeof(procInfo)); + + if (!CreateProcess(0, (wchar_t*)commandLine.utf16(), + 0, 0, TRUE, + 0, + 0, 0, &startInfo, &procInfo)) { + CloseHandle(startInfo.hStdOutput); + DeleteFile(tempFileName); + return stdOut; + } + + WaitForSingleObject(procInfo.hProcess, INFINITE); + CloseHandle(procInfo.hThread); + CloseHandle(procInfo.hProcess); + CloseHandle(startInfo.hStdOutput); + QFile file(QString::fromWCharArray(tempFileName)); + + if (file.open(QIODevice::Text| QIODevice::ReadOnly)) { + stdOut = QString::fromLocal8Bit(file.readAll()); + file.close(); + } + DeleteFile(tempFileName); + return stdOut; +} + +/*! Creates a commandling from \a program and it \a arguments, escaping characters that needs it. */ diff --git a/tools/configure/environment.h b/tools/configure/environment.h index 9bbd096..81c232a 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -49,6 +49,7 @@ enum Compiler { CC_UNKNOWN = 0, CC_BORLAND = 0x01, CC_MINGW = 0x02, + CC_MINGW_44 = 0x21, CC_INTEL = 0x03, CC_NET2003 = 0x71, CC_NET2005 = 0x80, @@ -63,6 +64,8 @@ public: static Compiler detectCompiler(); static QString detectQMakeSpec(); static bool detectExecutable(const QString &executable); + static int detectGPlusPlusVersion(const QString &executable, bool *is64bit); + static QString readProcessStandardOutput(const QString &commandLine); static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv); static bool cpdir(const QString &srcDir, |