diff options
Diffstat (limited to 'qmake/generators/mac/pbuilder_pbx.cpp')
-rw-r--r-- | qmake/generators/mac/pbuilder_pbx.cpp | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index d99b7158c3..d0d560aca9 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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: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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "pbuilder_pbx.h" #include "option.h" @@ -112,7 +87,7 @@ ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) for(int pb_subdir = 0; pb_subdir < pb_subdirs.size(); ++pb_subdir) { ProjectBuilderSubDirs *pb = pb_subdirs[pb_subdir]; const ProStringList &subdirs = pb->project->values("SUBDIRS"); - for(int subdir = 0; subdir < subdirs.count(); subdir++) { + for(int subdir = 0; subdir < subdirs.size(); subdir++) { ProString tmpk = subdirs[subdir]; const ProKey fkey(tmpk + ".file"); if (!pb->project->isEmpty(fkey)) { @@ -354,7 +329,7 @@ ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) t << "\t\t\tprojectReferences = (\n"; { const ProStringList &qmake_subdirs = project->values("QMAKE_PBX_SUBDIRS"); - for(int i = 0; i < qmake_subdirs.count(); i++) { + for(int i = 0; i < qmake_subdirs.size(); i++) { const ProString &subdir = qmake_subdirs[i]; t << "\t\t\t\t{\n" << "\t\t\t\t\t" << writeSettings("ProductGroup", keyFor(subdir + "_PRODUCTGROUP")) << ";\n" @@ -454,17 +429,17 @@ ProjectBuilderSources::files(QMakeProject *project) const static QString xcodeFiletypeForFilename(const QString &filename) { - for (const QString &ext : qAsConst(Option::cpp_ext)) { + for (const QString &ext : std::as_const(Option::cpp_ext)) { if (filename.endsWith(ext)) return QStringLiteral("sourcecode.cpp.cpp"); } - for (const QString &ext : qAsConst(Option::c_ext)) { + for (const QString &ext : std::as_const(Option::c_ext)) { if (filename.endsWith(ext)) return QStringLiteral("sourcecode.c.c"); } - for (const QString &ext : qAsConst(Option::h_ext)) { + for (const QString &ext : std::as_const(Option::h_ext)) { if (filename.endsWith(ext)) return "sourcecode.c.h"; } @@ -549,14 +524,14 @@ bool ProjectBuilderMakefileGenerator::replaceLibrarySuffix(const QString &lib_fi warn_msg(WarnLogic, "Failed to find expected suffix '%s' for library '%s'.", qPrintable(librarySuffix), qPrintable(library)); } else { - library.replace(pos, librarySuffix.length(), suffixSetting); + library.replace(pos, librarySuffix.size(), suffixSetting); if (name.endsWith(librarySuffix)) - name.chop(librarySuffix.length()); + name.chop(librarySuffix.size()); } } else { int pos = library.lastIndexOf(name); if (pos != -1) - library.insert(pos + name.length(), suffixSetting); + library.insert(pos + name.size(), suffixSetting); } } } @@ -683,7 +658,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) const QStringList &files = fileFixify(sources.at(source).files(project), FileFixifyFromOutdir | FileFixifyAbsolute); - for(int f = 0; f < files.count(); ++f) { + for(int f = 0; f < files.size(); ++f) { QString file = files[f]; if(!sources.at(source).compilerName().isNull() && !verifyExtraCompiler(sources.at(source).compilerName(), file)) @@ -783,6 +758,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) { QString mkfile = pbx_dir + Option::dir_sep + "qt_preprocess.mak"; QFile mkf(mkfile); + ProStringList outputPaths; + ProStringList inputPaths; if(mkf.open(QIODevice::WriteOnly | QIODevice::Text)) { writingUnixMakefileGenerator = true; debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData()); @@ -832,8 +809,11 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) ++added; const QString file_name = fileFixify(fn, FileFixifyFromOutdir); const QString tmpOut = fileFixify(tmp_out.first().toQString(), FileFixifyFromOutdir); - mkt << ' ' << escapeDependencyPath(Option::fixPathToTargetOS( + QString path = escapeDependencyPath(Option::fixPathToTargetOS( replaceExtraCompilerVariables(tmpOut, file_name, QString(), NoShell))); + mkt << ' ' << path; + inputPaths << fn; + outputPaths << path; } } } @@ -844,6 +824,14 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) mkt.flush(); mkf.close(); } + // Remove duplicates from build steps with "combine" + outputPaths.removeDuplicates(); + + // Don't create cycles. We only have one qt_preprocess.mak which runs different compilers + // whose inputs may depend on the output of another. The "compilers" step will run all + // compilers anyway + inputPaths.removeEach(outputPaths); + mkfile = fileFixify(mkfile); QString phase_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET"); // project->values("QMAKE_PBX_BUILDPHASES").append(phase_key); @@ -854,10 +842,13 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) << "\t\t\t" << writeSettings("isa", "PBXShellScriptBuildPhase", SettingsNoQuote) << ";\n" << "\t\t\t" << writeSettings("runOnlyForDeploymentPostprocessing", "0", SettingsNoQuote) << ";\n" << "\t\t\t" << writeSettings("name", "Qt Preprocessors") << ";\n" + << "\t\t\t" << writeSettings("inputPaths", inputPaths, SettingsAsList, 4) << ";\n" + << "\t\t\t" << writeSettings("outputPaths", outputPaths, SettingsAsList, 4) << ";\n" << "\t\t\t" << writeSettings("shellPath", "/bin/sh") << ";\n" << "\t\t\t" << writeSettings("shellScript", "make -C " + IoUtils::shellQuoteUnix(Option::output_dir) + " -f " + IoUtils::shellQuoteUnix(mkfile)) << ";\n" << "\t\t\t" << writeSettings("showEnvVarsInLog", "0") << ";\n" + << "\t\t\t" << writeSettings("alwaysOutOfDate", "1") << ";\n" << "\t\t};\n"; } @@ -882,7 +873,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr }; for (int i = 0; libs[i]; i++) { tmp = project->values(libs[i]); - for(int x = 0; x < tmp.count();) { + for(int x = 0; x < tmp.size();) { bool libSuffixReplaced = false; bool remove = false; QString library, name; @@ -921,7 +912,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) if(opt.size() > 2) { r = opt.mid(2).toQString(); } else { - if(x == tmp.count()-1) + if(x == tmp.size()-1) break; r = tmp[++x].toQString(); } @@ -930,12 +921,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) frameworkdirs.append(r); } } else if(opt == "-framework") { - if(x == tmp.count()-1) + if(x == tmp.size()-1) break; const ProString &framework = tmp[x+1]; ProStringList fdirs = frameworkdirs; fdirs << "/System/Library/Frameworks/" << "/Library/Frameworks/"; - for(int fdir = 0; fdir < fdirs.count(); fdir++) { + for(int fdir = 0; fdir < fdirs.size(); fdir++) { if(exists(fdirs[fdir] + QDir::separator() + framework + ".framework")) { remove = true; library = fdirs[fdir] + Option::dir_sep + framework + ".framework"; @@ -964,7 +955,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) const int slsh = library.lastIndexOf(Option::dir_sep); if(name.isEmpty()) { if(slsh != -1) - name = library.right(library.length() - slsh - 1); + name = library.right(library.size() - slsh - 1); } if(slsh != -1) { const QString path = QFileInfo(library.left(slsh)).absoluteFilePath(); @@ -1017,12 +1008,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) mkt << "SUBLIBS= "; // ### This is missing the parametrization found in unixmake2.cpp tmp = project->values("SUBLIBS"); - for(int i = 0; i < tmp.count(); i++) + for(int i = 0; i < tmp.size(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") << ' '; t << Qt::endl << Qt::endl; mkt << "sublibs: $(SUBLIBS)\n\n"; tmp = project->values("SUBLIBS"); - for(int i = 0; i < tmp.count(); i++) + for(int i = 0; i < tmp.size(); i++) t << escapeFilePath("tmp/lib" + tmp[i] + ".a") + ":\n\t" << var(ProKey("MAKELIB" + tmp[i])) << Qt::endl << Qt::endl; mkt.flush(); @@ -1157,7 +1148,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) //all bundle data const ProStringList &bundle_data = project->values("QMAKE_BUNDLE_DATA"); - for(int i = 0; i < bundle_data.count(); i++) { + for(int i = 0; i < bundle_data.size(); i++) { ProStringList bundle_files; ProString path = project->first(ProKey(bundle_data[i] + ".path")); const bool isEmbeddedFramework = ((!osx && path == QLatin1String("Frameworks")) @@ -1167,7 +1158,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) //all files const ProStringList &files = project->values(ProKey(bundle_data[i] + ".files")); - for(int file = 0; file < files.count(); file++) { + for(int file = 0; file < files.size(); file++) { QString fn = fileFixify(files[file].toQString(), FileFixifyAbsolute); QString name = fn.split(Option::dir_sep).back(); QString file_ref_key = keyFor("QMAKE_PBX_BUNDLE_DATA_FILE_REF." + bundle_data[i] + "-" + fn); @@ -1190,13 +1181,13 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) if (copyBundleResources && ((!osx && path.isEmpty()) || (osx && path == QLatin1String("Contents/Resources")))) { - for (const ProString &s : qAsConst(bundle_files)) + for (const ProString &s : std::as_const(bundle_files)) bundle_resources_files << s; } else if (copyBundleResources && isEmbeddedFramework) { - for (const ProString &s : qAsConst(bundle_files)) + for (const ProString &s : std::as_const(bundle_files)) embedded_frameworks << s; } else if (copyBundleResources && isEmbeddedPlugin) { - for (const ProString &s : qAsConst(bundle_files)) { + for (const ProString &s : std::as_const(bundle_files)) { ProString subpath = (path == pluginsPrefix) ? ProString() : path.mid(pluginsPrefix.size() + 1); embedded_plugins[subpath] << s; } @@ -1693,7 +1684,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) t << "\t\t\t\t" << writeSettings("CODE_SIGN_IDENTITY", project->first("QMAKE_XCODE_CODE_SIGN_IDENTITY")) << ";\n"; tmp = project->values("QMAKE_PBX_VARS"); - for (int i = 0; i < tmp.count(); i++) { + for (int i = 0; i < tmp.size(); i++) { QString var = tmp[i].toQString(), val = QString::fromLocal8Bit(qgetenv(var.toLatin1().constData())); if (val.isEmpty() && var == "TB") val = "/usr/bin/"; @@ -1897,7 +1888,7 @@ ProStringList ProjectBuilderMakefileGenerator::fixListForOutput(const ProStringList &l) { ProStringList ret; - for(int i = 0; i < l.count(); i++) + for(int i = 0; i < l.size(); i++) ret += fixForOutput(l[i].toQString()); return ret; } @@ -1979,14 +1970,14 @@ ProjectBuilderMakefileGenerator::pbxbuild() static QString quotedStringLiteral(const QString &value) { QString result; - const int len = value.length(); + const int len = value.size(); result.reserve(int(len * 1.1) + 2); result += QLatin1Char('"'); // Escape for (int i = 0; i < len; ++i) { - QChar character = value.at(i);; + QChar character = value.at(i); ushort code = character.unicode(); switch (code) { case '\\': @@ -2058,4 +2049,10 @@ ProjectBuilderMakefileGenerator::writeSettings(const QString &var, const ProStri return ret; } +bool +ProjectBuilderMakefileGenerator::inhibitMakeDirOutPath(const ProKey &path) const +{ + return path == "OBJECTS_DIR"; +} + QT_END_NAMESPACE |