summaryrefslogtreecommitdiffstats
path: root/tools/configure/environment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/configure/environment.cpp')
-rw-r--r--tools/configure/environment.cpp237
1 files changed, 0 insertions, 237 deletions
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index 8f18f3c489..6cc350acc5 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -119,58 +119,6 @@ QString Environment::detectQMakeSpec()
return spec;
}
-Compiler Environment::compilerFromQMakeSpec(const QString &qmakeSpec)
-{
- if (qmakeSpec == QLatin1String("win32-msvc2015"))
- return CC_MSVC2015;
- if (qmakeSpec == QLatin1String("win32-msvc2013"))
- return CC_MSVC2013;
- if (qmakeSpec == QLatin1String("win32-msvc2012"))
- return CC_MSVC2012;
- if (qmakeSpec == QLatin1String("win32-icc"))
- return CC_INTEL;
- if (qmakeSpec == QLatin1String("win32-g++"))
- return CC_MINGW;
- if (qmakeSpec == QLatin1String("win32-borland"))
- return CC_BORLAND;
- return CC_UNKNOWN;
-}
-
-QString Environment::gccVersion()
-{
- CompilerInfo *info = compilerInfo(CC_MINGW);
- int returnValue = 0;
- QString version = execute(QStringLiteral("%1 -dumpversion").arg(info->executable), &returnValue);
- if (returnValue != 0) {
- cout << "Could not get mingw version" << returnValue << qPrintable(version);
- version.resize(0);
- }
- return version;
-}
-
-QString Environment::msvcVersion()
-{
- int returnValue = 0;
- 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;
-}
-
/*!
Returns the enum of the compiler which was detected on the system.
The compilers are detected in the order as entered into the
@@ -455,189 +403,4 @@ QString Environment::execute(const QString &command, int *returnCode)
return output;
}
-/*!
- Copies the \a srcDir contents into \a destDir.
-
- Returns true if copying was successful.
-*/
-bool Environment::cpdir(const QString &srcDir, const QString &destDir)
-{
- QString cleanSrcName = QDir::cleanPath(srcDir);
- QString cleanDstName = QDir::cleanPath(destDir);
-
-#ifdef CONFIGURE_DEBUG_CP_DIR
- qDebug() << "Attempt to cpdir " << cleanSrcName << "->" << cleanDstName;
-#endif
- if(!QFile::exists(cleanDstName) && !QDir().mkpath(cleanDstName)) {
- qDebug() << "cpdir: Failure to create " << cleanDstName;
- return false;
- }
-
- bool result = true;
- QDir dir = QDir(cleanSrcName);
- QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
- for (int i = 0; result && (i < allEntries.count()); ++i) {
- QFileInfo entry = allEntries.at(i);
- bool intermediate = true;
- if (entry.isDir()) {
- intermediate = cpdir(QString("%1/%2").arg(cleanSrcName).arg(entry.fileName()),
- QString("%1/%2").arg(cleanDstName).arg(entry.fileName()));
- } else {
- QString destFile = QString("%1/%2").arg(cleanDstName).arg(entry.fileName());
-#ifdef CONFIGURE_DEBUG_CP_DIR
- qDebug() << "About to cp (file)" << entry.absoluteFilePath() << "->" << destFile;
-#endif
- QFile::remove(destFile);
- intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
- SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
- }
- if (!intermediate) {
- qDebug() << "cpdir: Failure for " << entry.fileName() << entry.isDir();
- result = false;
- }
- }
- return result;
-}
-
-bool Environment::rmdir(const QString &name)
-{
- bool result = true;
- QString cleanName = QDir::cleanPath(name);
-
- QDir dir = QDir(cleanName);
- QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
- for (int i = 0; result && (i < allEntries.count()); ++i) {
- QFileInfo entry = allEntries.at(i);
- if (entry.isDir()) {
- result &= rmdir(entry.absoluteFilePath());
- } else {
- result &= QFile::remove(entry.absoluteFilePath());
- }
- }
- result &= dir.rmdir(cleanName);
- return result;
-}
-
-static QStringList splitPathList(const QString &path)
-{
-#if defined(Q_OS_WIN)
- QRegExp splitReg(QStringLiteral("[;,]"));
-#else
- QRegExp splitReg(QStringLiteral("[:]"));
-#endif
- QStringList result = path.split(splitReg, QString::SkipEmptyParts);
- const QStringList::iterator end = result.end();
- for (QStringList::iterator it = result.begin(); it != end; ++it) {
- // Remove any leading or trailing ", this is commonly used in the environment
- // variables
- if (it->startsWith('"'))
- it->remove(0, 1);
- if (it->endsWith('"'))
- it->chop(1);
- *it = QDir::cleanPath(*it);
- if (it->endsWith(QLatin1Char('/')))
- it->chop(1);
- }
- return result;
-}
-
-QString Environment::findFileInPaths(const QString &fileName, const QStringList &paths)
-{
- if (!paths.isEmpty()) {
- QDir d;
- const QChar separator = QDir::separator();
- foreach (const QString &path, paths)
- if (d.exists(path + separator + fileName))
- return path;
- }
- return QString();
-}
-
-QStringList Environment::path()
-{
- return splitPathList(QString::fromLocal8Bit(qgetenv("PATH")));
-}
-
-static QStringList mingwPaths(const QString &mingwPath, const QString &pathName)
-{
- QStringList ret;
- QDir mingwDir(mingwPath);
- const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
- for (int i = 0 ;i < subdirs.length(); ++i) {
- const QFileInfo &fi = subdirs.at(i);
- const QString name = fi.fileName();
- if (name == pathName)
- ret += fi.absoluteFilePath();
- else if (name.contains(QLatin1String("mingw"))) {
- ret += fi.absoluteFilePath() + QLatin1Char('/') + pathName;
- }
- }
- return ret;
-}
-
-// Return MinGW location from "c:\mingw\bin" -> "c:\mingw"
-static inline QString detectMinGW()
-{
- const QString gcc = QStandardPaths::findExecutable(QLatin1String("g++.exe"));
- return gcc.isEmpty() ?
- gcc : QFileInfo(QFileInfo(gcc).absolutePath()).absolutePath();
-}
-
-// Detect Direct X SDK up tp June 2010. Included in Windows Kit 8.
-QString Environment::detectDirectXSdk()
-{
- const QByteArray directXSdkEnv = qgetenv("DXSDK_DIR");
- if (directXSdkEnv.isEmpty())
- return QString();
- QString directXSdk = QDir::cleanPath(QString::fromLocal8Bit(directXSdkEnv));
- if (directXSdk.endsWith(QLatin1Char('/')))
- directXSdk.truncate(directXSdk.size() - 1);
- return directXSdk;
-}
-
-QStringList Environment::headerPaths(Compiler compiler)
-{
- QStringList headerPaths;
- if (compiler == CC_MINGW) {
- const QString mingwPath = detectMinGW();
- headerPaths = mingwPaths(mingwPath, QLatin1String("include"));
- // Additional compiler paths
- const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
- for (int i = 0; i < mingwConfigs.length(); ++i) {
- const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath();
- foreach (const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
- headerPaths += version.absoluteFilePath() + QLatin1String("/include");
- }
- } else {
- headerPaths = splitPathList(QString::fromLocal8Bit(getenv("INCLUDE")));
- }
-
- // Add Direct X SDK for ANGLE
- const QString directXSdk = detectDirectXSdk();
- if (!directXSdk.isEmpty()) // Add Direct X SDK for ANGLE
- headerPaths += directXSdk + QLatin1String("/include");
- return headerPaths;
-}
-
-QStringList Environment::libraryPaths(Compiler compiler)
-{
- QStringList libraryPaths;
- if (compiler == CC_MINGW) {
- libraryPaths = mingwPaths(detectMinGW(), "lib");
- } else {
- libraryPaths = splitPathList(QString::fromLocal8Bit(qgetenv("LIB")));
- }
-
- // Add Direct X SDK for ANGLE
- const QString directXSdk = detectDirectXSdk();
- if (!directXSdk.isEmpty()) {
-#ifdef Q_OS_WIN64
- libraryPaths += directXSdk + QLatin1String("/lib/x64");
-#else
- libraryPaths += directXSdk + QLatin1String("/lib/x86");
-#endif
- }
- return libraryPaths;
-}
-
QT_END_NAMESPACE