2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include "unixmake.h"
|
|
|
|
#include "option.h"
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <qhash.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <qdebug.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2018-10-08 16:17:26 +00:00
|
|
|
ProStringList UnixMakefileGenerator::libdirToFlags(const ProKey &key)
|
|
|
|
{
|
|
|
|
ProStringList results;
|
2022-10-06 09:08:21 +00:00
|
|
|
for (const auto &libdir : std::as_const(project->values(key))) {
|
2018-10-08 16:17:26 +00:00
|
|
|
if (!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs"))
|
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdir;
|
|
|
|
results.append("-L" + escapeFilePath(libdir));
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
void
|
|
|
|
UnixMakefileGenerator::init()
|
|
|
|
{
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &configs = project->values("CONFIG");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty("ICON") && !project->isEmpty("RC_FILE"))
|
|
|
|
project->values("ICON") = project->values("RC_FILE");
|
|
|
|
if(project->isEmpty("QMAKE_EXTENSION_PLUGIN"))
|
|
|
|
project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB"));
|
|
|
|
|
2013-12-07 20:34:38 +00:00
|
|
|
project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");
|
|
|
|
|
|
|
|
//version handling
|
|
|
|
if (project->isEmpty("VERSION")) {
|
|
|
|
project->values("VERSION").append(
|
|
|
|
"1.0." + (project->isEmpty("VER_PAT") ? QString("0") : project->first("VER_PAT")));
|
|
|
|
}
|
|
|
|
QStringList l = project->first("VERSION").toQString().split('.');
|
|
|
|
l << "0" << "0"; //make sure there are three
|
|
|
|
project->values("VER_MAJ").append(l[0]);
|
|
|
|
project->values("VER_MIN").append(l[1]);
|
|
|
|
project->values("VER_PAT").append(l[2]);
|
|
|
|
|
2013-12-09 20:46:05 +00:00
|
|
|
QString sroot = project->sourceRoot();
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &iif : project->values("QMAKE_INTERNAL_INCLUDED_FILES")) {
|
2014-07-17 01:43:44 +00:00
|
|
|
if (iif == project->cacheFile())
|
|
|
|
continue;
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (iif.startsWith(sroot) && iif.at(sroot.size()) == QLatin1Char('/'))
|
2013-12-09 20:46:05 +00:00
|
|
|
project->values("DISTFILES") += fileFixify(iif.toQString(), FileFixifyRelative);
|
|
|
|
}
|
2013-12-07 20:34:38 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
/* this should probably not be here, but I'm using it to wrap the .t files */
|
|
|
|
if(project->first("TEMPLATE") == "app")
|
|
|
|
project->values("QMAKE_APP_FLAG").append("1");
|
|
|
|
else if(project->first("TEMPLATE") == "lib")
|
|
|
|
project->values("QMAKE_LIB_FLAG").append("1");
|
|
|
|
else if(project->first("TEMPLATE") == "subdirs") {
|
|
|
|
MakefileGenerator::init();
|
|
|
|
if(project->isEmpty("MAKEFILE"))
|
|
|
|
project->values("MAKEFILE").append("Makefile");
|
|
|
|
return; /* subdirs is done */
|
|
|
|
}
|
|
|
|
|
|
|
|
project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR");
|
|
|
|
if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) ||
|
|
|
|
(project->isActiveConfig("qt") && project->isActiveConfig("plugin"))) {
|
|
|
|
if(configs.indexOf("dll") == -1) configs.append("dll");
|
|
|
|
} else if(!project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll")) {
|
|
|
|
configs.removeAll("staticlib");
|
|
|
|
}
|
|
|
|
if(!project->isEmpty("QMAKE_INCREMENTAL"))
|
|
|
|
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_INCREMENTAL");
|
|
|
|
else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
|
|
|
|
!project->values("QMAKE_LIB_FLAG").isEmpty() &&
|
|
|
|
project->isActiveConfig("dll"))
|
|
|
|
project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PREBIND");
|
2017-05-16 15:28:22 +00:00
|
|
|
project->values("QMAKE_INCDIR") += project->values("QMAKE_INCDIR_POST");
|
2017-05-16 16:06:24 +00:00
|
|
|
project->values("QMAKE_RPATHDIR") += project->values("QMAKE_RPATHDIR_POST");
|
|
|
|
project->values("QMAKE_RPATHLINKDIR") += project->values("QMAKE_RPATHLINKDIR_POST");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_INCDIR"))
|
|
|
|
project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR");
|
2018-10-08 16:17:26 +00:00
|
|
|
// The order of the next two lines is relevant due to side effect on QMAKE_LFLAGS.
|
|
|
|
ProStringList ldadd = project->values("QMAKE_LIBDIR_FLAGS") + libdirToFlags("QMAKE_LIBDIR");
|
|
|
|
ProStringList ldaddpost = libdirToFlags("QMAKE_LIBDIR_POST");
|
2013-06-26 10:14:41 +00:00
|
|
|
if (project->isActiveConfig("mac")) {
|
2012-08-30 14:55:31 +00:00
|
|
|
if (!project->isEmpty("QMAKE_FRAMEWORKPATH")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &fwdirs = project->values("QMAKE_FRAMEWORKPATH");
|
2012-08-30 14:55:31 +00:00
|
|
|
for (int i = 0; i < fwdirs.size(); ++i)
|
|
|
|
project->values("QMAKE_FRAMEWORKPATH_FLAGS") += "-F" + escapeFilePath(fwdirs[i]);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-07-13 11:16:39 +00:00
|
|
|
ldadd += project->values("QMAKE_FRAMEWORKPATH_FLAGS");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2018-10-08 16:24:14 +00:00
|
|
|
ProStringList &qmklibs = project->values("LIBS");
|
2012-07-13 11:16:39 +00:00
|
|
|
qmklibs = ldadd + qmklibs;
|
2018-10-08 16:17:26 +00:00
|
|
|
ProStringList &qmklibspost = project->values("QMAKE_LIBS");
|
|
|
|
qmklibspost = ldaddpost + qmklibspost;
|
2014-08-07 11:06:55 +00:00
|
|
|
if (!project->isEmpty("QMAKE_RPATHDIR") && !project->isEmpty("QMAKE_LFLAGS_RPATH")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
|
2014-08-07 11:06:55 +00:00
|
|
|
for (int i = 0; i < rpathdirs.size(); ++i) {
|
|
|
|
QString rpathdir = rpathdirs[i].toQString();
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (rpathdir.size() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(') {
|
2015-06-05 14:12:02 +00:00
|
|
|
rpathdir.replace(0, 1, "\\$$"); // Escape from make and the shell
|
2015-09-29 18:06:05 +00:00
|
|
|
} else if (!rpathdir.startsWith('@') && fileInfo(rpathdir).isRelative()) {
|
|
|
|
QString rpathbase = project->first("QMAKE_REL_RPATH_BASE").toQString();
|
|
|
|
if (rpathbase.isEmpty()) {
|
|
|
|
fprintf(stderr, "Error: This platform does not support relative paths in QMAKE_RPATHDIR (%s)\n",
|
|
|
|
rpathdir.toLatin1().constData());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (rpathbase.startsWith('$'))
|
|
|
|
rpathbase.replace(0, 1, "\\$$"); // Escape from make and the shell
|
|
|
|
if (rpathdir == ".")
|
|
|
|
rpathdir = rpathbase;
|
|
|
|
else
|
|
|
|
rpathdir.prepend(rpathbase + '/');
|
|
|
|
project->values("QMAKE_LFLAGS").insertUnique(project->values("QMAKE_LFLAGS_REL_RPATH"));
|
|
|
|
}
|
2014-08-07 11:06:55 +00:00
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(rpathdir);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-03 11:34:37 +00:00
|
|
|
if (!project->isEmpty("QMAKE_RPATHLINKDIR")) {
|
|
|
|
const ProStringList &rpathdirs = project->values("QMAKE_RPATHLINKDIR");
|
|
|
|
for (int i = 0; i < rpathdirs.size(); ++i) {
|
|
|
|
if (!project->isEmpty("QMAKE_LFLAGS_RPATHLINK"))
|
|
|
|
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATHLINK") + escapeFilePath(QFileInfo(rpathdirs[i].toQString()).absoluteFilePath());
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if(project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
|
|
|
|
include_deps = true; //do not generate deps
|
|
|
|
|
|
|
|
MakefileGenerator::init();
|
|
|
|
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
if (project->isActiveConfig("objective_c"))
|
|
|
|
project->values("QMAKE_BUILTIN_COMPILERS") << "OBJC" << "OBJCXX";
|
|
|
|
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString compile_flag = var("QMAKE_COMPILE_FLAG");
|
|
|
|
if(compile_flag.isEmpty())
|
|
|
|
compile_flag = "-c";
|
|
|
|
|
|
|
|
if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
QString pchFlags = var(ProKey("QMAKE_" + compiler + "FLAGS_USE_PRECOMPILE"));
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QString pchBaseName;
|
|
|
|
if(!project->isEmpty("PRECOMPILED_DIR")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
pchBaseName = Option::fixPathToTargetOS(project->first("PRECOMPILED_DIR").toQString());
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!pchBaseName.endsWith(Option::dir_sep))
|
|
|
|
pchBaseName += Option::dir_sep;
|
|
|
|
}
|
2012-09-06 10:21:38 +00:00
|
|
|
pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
// replace place holders
|
2016-02-04 14:12:03 +00:00
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}"),
|
2015-02-06 14:30:02 +00:00
|
|
|
escapeFilePath(project->first("PRECOMPILED_HEADER").toQString()));
|
2016-02-04 14:12:03 +00:00
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}"), escapeFilePath(pchBaseName));
|
2011-04-27 10:05:43 +00:00
|
|
|
if (project->isActiveConfig("icc_pch_style")) {
|
|
|
|
// icc style
|
2016-02-04 14:12:03 +00:00
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
|
2015-02-06 14:30:02 +00:00
|
|
|
escapeFilePath(pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")));
|
2017-04-11 21:54:53 +00:00
|
|
|
const ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
|
|
|
|
for (const ProString &arch : pchArchs) {
|
|
|
|
QString suffix = project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
|
|
|
suffix.replace(QLatin1String("${QMAKE_PCH_ARCH}"), arch.toQString());
|
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT_") + arch + QLatin1Char('}'),
|
|
|
|
escapeFilePath(pchBaseName + suffix));
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
// gcc style (including clang_pch_style)
|
|
|
|
QString headerSuffix;
|
|
|
|
if (project->isActiveConfig("clang_pch_style"))
|
2012-09-06 10:21:38 +00:00
|
|
|
headerSuffix = project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2019-05-28 18:07:11 +00:00
|
|
|
pchBaseName += project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
pchBaseName += Option::dir_sep;
|
|
|
|
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
|
|
|
|
if (!language.isEmpty()) {
|
2016-02-04 14:12:03 +00:00
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
escapeFilePath(pchBaseName + language + headerSuffix));
|
2016-08-23 22:16:42 +00:00
|
|
|
const ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
|
|
|
|
for (const ProString &arch : pchArchs) {
|
2019-11-12 20:56:09 +00:00
|
|
|
QString file = pchBaseName + language + headerSuffix;
|
|
|
|
file.replace(QLatin1String("${QMAKE_PCH_ARCH}"), arch.toQString());
|
2016-08-23 22:16:42 +00:00
|
|
|
if (project->isActiveConfig("clang_pch_style")
|
2019-11-12 20:56:09 +00:00
|
|
|
&& (file.endsWith(QLatin1String(".pch"))
|
|
|
|
|| file.endsWith(QLatin1String(".gch")))) {
|
|
|
|
file.chop(4); // must omit header suffix for -include to recognize the PCH
|
2016-08-23 22:16:42 +00:00
|
|
|
}
|
|
|
|
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT_") + arch + QLatin1Char('}'),
|
2019-11-12 20:56:09 +00:00
|
|
|
escapeFilePath(file));
|
2016-08-23 22:16:42 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pchFlags.isEmpty())
|
|
|
|
compile_flag += " " + pchFlags;
|
|
|
|
}
|
|
|
|
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
QString compilerExecutable;
|
|
|
|
if (compiler == "C" || compiler == "OBJC") {
|
|
|
|
compilerExecutable = "$(CC)";
|
|
|
|
compile_flag += " $(CFLAGS)";
|
|
|
|
} else {
|
|
|
|
compilerExecutable = "$(CXX)";
|
|
|
|
compile_flag += " $(CXXFLAGS)";
|
|
|
|
}
|
|
|
|
|
|
|
|
compile_flag += " $(INCPATH)";
|
2011-04-27 10:05:43 +00:00
|
|
|
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
ProString compilerVariable = compiler;
|
|
|
|
if (compilerVariable == "C")
|
|
|
|
compilerVariable = ProString("CC");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
const ProKey runComp("QMAKE_RUN_" + compilerVariable);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty(runComp))
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
project->values(runComp).append(compilerExecutable + " " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "$obj $src");
|
|
|
|
const ProKey runCompImp("QMAKE_RUN_" + compilerVariable + "_IMP");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty(runCompImp))
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
project->values(runCompImp).append(compilerExecutable + " " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "\"$@\" \"$<\"");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 16:07:57 +00:00
|
|
|
if (project->isActiveConfig("mac") && !project->isEmpty("TARGET") &&
|
2011-04-27 10:05:43 +00:00
|
|
|
((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProString bundle;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_BUNDLE_NAME");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
} else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_APPLICATION_BUNDLE_NAME");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!bundle.endsWith(".app"))
|
|
|
|
bundle += ".app";
|
|
|
|
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
|
|
project->values("QMAKE_PKGINFO").append(project->first("DESTDIR") + bundle + "/Contents/PkgInfo");
|
|
|
|
} else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
|
|
|
|
((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) ||
|
|
|
|
(project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) {
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("TARGET");
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isActiveConfig("plugin")) {
|
|
|
|
if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_PLUGIN_BUNDLE_NAME");
|
2014-11-12 09:21:29 +00:00
|
|
|
if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
|
|
|
|
project->values("QMAKE_BUNDLE_EXTENSION").append(".plugin");
|
|
|
|
if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
2011-04-27 10:05:43 +00:00
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
|
|
|
|
} else {
|
|
|
|
if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
|
2015-02-06 14:30:02 +00:00
|
|
|
bundle = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME");
|
2014-11-12 09:21:29 +00:00
|
|
|
if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
|
|
|
|
project->values("QMAKE_BUNDLE_EXTENSION").append(".framework");
|
|
|
|
if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
|
2011-04-27 10:05:43 +00:00
|
|
|
bundle += project->first("QMAKE_BUNDLE_EXTENSION");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!bundle.isEmpty()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
project->values("QMAKE_BUNDLE") = ProStringList(bundle);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
project->values("QMAKE_BUNDLE").clear();
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
|
|
}
|
|
|
|
} else { //no bundling here
|
|
|
|
project->values("QMAKE_BUNDLE").clear();
|
|
|
|
project->values("QMAKE_BUNDLE_LOCATION").clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
init2();
|
rewrite windows library handling
first, store the library's full name in the .prl file, like we do on
unix. this is not expected to have any side effects, as QMAKE_PRL_TARGET
was entirely unused under windows so far.
then, rewrite the mingw library handling: instead of letting the linker
resolve the actual libraries, do it ourselves like we do for msvc. we
could not do that before due to the partial file names in the .prl
files: if the library didn't exist at qmake execution time, we'd have to
guess the file extension (the msvc generators never had that problem, as
they know about only one possible extension for libraries anyway).
make use of processPrlFile()'s ability to replace the reference to
the .prl file with the actual library. that way we don't need to
re-assemble the file name from pieces, which was fragile and
inefficient.
QMAKE_*_VERSION_OVERRIDE does not affect libraries coming with .prl
files any more. additionally, it is now used literally (not
numerically), and values less or equal to zero lost their special
meaning as "none" - this isn't a problem, because that's the default
anyway, and there is no need to override bogus versions from .prl files
any more.
no changelog for that, as i found no public traces of that feature
outside qtbase.
[ChangeLog][qmake][Windows] Libraries coming with .prl files can now
have non-standard file extensions and a major version of zero.
[ChangeLog][qmake][Windows][Important Behavior Changes] The .prl files
written by earlier versions of Qt cannot be used any more. This will
affect you if you depend on 3rd party libraries which come with .prl
files. Patch up QMAKE_PRL_TARGET to contain the complete file name of
the library, and replace any /LIBPATH: in QMAKE_PRL_LIBS with -L.
(the part about /LIBPATH: actually refers to the next commit.)
Change-Id: I07399341bff0609cb6db9660cbc62b141fb2ad96
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-09-25 12:21:44 +00:00
|
|
|
ProString target = project->first("TARGET");
|
|
|
|
int slsh = target.lastIndexOf(Option::dir_sep);
|
|
|
|
if (slsh != -1)
|
|
|
|
target.chopFront(slsh + 1);
|
|
|
|
project->values("LIB_TARGET").prepend(target);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
&UnixMakefileGenerator::findDependencies(const QString &f)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
QStringList &ret = MakefileGenerator::findDependencies(f);
|
2014-11-13 14:37:55 +00:00
|
|
|
if (doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
ProString file = f;
|
2011-04-27 10:05:43 +00:00
|
|
|
QString header_prefix;
|
|
|
|
if(!project->isEmpty("PRECOMPILED_DIR"))
|
2012-09-06 10:21:38 +00:00
|
|
|
header_prefix = project->first("PRECOMPILED_DIR").toQString();
|
|
|
|
header_prefix += project->first("QMAKE_ORIG_TARGET").toQString();
|
2019-05-28 18:07:11 +00:00
|
|
|
header_prefix += project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if (project->isActiveConfig("icc_pch_style")) {
|
|
|
|
// icc style
|
2017-04-11 21:54:53 +00:00
|
|
|
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
|
|
|
|
if (pchArchs.isEmpty())
|
|
|
|
pchArchs << ProString(); // normal single-arch PCH
|
2022-10-06 09:08:21 +00:00
|
|
|
for (const ProString &arch : std::as_const(pchArchs)) {
|
2017-04-11 21:54:53 +00:00
|
|
|
auto pfx = header_prefix;
|
|
|
|
if (!arch.isEmpty())
|
|
|
|
pfx.replace(QLatin1String("${QMAKE_PCH_ARCH}"), arch.toQString());
|
|
|
|
for (QStringList::Iterator it = Option::cpp_ext.begin();
|
|
|
|
it != Option::cpp_ext.end(); ++it) {
|
|
|
|
if (file.endsWith(*it)) {
|
|
|
|
ret += pfx;
|
|
|
|
break;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// gcc style (including clang_pch_style)
|
|
|
|
QString header_suffix = project->isActiveConfig("clang_pch_style")
|
2012-09-06 10:21:38 +00:00
|
|
|
? project->first("QMAKE_PCH_OUTPUT_EXT").toQString() : "";
|
2011-04-27 10:05:43 +00:00
|
|
|
header_prefix += Option::dir_sep + project->first("QMAKE_PRECOMP_PREFIX");
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) {
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
if (project->isEmpty(ProKey("QMAKE_" + compiler + "FLAGS_PRECOMPILE")))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
|
|
|
|
if (language.isEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Unfortunately we were not consistent about the C++ naming
|
|
|
|
ProString extensionSuffix = compiler;
|
|
|
|
if (extensionSuffix == "CXX")
|
|
|
|
extensionSuffix = ProString("CPP");
|
|
|
|
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &extension : project->values(ProKey("QMAKE_EXT_" + extensionSuffix))) {
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
if (!file.endsWith(extension.toQString()))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 22:16:42 +00:00
|
|
|
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
|
|
|
|
if (pchArchs.isEmpty())
|
|
|
|
pchArchs << ProString(); // normal single-arch PCH
|
2022-10-06 09:08:21 +00:00
|
|
|
for (const ProString &arch : std::as_const(pchArchs)) {
|
2019-11-12 20:56:09 +00:00
|
|
|
QString precompiledHeader = header_prefix + language + header_suffix;
|
|
|
|
if (!arch.isEmpty()) {
|
|
|
|
precompiledHeader.replace(QLatin1String("${QMAKE_PCH_ARCH}"),
|
|
|
|
arch.toQString());
|
|
|
|
}
|
2016-08-23 22:16:42 +00:00
|
|
|
if (!ret.contains(precompiledHeader))
|
|
|
|
ret += precompiledHeader;
|
|
|
|
}
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
|
|
|
|
goto foundPrecompiledDependency;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
Distinguish between Objective-C and Objective-C++ sources
Instead of lumping both Objective-C (.m) and Objective-C++ (.mm) sources
into the same pile, passing them on to the same compiler as for C++ (CXX),
with the C++ flags (CXXFLAGS), we follow Apple's lead and treat them as
variants of the C and C++ languages separately, so that Objective-C
sources are built with CC and with CFLAGS, and Objective-C++ sources
with CXX, and CXXFLAGS.
This lets us remove a lot of duplicated flags and definitions from the
QMAKE_OBJECTIVE_CFLAGS variable, which in 99% of the cases just matched
the C++ equivalent. The remaining Objective-C/C++ flags are added to
CFLAGS/CXXFLAGS, as the compiler will just ignore them when running in
C/C++ mode. This matches Xcode, which also doesn't have a separate build
setting for Objective-C/C++ flags.
The Makefile qmake generator has been rewritten to support Objective-C/C++
fully, by not assuming that we're just iterating over the C and C++
extensions when dealing with compilation rules, precompiled headers, etc.
There's some duplicated logic in this code, as inherent by qmake's already
duplicated code paths, but this can be cleaned up when C++11 support is
mandatory and we can use lambda functions.
Task-number: QTBUG-36575
Change-Id: I4f06576d5f49e939333a2e03d965da54119e5e31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
2015-10-02 11:54:33 +00:00
|
|
|
foundPrecompiledDependency:
|
|
|
|
; // Hurray!!
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-06 14:30:02 +00:00
|
|
|
ProString
|
|
|
|
UnixMakefileGenerator::fixLibFlag(const ProString &lib)
|
|
|
|
{
|
|
|
|
return escapeFilePath(lib);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
bool
|
2015-08-17 17:33:52 +00:00
|
|
|
UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2020-07-06 09:11:44 +00:00
|
|
|
QList<QMakeLocalFileName> libdirs, frameworkdirs;
|
2015-08-17 17:33:52 +00:00
|
|
|
int libidx = 0, fwidx = 0;
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
|
2012-09-06 10:21:38 +00:00
|
|
|
libdirs.append(QMakeLocalFileName(dlib.toQString()));
|
2015-08-17 17:33:52 +00:00
|
|
|
frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks"));
|
|
|
|
frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks"));
|
2018-12-14 13:18:39 +00:00
|
|
|
ProStringList extens;
|
|
|
|
extens << project->first("QMAKE_EXTENSION_SHLIB") << "a";
|
2018-10-08 16:24:14 +00:00
|
|
|
static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE",
|
|
|
|
"QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr };
|
2012-08-20 11:04:39 +00:00
|
|
|
for (int i = 0; lflags[i]; i++) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &l = project->values(lflags[i]);
|
|
|
|
for (ProStringList::Iterator it = l.begin(); it != l.end(); ) {
|
2015-06-01 13:22:18 +00:00
|
|
|
QString opt = (*it).toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(opt.startsWith("-")) {
|
|
|
|
if(opt.startsWith("-L")) {
|
2012-07-13 11:08:26 +00:00
|
|
|
QString lib = opt.mid(2);
|
|
|
|
QMakeLocalFileName f(lib);
|
2012-08-02 10:11:13 +00:00
|
|
|
int idx = libdirs.indexOf(f);
|
|
|
|
if (idx >= 0 && idx < libidx) {
|
2012-07-13 11:09:30 +00:00
|
|
|
it = l.erase(it);
|
|
|
|
continue;
|
|
|
|
}
|
2012-07-19 15:50:59 +00:00
|
|
|
libdirs.insert(libidx++, f);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(opt.startsWith("-l")) {
|
2015-06-01 13:22:18 +00:00
|
|
|
QString lib = opt.mid(2);
|
2022-10-06 09:08:21 +00:00
|
|
|
for (const QMakeLocalFileName &libdir : std::as_const(libdirs)) {
|
2019-08-06 13:01:49 +00:00
|
|
|
QString libBase = libdir.local() + '/'
|
2015-08-17 17:33:52 +00:00
|
|
|
+ project->first("QMAKE_PREFIX_SHLIB") + lib;
|
2018-07-09 18:02:27 +00:00
|
|
|
if (linkPrl && processPrlFile(libBase, true))
|
2015-08-17 17:33:52 +00:00
|
|
|
goto found;
|
|
|
|
for (ProStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
|
|
|
|
if (exists(libBase + '.' + (*extit)))
|
|
|
|
goto found;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-17 17:33:52 +00:00
|
|
|
found: ;
|
2013-03-06 13:53:36 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt.startsWith("-F")) {
|
2015-08-17 17:33:52 +00:00
|
|
|
QMakeLocalFileName f(opt.mid(2));
|
|
|
|
if (!frameworkdirs.contains(f))
|
2012-07-19 15:50:59 +00:00
|
|
|
frameworkdirs.insert(fwidx++, f);
|
2019-09-27 13:07:58 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE && opt == "-framework") {
|
2015-08-17 17:33:52 +00:00
|
|
|
if (linkPrl) {
|
2019-09-27 13:07:58 +00:00
|
|
|
opt = (*++it).toQString();
|
2018-04-18 12:09:12 +00:00
|
|
|
static const QChar suffixMarker = ',';
|
|
|
|
const int suffixPosition = opt.indexOf(suffixMarker);
|
|
|
|
const bool hasSuffix = suffixPosition >= 0;
|
|
|
|
QString frameworkName = opt;
|
|
|
|
if (hasSuffix) {
|
|
|
|
frameworkName.truncate(suffixPosition);
|
|
|
|
opt.remove(suffixMarker); // Apply suffix by removing marker
|
|
|
|
}
|
2022-10-06 09:08:21 +00:00
|
|
|
for (const QMakeLocalFileName &dir : std::as_const(frameworkdirs)) {
|
2019-09-27 13:38:48 +00:00
|
|
|
auto processPrlIfFound = [&](QString directory) {
|
|
|
|
QString suffixedPrl = directory + opt;
|
|
|
|
if (processPrlFile(suffixedPrl, true))
|
|
|
|
return true;
|
|
|
|
if (hasSuffix) {
|
|
|
|
QString unsuffixedPrl = directory + frameworkName;
|
|
|
|
if (processPrlFile(unsuffixedPrl, true))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2018-04-18 12:09:12 +00:00
|
|
|
QString frameworkDirectory = dir.local() + "/" + frameworkName + + ".framework/";
|
2019-09-27 13:38:48 +00:00
|
|
|
if (processPrlIfFound(frameworkDirectory + "Resources/")
|
|
|
|
|| processPrlIfFound(frameworkDirectory))
|
2015-08-17 17:33:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
if (opt.size() == 10)
|
2015-08-17 17:33:52 +00:00
|
|
|
++it;
|
|
|
|
// Skip
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-17 17:33:52 +00:00
|
|
|
} else if (linkPrl) {
|
2018-07-09 18:02:27 +00:00
|
|
|
processPrlFile(opt, false);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
|
2015-08-17 17:33:52 +00:00
|
|
|
for (int prl = 0; prl < prl_libs.size(); ++prl)
|
|
|
|
it = l.insert(++it, prl_libs.at(prl));
|
|
|
|
prl_libs.clear();
|
|
|
|
++it;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-17 17:33:52 +00:00
|
|
|
if (mergeLflags) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QHash<ProKey, ProStringList> lflags;
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int lit = 0; lit < l.size(); ++lit) {
|
2012-09-06 10:21:38 +00:00
|
|
|
ProKey arch("default");
|
2015-05-22 10:07:49 +00:00
|
|
|
ProString opt = l.at(lit);
|
2015-08-17 17:33:52 +00:00
|
|
|
if (opt.startsWith('-')) {
|
2013-03-06 13:53:36 +00:00
|
|
|
if (target_mode == TARG_MAC_MODE && opt.startsWith("-Xarch")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if (opt.length() > 7) {
|
2012-09-06 10:21:38 +00:00
|
|
|
arch = opt.mid(7).toKey();
|
2011-04-27 10:05:43 +00:00
|
|
|
opt = l.at(++lit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-17 17:33:52 +00:00
|
|
|
if (opt.startsWith("-L")
|
|
|
|
|| (target_mode == TARG_MAC_MODE && opt.startsWith("-F"))) {
|
|
|
|
if (!lflags[arch].contains(opt))
|
2011-04-27 10:05:43 +00:00
|
|
|
lflags[arch].append(opt);
|
2015-08-17 17:33:52 +00:00
|
|
|
} else if (opt.startsWith("-l") || opt == "-pthread") {
|
|
|
|
// Make sure we keep the dependency order of libraries
|
|
|
|
lflags[arch].removeAll(opt);
|
2011-04-27 10:05:43 +00:00
|
|
|
lflags[arch].append(opt);
|
2018-01-16 13:41:28 +00:00
|
|
|
} else if (target_mode == TARG_MAC_MODE
|
|
|
|
&& (opt == "-framework" || opt == "-force_load")) {
|
|
|
|
// Handle space separated options
|
|
|
|
ProString dashOpt = opt;
|
2019-07-29 14:00:43 +00:00
|
|
|
opt = l.at(++lit);
|
|
|
|
if (opt.startsWith("-Xarch"))
|
|
|
|
opt = l.at(++lit); // The user has done the right thing and prefixed each part
|
2011-04-27 10:05:43 +00:00
|
|
|
for(int x = 0; x < lflags[arch].size(); ++x) {
|
2018-01-16 13:41:28 +00:00
|
|
|
if (lflags[arch].at(x) == dashOpt && lflags[arch].at(++x) == opt) {
|
2018-12-19 17:18:24 +00:00
|
|
|
lflags[arch].remove(x - 1, 2);
|
2015-06-02 18:32:20 +00:00
|
|
|
break;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-16 13:41:28 +00:00
|
|
|
lflags[arch].append(dashOpt);
|
2018-12-19 17:18:24 +00:00
|
|
|
lflags[arch].append(opt);
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
}
|
|
|
|
} else if(!opt.isNull()) {
|
2018-12-14 13:18:39 +00:00
|
|
|
for (const ProString &ext : extens) {
|
|
|
|
if (opt.size() > ext.size() && opt.endsWith(ext)
|
|
|
|
&& opt.at(opt.size() - ext.size() - 1) == '.') {
|
|
|
|
// Make sure we keep the dependency order of libraries
|
|
|
|
lflags[arch].removeAll(opt);
|
|
|
|
lflags[arch].append(opt);
|
|
|
|
goto found2;
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!lflags[arch].contains(opt))
|
|
|
|
lflags[arch].append(opt);
|
2018-12-14 13:18:39 +00:00
|
|
|
found2: ;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = lflags.take("default");
|
|
|
|
|
|
|
|
// Process architecture specific options (Xarch)
|
2012-09-06 10:21:38 +00:00
|
|
|
QHash<ProKey, ProStringList>::const_iterator archIterator = lflags.constBegin();
|
2011-04-27 10:05:43 +00:00
|
|
|
while (archIterator != lflags.constEnd()) {
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &archOptions = archIterator.value();
|
2011-04-27 10:05:43 +00:00
|
|
|
for (int i = 0; i < archOptions.size(); ++i) {
|
|
|
|
l.append(QLatin1String("-Xarch_") + archIterator.key());
|
|
|
|
l.append(archOptions.at(i));
|
|
|
|
}
|
|
|
|
++archIterator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-17 17:33:52 +00:00
|
|
|
return false;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2016-01-14 12:01:39 +00:00
|
|
|
#ifdef Q_OS_WIN // MinGW x-compiling for QNX
|
|
|
|
QString UnixMakefileGenerator::installRoot() const
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
We include a magic prefix on the path to bypass mingw-make's "helpful"
|
|
|
|
intervention in the environment, recognising variables that look like
|
|
|
|
paths and adding the msys system root as prefix, which we don't want.
|
|
|
|
Once this hack has smuggled INSTALL_ROOT into make's variable space, we
|
|
|
|
can trivially strip the magic prefix back off to get the path we meant.
|
|
|
|
*/
|
|
|
|
return QStringLiteral("$(INSTALL_ROOT:@msyshack@%=%)");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QString
|
|
|
|
UnixMakefileGenerator::defaultInstall(const QString &t)
|
|
|
|
{
|
|
|
|
if(t != "target" || project->first("TEMPLATE") == "subdirs")
|
|
|
|
return QString();
|
|
|
|
|
2013-07-11 13:43:32 +00:00
|
|
|
enum { NoBundle, SolidBundle, SlicedBundle } bundle = NoBundle;
|
2015-05-05 17:01:14 +00:00
|
|
|
bool isAux = (project->first("TEMPLATE") == "aux");
|
2016-01-14 12:01:39 +00:00
|
|
|
const QString root = installRoot();
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
|
|
|
|
QString ret, destdir = project->first("DESTDIR").toQString();
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
|
|
|
|
destdir += Option::dir_sep;
|
2014-11-24 18:51:32 +00:00
|
|
|
QString targetdir = fileFixify(project->first("target.path").toQString(), FileFixifyAbsolute);
|
2011-04-27 10:05:43 +00:00
|
|
|
if(targetdir.right(1) != Option::dir_sep)
|
|
|
|
targetdir += Option::dir_sep;
|
|
|
|
|
2012-09-06 10:21:38 +00:00
|
|
|
ProStringList links;
|
2011-04-27 10:05:43 +00:00
|
|
|
QString target="$(TARGET)";
|
2012-09-06 10:21:38 +00:00
|
|
|
const ProStringList &targets = project->values(ProKey(t + ".targets"));
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_BUNDLE")) {
|
2012-09-06 10:21:38 +00:00
|
|
|
target = project->first("QMAKE_BUNDLE").toQString();
|
2013-07-11 13:43:32 +00:00
|
|
|
bundle = project->isActiveConfig("sliced_bundle") ? SlicedBundle : SolidBundle;
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(project->first("TEMPLATE") == "app") {
|
|
|
|
target = "$(QMAKE_TARGET)";
|
|
|
|
} else if(project->first("TEMPLATE") == "lib") {
|
2014-04-23 14:26:26 +00:00
|
|
|
if (!project->isActiveConfig("staticlib")
|
|
|
|
&& !project->isActiveConfig("plugin")
|
|
|
|
&& !project->isActiveConfig("unversioned_libname")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
|
|
|
|
links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
|
|
|
|
} else {
|
|
|
|
links << "$(TARGET0)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i = 0; i < targets.size(); ++i) {
|
2012-09-06 10:21:38 +00:00
|
|
|
QString src = targets.at(i).toQString(),
|
2015-02-06 14:30:02 +00:00
|
|
|
dst = escapeFilePath(filePrefixRoot(root, targetdir + src.section('/', -1)));
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2019-05-23 08:58:30 +00:00
|
|
|
ret += "$(QINSTALL) " + escapeFilePath(Option::fixPathToTargetOS(src, false)) + ' ' + dst;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 16:07:57 +00:00
|
|
|
{
|
2011-04-27 10:05:43 +00:00
|
|
|
QString src_targ = target;
|
|
|
|
if(!destdir.isEmpty())
|
|
|
|
src_targ = Option::fixPathToTargetOS(destdir + target, false);
|
2013-07-11 13:43:32 +00:00
|
|
|
QString plain_targ = filePrefixRoot(root, fileFixify(targetdir + target, FileFixifyAbsolute));
|
|
|
|
QString dst_targ = plain_targ;
|
2015-02-06 14:30:02 +00:00
|
|
|
plain_targ = escapeFilePath(plain_targ);
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle != NoBundle) {
|
|
|
|
QString suffix;
|
2016-02-16 06:29:01 +00:00
|
|
|
if (project->first("TEMPLATE") == "lib") {
|
|
|
|
if (!project->isActiveConfig("shallow_bundle"))
|
|
|
|
suffix += "/Versions/" + project->first("QMAKE_FRAMEWORK_VERSION");
|
|
|
|
suffix += "/$(TARGET)";
|
|
|
|
} else {
|
2013-07-11 13:43:32 +00:00
|
|
|
suffix = "/" + project->first("QMAKE_BUNDLE_LOCATION") + "/$(QMAKE_TARGET)";
|
2016-02-16 06:29:01 +00:00
|
|
|
}
|
2013-07-11 13:43:32 +00:00
|
|
|
dst_targ += suffix;
|
|
|
|
if (bundle == SolidBundle) {
|
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "$(DEL_FILE) -r " + plain_targ + "\n\t";
|
2013-07-11 13:43:32 +00:00
|
|
|
} else {
|
|
|
|
src_targ += suffix;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2015-02-06 14:30:02 +00:00
|
|
|
src_targ = escapeFilePath(src_targ);
|
|
|
|
dst_targ = escapeFilePath(dst_targ);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2015-05-05 17:01:14 +00:00
|
|
|
QString copy_cmd;
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SolidBundle) {
|
2019-05-23 08:58:30 +00:00
|
|
|
copy_cmd += "$(QINSTALL) " + src_targ + ' ' + plain_targ;
|
2013-07-11 13:43:32 +00:00
|
|
|
} else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
2019-05-23 08:58:30 +00:00
|
|
|
copy_cmd += "$(QINSTALL) " + src_targ + ' ' + dst_targ;
|
2015-05-05 17:01:14 +00:00
|
|
|
} else if (!isAux) {
|
2016-06-11 03:15:12 +00:00
|
|
|
if (bundle == SlicedBundle) {
|
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
|
|
|
ret += mkdir_p_asstring("\"`dirname " + dst_targ + "`\"", false);
|
|
|
|
}
|
2019-05-23 08:58:30 +00:00
|
|
|
copy_cmd += "$(QINSTALL_PROGRAM) " + src_targ + ' ' + dst_targ;
|
2013-07-11 13:43:32 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib")
|
2012-09-06 10:21:38 +00:00
|
|
|
&& project->values(ProKey(t + ".CONFIG")).indexOf("fix_rpath") != -1) {
|
2015-05-05 17:01:14 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_FIX_RPATH")) {
|
|
|
|
ret += copy_cmd;
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "\n\t-" + var("QMAKE_FIX_RPATH") + ' ' + dst_targ + ' ' + dst_targ;
|
2011-04-27 10:05:43 +00:00
|
|
|
} else if(!project->isEmpty("QMAKE_LFLAGS_RPATH")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += "-$(LINK) $(LFLAGS) " + var("QMAKE_LFLAGS_RPATH") + targetdir + " -o " +
|
|
|
|
dst_targ + " $(OBJECTS) $(LIBS) $(OBJCOMP)";
|
2011-04-27 10:05:43 +00:00
|
|
|
} else {
|
|
|
|
ret += copy_cmd;
|
|
|
|
}
|
2015-05-05 17:01:14 +00:00
|
|
|
} else if (!copy_cmd.isEmpty()) {
|
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2011-04-27 10:05:43 +00:00
|
|
|
ret += copy_cmd;
|
|
|
|
}
|
|
|
|
|
2015-05-05 17:01:14 +00:00
|
|
|
if (isAux) {
|
|
|
|
} else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!project->isEmpty("QMAKE_RANLIB"))
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += QString("\n\t$(RANLIB) ") + dst_targ;
|
2013-11-18 20:39:08 +00:00
|
|
|
} else if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip")
|
|
|
|
&& !project->isEmpty("QMAKE_STRIP")) {
|
2011-04-27 10:05:43 +00:00
|
|
|
ret += "\n\t-$(STRIP)";
|
2013-07-04 14:09:05 +00:00
|
|
|
if (project->first("TEMPLATE") == "lib") {
|
|
|
|
if (!project->isEmpty("QMAKE_STRIPFLAGS_LIB"))
|
|
|
|
ret += " " + var("QMAKE_STRIPFLAGS_LIB");
|
|
|
|
} else if (project->first("TEMPLATE") == "app") {
|
|
|
|
if (!project->isEmpty("QMAKE_STRIPFLAGS_APP"))
|
|
|
|
ret += " " + var("QMAKE_STRIPFLAGS_APP");
|
|
|
|
}
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += ' ' + dst_targ;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SolidBundle)
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) -r " + plain_targ);
|
2015-05-05 17:01:14 +00:00
|
|
|
else if (!isAux)
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst_targ);
|
2013-07-11 13:43:32 +00:00
|
|
|
if (bundle == SlicedBundle) {
|
|
|
|
int dstlen = project->first("DESTDIR").length();
|
2016-01-26 13:38:54 +00:00
|
|
|
for (const ProString &src : project->values("QMAKE_BUNDLED_FILES")) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ProString file = src.mid(dstlen);
|
|
|
|
QString dst = escapeFilePath(
|
|
|
|
filePrefixRoot(root, fileFixify(targetdir + file, FileFixifyAbsolute)));
|
2013-07-11 13:43:32 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
2015-02-06 14:30:02 +00:00
|
|
|
ret += mkdir_p_asstring("\"`dirname " + dst + "`\"", false) + "\n\t";
|
|
|
|
ret += "-$(DEL_FILE) " + dst + "\n\t"; // Can't overwrite symlinks to directories
|
2019-05-23 08:58:30 +00:00
|
|
|
ret += "$(QINSTALL) " + escapeFilePath(src) + " " + dst;
|
2013-07-11 13:43:32 +00:00
|
|
|
if (!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst);
|
2013-07-11 13:43:32 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!links.isEmpty()) {
|
|
|
|
for(int i = 0; i < links.size(); ++i) {
|
2013-03-06 13:53:36 +00:00
|
|
|
if (target_mode == TARG_UNIX_MODE || target_mode == TARG_MAC_MODE) {
|
2011-04-27 10:05:43 +00:00
|
|
|
QString link = Option::fixPathToTargetOS(destdir + links[i], false);
|
|
|
|
int lslash = link.lastIndexOf(Option::dir_sep);
|
|
|
|
if(lslash != -1)
|
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-30 12:09:04 +00:00
|
|
|
link = link.right(link.size() - (lslash + 1));
|
2015-02-06 14:30:02 +00:00
|
|
|
QString dst_link = escapeFilePath(
|
|
|
|
filePrefixRoot(root, fileFixify(targetdir + link, FileFixifyAbsolute)));
|
|
|
|
ret += "\n\t-$(SYMLINK) $(TARGET) " + dst_link;
|
2011-04-27 10:05:43 +00:00
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + dst_link);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-03 12:59:16 +00:00
|
|
|
if (isAux || project->first("TEMPLATE") == "lib") {
|
2011-04-27 10:05:43 +00:00
|
|
|
QStringList types;
|
|
|
|
types << "prl" << "libtool" << "pkgconfig";
|
|
|
|
for(int i = 0; i < types.size(); ++i) {
|
|
|
|
const QString type = types.at(i);
|
|
|
|
QString meta;
|
|
|
|
if(type == "prl" && project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
|
|
|
|
!project->isEmpty("QMAKE_INTERNAL_PRL_FILE"))
|
|
|
|
meta = prlFileName(false);
|
2015-08-18 16:07:57 +00:00
|
|
|
if (type == "libtool" && project->isActiveConfig("create_libtool"))
|
2011-04-27 10:05:43 +00:00
|
|
|
meta = libtoolFileName(false);
|
|
|
|
if(type == "pkgconfig" && project->isActiveConfig("create_pc"))
|
|
|
|
meta = pkgConfigFileName(false);
|
|
|
|
if(!meta.isEmpty()) {
|
|
|
|
QString src_meta = meta;
|
|
|
|
if(!destdir.isEmpty())
|
|
|
|
src_meta = Option::fixPathToTargetOS(destdir + meta, false);
|
|
|
|
QString dst_meta = filePrefixRoot(root, fileFixify(targetdir + meta, FileFixifyAbsolute));
|
|
|
|
if(!uninst.isEmpty())
|
|
|
|
uninst.append("\n\t");
|
2015-02-06 14:30:02 +00:00
|
|
|
uninst.append("-$(DEL_FILE) " + escapeFilePath(dst_meta));
|
2011-04-27 10:05:43 +00:00
|
|
|
const QString dst_meta_dir = fileInfo(dst_meta).path();
|
|
|
|
if(!dst_meta_dir.isEmpty()) {
|
|
|
|
if(!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
|
|
|
ret += mkdir_p_asstring(dst_meta_dir, true);
|
|
|
|
}
|
2013-01-10 23:30:41 +00:00
|
|
|
if (!ret.isEmpty())
|
|
|
|
ret += "\n\t";
|
|
|
|
ret += installMetaFile(ProKey("QMAKE_" + type.toUpper() + "_INSTALL_REPLACE"), src_meta, dst_meta);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
UnixMakefileGenerator::escapeFilePath(const QString &path) const
|
|
|
|
{
|
|
|
|
QString ret = path;
|
|
|
|
if(!ret.isEmpty()) {
|
2015-02-06 14:30:02 +00:00
|
|
|
ret.replace(QLatin1Char(' '), QLatin1String("\\ "))
|
|
|
|
.replace(QLatin1Char('\t'), QLatin1String("\\\t"));
|
2011-04-27 10:05:43 +00:00
|
|
|
debug_msg(2, "EscapeFilePath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData());
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|