diff options
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp')
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 92 |
1 files changed, 42 insertions, 50 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index a1a8407a11..1b3b328243 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the qmake application of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -129,7 +124,7 @@ DotNET which_dotnet_version(const QByteArray &preferredVersion = QByteArray()) // More than one version installed, search directory path QString paths = qgetenv("PATH"); const QStringList pathlist = paths.split(QLatin1Char(';')); - foreach (const QString &path, pathlist) { + for (const QString &path : pathlist) { for (i = 0; dotNetCombo[i].version; ++i) { const QString productPath = installPaths.value(dotNetCombo[i].version); if (productPath.isEmpty()) @@ -414,7 +409,7 @@ bool VcprojGenerator::isStandardSuffix(const QString &suffix) const ProString VcprojGenerator::firstInputFileName(const ProString &extraCompilerName) const { - foreach (const ProString &var, project->values(ProKey(extraCompilerName + ".input"))) { + for (const ProString &var : project->values(ProKey(extraCompilerName + ".input"))) { const ProStringList &files = project->values(var.toKey()); if (!files.isEmpty()) return files.first(); @@ -439,10 +434,12 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt QHash<QString, ProStringList> &subdirProjectLookup, const ProStringList &allDependencies) { - QLinkedList<QPair<QString, ProStringList> > collectedSubdirs; + QVector<QPair<QString, ProStringList> > collectedSubdirs; ProStringList tmp_proj_subdirs = proj->values("SUBDIRS"); ProStringList projectsInProject; - for(int x = 0; x < tmp_proj_subdirs.size(); ++x) { + const int numSubdirs = tmp_proj_subdirs.size(); + collectedSubdirs.reserve(numSubdirs); + for (int x = 0; x < numSubdirs; ++x) { ProString tmpdir = tmp_proj_subdirs.at(x); const ProKey tmpdirConfig(tmpdir + ".CONFIG"); if (!proj->isEmpty(tmpdirConfig)) { @@ -464,9 +461,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt collectedSubdirs.append(qMakePair(tmpdir.toQString(), proj->values(ProKey(tmp_proj_subdirs.at(x) + ".depends")))); projLookup.insert(tmp_proj_subdirs.at(x).toQString(), tmpdir.toQString()); } - QLinkedListIterator<QPair<QString, ProStringList> > collectedIt(collectedSubdirs); - while (collectedIt.hasNext()) { - QPair<QString, ProStringList> subdir = collectedIt.next(); + for (const auto &subdir : qAsConst(collectedSubdirs)) { QString profile = subdir.first; QFileInfo fi(fileInfo(Option::normalizePath(profile))); if (fi.exists()) { @@ -538,13 +533,13 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt if (tmpList.size()) { const ProStringList depends = tmpList; - foreach (const ProString &dep, depends) { + for (const ProString &dep : depends) { QString depend = dep.toQString(); if (!projGuids[depend].isEmpty()) { newDep->dependencies << projGuids[depend]; } else if (subdirProjectLookup[projLookup[depend]].size() > 0) { - ProStringList tmpLst = subdirProjectLookup[projLookup[depend]]; - foreach (const ProString &tDep, tmpLst) { + const ProStringList tmpLst = subdirProjectLookup[projLookup[depend]]; + for (const ProString &tDep : tmpLst) { QString tmpDep = tDep.toQString(); newDep->dependencies << projGuids[projLookup[tmpDep]]; } @@ -690,10 +685,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) t << _slnGlobalBeg; - QHashIterator<VcsolutionDepend *, QStringList> extraIt(extraSubdirs); - while (extraIt.hasNext()) { - extraIt.next(); - foreach (const QString &depend, extraIt.value()) { + for (auto extraIt = extraSubdirs.cbegin(), end = extraSubdirs.cend(); extraIt != end; ++extraIt) { + for (const QString &depend : extraIt.value()) { if (!projGuids[depend].isEmpty()) { extraIt.key()->dependencies << projGuids[depend]; } else if (!profileLookup[depend].isEmpty()) { @@ -704,12 +697,12 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } QString slnConf = _slnSolutionConf; if (!project->isEmpty("VCPROJ_ARCH")) { - slnConf.replace(QString("|Win32"), "|" + project->first("VCPROJ_ARCH")); + slnConf.replace(QLatin1String("|Win32"), "|" + project->first("VCPROJ_ARCH")); } else if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) { QString slnPlatform = QString("|") + project->values("CE_SDK").join(' ') + " (" + project->first("CE_ARCH") + ")"; - slnConf.replace(QString("|Win32"), slnPlatform); + slnConf.replace(QLatin1String("|Win32"), slnPlatform); } else if (is64Bit) { - slnConf.replace(QString("|Win32"), "|x64"); + slnConf.replace(QLatin1String("|Win32"), QLatin1String("|x64")); } t << slnConf; @@ -872,7 +865,7 @@ void VcprojGenerator::init() // Add all input files for a custom compiler into a map for uniqueness, // unless the compiler is configure as a combined stage, then use the first one - foreach (const ProString &quc, project->values("QMAKE_EXTRA_COMPILERS")) { + for (const ProString &quc : project->values("QMAKE_EXTRA_COMPILERS")) { const ProStringList &invar = project->values(ProKey(quc + ".input")); const QString compiler_out = project->first(ProKey(quc + ".output")).toQString(); for (ProStringList::ConstIterator iit = invar.constBegin(); iit != invar.constEnd(); ++iit) { @@ -898,12 +891,10 @@ void VcprojGenerator::init() } #if 0 // Debugging - Q_FOREACH(QString aKey, extraCompilerSources.keys()) { - qDebug("Extracompilers for %s are (%s)", aKey.toLatin1().constData(), extraCompilerSources.value(aKey).join(", ").toLatin1().constData()); - } - Q_FOREACH(QString aKey, extraCompilerOutputs.keys()) { - qDebug("Object mapping for %s is (%s)", aKey.toLatin1().constData(), extraCompilerOutputs.value(aKey).join(", ").toLatin1().constData()); - } + for (auto it = extraCompilerSources.cbegin(), end = extraCompilerSources.cend(); it != end; ++it) + qDebug("Extracompilers for %s are (%s)", it.key().toLatin1().constData(), it.value().join(", ").toLatin1().constData()); + for (auto it = extraCompilerOutputs.cbegin(), end = extraCompilerOutputs.cend(); it != end; ++it) + qDebug("Object mapping for %s is (%s)", it.key().toLatin1().constData(), it.value().join(", ").toLatin1().constData()); qDebug(""); #endif } @@ -1174,7 +1165,8 @@ void VcprojGenerator::initLinkerTool() static const char * const lflags[] = { "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", 0 }; for (int i = 0; lflags[i]; i++) { - foreach (const ProString &lib, fixLibFlags(lflags[i])) { + const auto libs = fixLibFlags(lflags[i]); + for (const ProString &lib : libs) { if (lib.startsWith("/LIBPATH:")) conf.linker.AdditionalLibraryDirectories << lib.mid(9).toQString(); else @@ -1196,7 +1188,7 @@ void VcprojGenerator::initResourceTool() else conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions; - foreach (const ProString &path, project->values("RC_INCLUDEPATH")) { + for (const ProString &path : project->values("RC_INCLUDEPATH")) { QString fixedPath = fileFixify(path.toQString()); if (fileInfo(fixedPath).isRelative()) { if (fixedPath == QLatin1String(".")) @@ -1270,7 +1262,7 @@ void VcprojGenerator::initDeploymentTool() if (targetPath.endsWith("/") || targetPath.endsWith("\\")) targetPath.chop(1); } - ProStringList dllPaths = project->values("QMAKE_DLL_PATHS"); + const ProStringList dllPaths = project->values("QMAKE_DLL_PATHS"); // Only deploy Qt libs for shared build if (!dllPaths.isEmpty() && !(conf.WinRT && project->first("MSVC_VER").toQString() == "14.0")) { @@ -1288,7 +1280,7 @@ void VcprojGenerator::initDeploymentTool() // Use only the file name and check in Qt's install path and LIBPATHs to check for existence dllName.remove(0, dllName.lastIndexOf(QLatin1Char('/')) + 1); QFileInfo info; - foreach (const ProString &dllPath, dllPaths) { + for (const ProString &dllPath : dllPaths) { QString absoluteDllFilePath = dllPath.toQString(); if (!absoluteDllFilePath.endsWith(QLatin1Char('/'))) absoluteDllFilePath += QLatin1Char('/'); @@ -1351,7 +1343,7 @@ void VcprojGenerator::initDeploymentTool() } } - foreach (const ProString &item, project->values("INSTALLS")) { + for (const ProString &item : project->values("INSTALLS")) { // get item.path QString devicePath = project->first(ProKey(item + ".path")).toQString(); if (!conf.WinRT) { @@ -1366,7 +1358,7 @@ void VcprojGenerator::initDeploymentTool() } } // foreach d in item.files - foreach (const ProString &src, project->values(ProKey(item + ".files"))) { + for (const ProString &src : project->values(ProKey(item + ".files"))) { QString itemDevicePath = devicePath; QString source = Option::normalizePath(src.toQString()); QString nameFilter; @@ -1670,7 +1662,7 @@ void VcprojGenerator::initExtraCompilerOutputs() // provided that the input file variable is not handled already (those in otherFilters // are handled, so we avoid them). const ProStringList &inputVars = project->values(ProKey(*it + ".input")); - foreach (const ProString &inputVar, inputVars) { + for (const ProString &inputVar : inputVars) { if (!otherFilters.contains(inputVar)) { const ProStringList &tmp_in = project->values(inputVar.toKey()); for (int i = 0; i < tmp_in.count(); ++i) { @@ -1706,12 +1698,12 @@ QString VcprojGenerator::replaceExtraCompilerVariables( if(defines.isEmpty()) defines.append(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") + varGlue("DEFINES"," -D"," -D","")); - ret.replace("$(DEFINES)", defines.first().toQString()); + ret.replace(QLatin1String("$(DEFINES)"), defines.first().toQString()); ProStringList &incpath = project->values("VCPROJ_MAKEFILE_INCPATH"); if(incpath.isEmpty() && !this->var("MSVCPROJ_INCPATH").isEmpty()) incpath.append(this->var("MSVCPROJ_INCPATH")); - ret.replace("$(INCPATH)", incpath.join(' ')); + ret.replace(QLatin1String("$(INCPATH)"), incpath.join(' ')); return ret; } |