summaryrefslogtreecommitdiffstats
path: root/qmake/generators/makefile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/generators/makefile.cpp')
-rw-r--r--qmake/generators/makefile.cpp81
1 files changed, 44 insertions, 37 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 5ec4cfb7ef..dffc3d6acb 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.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$
**
@@ -59,6 +54,8 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
using namespace QMakeInternal;
@@ -779,6 +776,7 @@ MakefileGenerator::init()
if(project->isActiveConfig("depend_includepath"))
incDirs += v["INCLUDEPATH"];
QList<QMakeLocalFileName> deplist;
+ deplist.reserve(incDirs.size());
for (ProStringList::Iterator it = incDirs.begin(); it != incDirs.end(); ++it)
deplist.append(QMakeLocalFileName((*it).toQString()));
QMakeSourceFileInfo::setDependencyPaths(deplist);
@@ -907,7 +905,7 @@ MakefileGenerator::processPrlFile(QString &file)
project->values("QMAKE_CURRENT_PRL_LIBS") = libinfo.values("QMAKE_PRL_LIBS");
ProStringList &defs = project->values("DEFINES");
const ProStringList &prl_defs = project->values("PRL_EXPORT_DEFINES");
- foreach (const ProString &def, libinfo.values("QMAKE_PRL_DEFINES"))
+ for (const ProString &def : libinfo.values("QMAKE_PRL_DEFINES"))
if (!defs.contains(def) && prl_defs.contains(def))
defs.append(def);
if (try_replace_file) {
@@ -939,12 +937,12 @@ void
MakefileGenerator::filterIncludedFiles(const char *var)
{
ProStringList &inputs = project->values(var);
- for (ProStringList::Iterator input = inputs.begin(); input != inputs.end(); ) {
- if (QMakeSourceFileInfo::included((*input).toQString()) > 0)
- input = inputs.erase(input);
- else
- ++input;
- }
+ auto isIncluded = [this](const ProString &input) {
+ return QMakeSourceFileInfo::included(input.toQString()) > 0;
+ };
+ inputs.erase(std::remove_if(inputs.begin(), inputs.end(),
+ isIncluded),
+ inputs.end());
}
static QString
@@ -957,7 +955,7 @@ static QString
qv(const ProStringList &val)
{
QString ret;
- foreach (const ProString &v, val)
+ for (const ProString &v : val)
ret += qv(v);
return ret;
}
@@ -1013,6 +1011,7 @@ MakefileGenerator::writeProjectMakefile()
QList<SubTarget*> targets;
{
ProStringList builds = project->values("BUILDS");
+ targets.reserve(builds.size());
for (ProStringList::Iterator it = builds.begin(); it != builds.end(); ++it) {
SubTarget *st = new SubTarget;
targets.append(st);
@@ -1144,7 +1143,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src)
<< " " << escapeDependencyPaths(findDependencies(srcf)).join(" \\\n\t\t");
ProKey comp;
- foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
+ for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
// Unfortunately we were not consistent about the C++ naming
ProString extensionSuffix = compiler;
if (extensionSuffix == "CXX")
@@ -1155,7 +1154,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src)
if (compilerSuffix == "C")
compilerSuffix = ProString("CC");
- foreach (const ProString &extension, project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
+ for (const ProString &extension : project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
if ((*sit).endsWith(extension)) {
comp = ProKey("QMAKE_RUN_" + compilerSuffix);
break;
@@ -1453,7 +1452,9 @@ QString
MakefileGenerator::fixFileVarGlue(const ProKey &var, const QString &before, const QString &glue, const QString &after) const
{
ProStringList varList;
- foreach (const ProString &val, project->values(var))
+ const auto values = project->values(var);
+ varList.reserve(values.size());
+ for (const ProString &val : values)
varList << escapeFilePath(Option::fixPathToTargetOS(val.toQString()));
return valGlue(varList, before, glue, after);
}
@@ -1867,7 +1868,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
if (raw_clean.isEmpty())
raw_clean << tmp_out;
QString tmp_clean;
- foreach (const QString &rc, raw_clean)
+ for (const QString &rc : qAsConst(raw_clean))
tmp_clean += ' ' + escapeFilePath(Option::fixPathToTargetOS(rc));
QString tmp_clean_cmds = project->values(ProKey(*it + ".clean_commands")).join(' ');
if(!tmp_inputs.isEmpty())
@@ -1892,7 +1893,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) {
QString tinp = (*input).toQString();
QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell);
- foreach (const QString &rc, raw_clean) {
+ for (const QString &rc : qAsConst(raw_clean)) {
dels << ' ' + escapeFilePath(Option::fixPathToTargetOS(
replaceExtraCompilerVariables(rc, tinp, out, NoShell), false));
}
@@ -1902,7 +1903,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
} else {
QString files;
const int commandlineLimit = 2047; // NT limit, expanded
- foreach (const QString &file, dels) {
+ for (const QString &file : qAsConst(dels)) {
if(del_statement.length() + files.length() +
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
cleans.append(files);
@@ -2248,7 +2249,7 @@ QString MakefileGenerator::buildArgs()
{
QString ret;
- foreach (const QString &arg, Option::globals->qmake_args)
+ for (const QString &arg : qAsConst(Option::globals->qmake_args))
ret += " " + shellQuote(arg);
return ret;
}
@@ -2772,11 +2773,11 @@ MakefileGenerator::parseLibFlag(const ProString &flag, ProString *arg)
ProStringList
MakefileGenerator::fixLibFlags(const ProKey &var)
{
- ProStringList in = project->values(var);
+ const ProStringList &in = project->values(var);
ProStringList ret;
ret.reserve(in.length());
- foreach (const ProString &v, in)
+ for (const ProString &v : in)
ret << fixLibFlag(v);
return ret;
}
@@ -2806,7 +2807,9 @@ ProStringList
MakefileGenerator::escapeFilePaths(const ProStringList &paths) const
{
ProStringList ret;
- for (int i = 0; i < paths.size(); ++i)
+ const int size = paths.size();
+ ret.reserve(size);
+ for (int i = 0; i < size; ++i)
ret.append(escapeFilePath(paths.at(i)));
return ret;
}
@@ -2821,7 +2824,9 @@ QStringList
MakefileGenerator::escapeDependencyPaths(const QStringList &paths) const
{
QStringList ret;
- for(int i = 0; i < paths.size(); ++i)
+ const int size = paths.size();
+ ret.reserve(size);
+ for (int i = 0; i < size; ++i)
ret.append(escapeDependencyPath(paths.at(i)));
return ret;
}
@@ -2830,7 +2835,9 @@ ProStringList
MakefileGenerator::escapeDependencyPaths(const ProStringList &paths) const
{
ProStringList ret;
- for (int i = 0; i < paths.size(); ++i)
+ const int size = paths.size();
+ ret.reserve(size);
+ for (int i = 0; i < size; ++i)
ret.append(escapeDependencyPath(paths.at(i).toQString()));
return ret;
}