summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-04-03 11:49:27 +0200
committerLars Knoll <lars.knoll@qt.io>2020-05-05 18:41:10 +0200
commit52f3a7d9d40d3bf835bb0716ad201ee56731b980 (patch)
treea736d2cca2516f2ad2003ff28b34e7a8ff483cf6
parentae7e701074be97130aa45f780e2456981850b432 (diff)
Build qmake with QT_USE_STRINGBUILDER
Should improve performance and is going to be required in the future anyway. Change-Id: I89d7c50441d2491da1ab0a4d564dcc91f52ade85 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--qmake/CMakeLists.txt2
-rw-r--r--qmake/Makefile.unix2
-rw-r--r--qmake/Makefile.win322
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp2
-rw-r--r--qmake/generators/mac/pbuilder_pbx.h2
-rw-r--r--qmake/generators/makefile.cpp6
-rw-r--r--qmake/generators/makefile.h6
-rw-r--r--qmake/generators/unix/unixmake.h2
-rw-r--r--qmake/generators/unix/unixmake2.cpp4
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp8
-rw-r--r--qmake/library/proitems.h74
-rw-r--r--qmake/qmake.pro3
-rw-r--r--tests/auto/tools/qmakelib/CMakeLists.txt1
-rw-r--r--tests/auto/tools/qmakelib/qmakelib.pro2
14 files changed, 80 insertions, 36 deletions
diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt
index 3bfd27f293..7017812aca 100644
--- a/qmake/CMakeLists.txt
+++ b/qmake/CMakeLists.txt
@@ -72,6 +72,7 @@ qt_add_tool(qmake # special case
../src/corelib/text/qregexp.cpp ../src/corelib/text/qregexp.h
../src/corelib/tools/qringbuffer.cpp # special case
../src/corelib/text/qstring.cpp ../src/corelib/text/qstring.h
+ ../src/corelib/text/qstringbuilder.cpp ../src/corelib/text/qstringbuilder.h
../src/corelib/text/qstringlist.cpp ../src/corelib/text/qstringlist.h
../src/corelib/text/qstringmatcher.h
../src/corelib/tools/qvector.h
@@ -110,6 +111,7 @@ qt_add_tool(qmake # special case
PROEVALUATOR_FULL
QT_BOOTSTRAPPED
QT_BUILD_QMAKE
+ QT_USE_QSTRINGBUILDER
QT_NO_FOREACH
QT_VERSION_STR="${PROJECT_VERSION}" # special case
QT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} # special case
diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix
index 32c6d1dae6..d113b456d4 100644
--- a/qmake/Makefile.unix
+++ b/qmake/Makefile.unix
@@ -143,7 +143,7 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \
-I$(QMAKESPEC) \
-DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
- -DQT_NO_FOREACH
+ -DQT_NO_FOREACH -DQT_USE_QSTRINGBUILDER
CXXFLAGS = $(EXTRA_CXXFLAGS) $(CONFIG_CXXFLAGS) $(CPPFLAGS)
LFLAGS = $(EXTRA_LFLAGS) $(CONFIG_LFLAGS)
diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32
index 20644595d2..3430cf8c7f 100644
--- a/qmake/Makefile.win32
+++ b/qmake/Makefile.win32
@@ -38,7 +38,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \
-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS \
-DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
- -DQT_NO_FOREACH -DUNICODE -D_ENABLE_EXTENDED_ALIGNED_STORAGE
+ -DQT_NO_FOREACH -DQT_USE_QSTRINGBUILDER -DUNICODE -D_ENABLE_EXTENDED_ALIGNED_STORAGE
CFLAGS = $(CFLAGS_PCH) $(CFLAGS_BARE) $(CFLAGS)
CXXFLAGS_BARE = $(CFLAGS_BARE)
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index c2f6df7787..ec0a044361 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -644,7 +644,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
bool isObj = project->values(ProKey(*it + ".CONFIG")).indexOf("no_link") == -1;
if (!isObj) {
for (int i = 0; i < sources.size(); ++i) {
- if (sources.at(i).keyName() == inputs.at(input)) {
+ if (sources.at(i).keyName() == inputs.at(input).toQStringView()) {
duplicate = true;
break;
}
diff --git a/qmake/generators/mac/pbuilder_pbx.h b/qmake/generators/mac/pbuilder_pbx.h
index 1b90a3bbeb..9b85764caa 100644
--- a/qmake/generators/mac/pbuilder_pbx.h
+++ b/qmake/generators/mac/pbuilder_pbx.h
@@ -56,8 +56,6 @@ class ProjectBuilderMakefileGenerator : public UnixMakefileGenerator
enum { SettingsAsList=0x01, SettingsNoQuote=0x02 };
inline QString writeSettings(const QString &var, const char *val, int flags=0, int indent_level=0)
{ return writeSettings(var, ProString(val), flags, indent_level); }
- inline QString writeSettings(const QString &var, const QString &val, int flags=0, int indent_level=0)
- { return writeSettings(var, ProString(val), flags, indent_level); }
inline QString writeSettings(const QString &var, const ProString &val, int flags=0, int indent_level=0)
{ return writeSettings(var, ProStringList(val), flags, indent_level); }
QString writeSettings(const QString &var, const ProStringList &vals, int flags=0, int indent_level=0);
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 5c61a3c65c..9d2d240bc2 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -2273,7 +2273,7 @@ QString MakefileGenerator::fullBuildArgs()
//output
QString ofile = fileFixify(Option::output.fileName());
- if(!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE"))
+ if (!ofile.isEmpty() && ofile != project->first("QMAKE_MAKEFILE").toQStringView())
ret += " -o " + escapeFilePath(ofile);
//inputs
@@ -2515,7 +2515,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT
if(!abs_source_path.isEmpty() && out_directory.startsWith(abs_source_path))
out_directory = Option::output_dir + out_directory.mid(abs_source_path.length());
- QString out_directory_cdin = out_directory.isEmpty() ? "\n\t"
+ QString out_directory_cdin = out_directory.isEmpty() ? QString("\n\t")
: "\n\tcd " + escapeFilePath(out_directory) + " && ";
QString makefilein = " -f " + escapeFilePath(subtarget->makefile);
@@ -2696,7 +2696,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT
if(!recurse.contains(subtarget->name))
continue;
- QString out_directory_cdin = out_directory.isEmpty() ? "\n\t"
+ QString out_directory_cdin = out_directory.isEmpty() ? QString("\n\t")
: "\n\tcd " + escapeFilePath(out_directory) + " && ";
QString makefilein = " -f " + escapeFilePath(subtarget->makefile);
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index bae32883b4..b80b6e3e08 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -140,10 +140,16 @@ protected:
//escape
virtual QString escapeFilePath(const QString &path) const = 0;
ProString escapeFilePath(const ProString &path) const;
+ template<typename A, typename B>
+ QString escapeFilePath(const QStringBuilder<A, B> &path) const
+ { return escapeFilePath(QString(path)); }
QStringList escapeFilePaths(const QStringList &paths) const;
ProStringList escapeFilePaths(const ProStringList &paths) const;
virtual QString escapeDependencyPath(const QString &path) const;
ProString escapeDependencyPath(const ProString &path) const;
+ template<typename A, typename B>
+ QString escapeDependencyPath(const QStringBuilder<A, B> &path) const
+ { return escapeDependencyPath(QString(path)); }
QStringList escapeDependencyPaths(const QStringList &paths) const;
ProStringList escapeDependencyPaths(const ProStringList &paths) const;
diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h
index 28302b4f15..1f32e4341f 100644
--- a/qmake/generators/unix/unixmake.h
+++ b/qmake/generators/unix/unixmake.h
@@ -50,7 +50,7 @@ protected:
bool findLibraries(bool linkPrl, bool mergeLflags) override;
QString escapeFilePath(const QString &path) const override;
- ProString escapeFilePath(const ProString &path) const { return MakefileGenerator::escapeFilePath(path); }
+ using MakefileGenerator::escapeFilePath;
QStringList &findDependencies(const QString &) override;
void init() override;
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 0412b52813..19975bc8bb 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -134,7 +134,7 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::
if (!dist_directory.startsWith(Option::dir_sep))
dist_directory.prepend(Option::dir_sep);
- QString out_directory_cdin = out_directory.isEmpty() ? "\n\t"
+ QString out_directory_cdin = out_directory.isEmpty() ? QString("\n\t")
: "\n\tcd " + escapeFilePath(out_directory) + " && ";
QString makefilein = " -e -f " + escapeFilePath(subtarget->makefile)
+ " distdir DISTDIR=$(DISTDIR)" + escapeFilePath(dist_directory);
@@ -749,7 +749,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
(!isShallowBundle
? (isFramework
? ("Versions/" + project->first("QMAKE_FRAMEWORK_VERSION") + "/Resources/")
- : "Contents/")
+ : QString("Contents/"))
: QString())
+ "Info.plist";
bundledFiles << info_plist_out;
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index 2fb24201bd..73e84a3269 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -86,8 +86,8 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t)
if (project->isActiveConfig("debug_info")) {
if (t == "dlltarget" || project->values(ProKey(t + ".CONFIG")).indexOf("no_dll") == -1) {
- const QFileInfo targetFileInfo = project->first("DESTDIR") + project->first("TARGET")
- + project->first("TARGET_EXT");
+ const QFileInfo targetFileInfo(project->first("DESTDIR") + project->first("TARGET")
+ + project->first("TARGET_EXT"));
const QString pdb_target = targetFileInfo.completeBaseName() + ".pdb";
QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + pdb_target;
QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + pdb_target, FileFixifyAbsolute));
@@ -245,8 +245,8 @@ void NmakeMakefileGenerator::init()
project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC);
}
- const QFileInfo targetFileInfo = project->first("DESTDIR") + project->first("TARGET")
- + project->first("TARGET_EXT");
+ const QFileInfo targetFileInfo(project->first("DESTDIR") + project->first("TARGET")
+ + project->first("TARGET_EXT"));
const ProString targetBase = targetFileInfo.path() + '/' + targetFileInfo.completeBaseName();
if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("shared")) {
project->values("QMAKE_CLEAN").append(targetBase + ".exp");
diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h
index 333f9ed889..09c5504fdf 100644
--- a/qmake/library/proitems.h
+++ b/qmake/library/proitems.h
@@ -70,9 +70,16 @@ public:
ProString();
ProString(const ProString &other);
ProString &operator=(const ProString &) = default;
- PROITEM_EXPLICIT ProString(const QString &str);
+ template<typename A, typename B>
+ ProString &operator=(const QStringBuilder<A, B> &str)
+ { return *this = QString(str); }
+ ProString(const QString &str);
PROITEM_EXPLICIT ProString(const QStringRef &str);
PROITEM_EXPLICIT ProString(const char *str);
+ template<typename A, typename B>
+ ProString(const QStringBuilder<A, B> &str)
+ : ProString(QString(str))
+ {}
ProString(const QString &str, int offset, int length);
void setValue(const QString &str);
void clear() { m_string.clear(); m_length = 0; }
@@ -83,12 +90,16 @@ public:
ProString &prepend(const ProString &other);
ProString &append(const ProString &other, bool *pending = nullptr);
ProString &append(const QString &other) { return append(ProString(other)); }
+ template<typename A, typename B>
+ ProString &append(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &append(const QLatin1String other);
ProString &append(const char *other) { return append(QLatin1String(other)); }
ProString &append(QChar other);
ProString &append(const ProStringList &other, bool *pending = nullptr, bool skipEmpty1st = false);
ProString &operator+=(const ProString &other) { return append(other); }
ProString &operator+=(const QString &other) { return append(other); }
+ template<typename A, typename B>
+ ProString &operator+=(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &operator+=(const QLatin1String other) { return append(other); }
ProString &operator+=(const char *other) { return append(other); }
ProString &operator+=(QChar other) { return append(other); }
@@ -123,9 +134,13 @@ public:
bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub, cs); }
bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(QLatin1String(sub), cs); }
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(c, cs); }
+ template<typename A, typename B>
+ bool startsWith(const QStringBuilder<A, B> &str) { return startsWith(QString(str)); }
bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub.toQStringRef(), cs); }
bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub, cs); }
bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(QLatin1String(sub), cs); }
+ template<typename A, typename B>
+ bool endsWith(const QStringBuilder<A, B> &str) { return endsWith(QString(str)); }
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(c, cs); }
int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(s, from, cs); }
int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(QLatin1String(s), from, cs); }
@@ -179,10 +194,15 @@ private:
};
Q_DECLARE_TYPEINFO(ProString, Q_MOVABLE_TYPE);
+
class ProKey : public ProString {
public:
ALWAYS_INLINE ProKey() : ProString() {}
explicit ProKey(const QString &str);
+ template<typename A, typename B>
+ ProKey(const QStringBuilder<A, B> &str)
+ : ProString(str)
+ {}
PROITEM_EXPLICIT ProKey(const char *str);
ProKey(const QString &str, int off, int len);
ProKey(const QString &str, int off, int len, uint hash);
@@ -206,31 +226,43 @@ private:
};
Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE);
+template <> struct QConcatenable<ProString> : private QAbstractConcatenable
+{
+ typedef ProString type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProString &a) { return a.length(); }
+ static inline void appendTo(const ProString &a, QChar *&out)
+ {
+ const auto n = a.size();
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
+
+template <> struct QConcatenable<ProKey> : private QAbstractConcatenable
+{
+ typedef ProKey type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProKey &a) { return a.length(); }
+ static inline void appendTo(const ProKey &a, QChar *&out)
+ {
+ const auto n = a.size();
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
+
+
size_t qHash(const ProString &str);
-QString operator+(const ProString &one, const ProString &two);
-inline QString operator+(const ProString &one, const QString &two)
- { return one.toQStringRef() + two; }
-inline QString operator+(const QString &one, const ProString &two)
- { return one + two.toQStringRef(); }
-
-inline QString operator+(const ProString &one, const char *two)
- { return one.toQStringRef() + QLatin1String(two); }
-inline QString operator+(const char *one, const ProString &two)
- { return QLatin1String(one) + two.toQStringRef(); }
-inline QString operator+(const ProString &one, QChar two)
- { return one.toQStringRef() + two; }
-inline QString operator+(QChar one, const ProString &two)
- { return one + two.toQStringRef(); }
inline QString &operator+=(QString &that, const ProString &other)
{ return that += other.toQStringRef(); }
-inline bool operator==(const QString &that, const ProString &other)
- { return other == that; }
-inline bool operator!=(const QString &that, const ProString &other)
- { return !(other == that); }
-
QTextStream &operator<<(QTextStream &t, const ProString &str);
+template<typename A, typename B>
+QTextStream &operator<<(QTextStream &t, const QStringBuilder<A, B> &str) { return t << QString(str); }
// This class manages read-only access to a ProString via a raw data QString
// temporary, ensuring that the latter is accessed exclusively.
@@ -296,6 +328,8 @@ public:
QString join(const ProString &sep) const;
QString join(const QString &sep) const;
QString join(QChar sep) const;
+ template<typename A, typename B>
+ QString join(const QStringBuilder<A, B> &str) { return join(QString(str)); }
void insertUnique(const ProStringList &value);
diff --git a/qmake/qmake.pro b/qmake/qmake.pro
index 53e0811098..d1532af0d2 100644
--- a/qmake/qmake.pro
+++ b/qmake/qmake.pro
@@ -10,6 +10,7 @@ DEFINES += \
PROEVALUATOR_FULL \
QT_BOOTSTRAPPED \
QT_BUILD_QMAKE \
+ QT_USE_QSTRINGBUILDER \
QT_NO_FOREACH \
$$shell_quote(QT_VERSION_STR=\"$$QT_VERSION\") \
QT_VERSION_MAJOR=$$QT_MAJOR_VERSION \
@@ -153,6 +154,7 @@ SOURCES += \
qromancalendar.cpp \
qsettings.cpp \
qstring.cpp \
+ qstringbuilder.cpp \
qstringlist.cpp \
qsystemerror.cpp \
qtemporaryfile.cpp \
@@ -209,6 +211,7 @@ HEADERS += \
qregexp.h \
qromancalendar_p.h \
qstring.h \
+ qstringbuilder.h \
qstringlist.h \
qstringmatcher.h \
qsystemerror_p.h \
diff --git a/tests/auto/tools/qmakelib/CMakeLists.txt b/tests/auto/tools/qmakelib/CMakeLists.txt
index 1e56c81e77..abb8e62c95 100644
--- a/tests/auto/tools/qmakelib/CMakeLists.txt
+++ b/tests/auto/tools/qmakelib/CMakeLists.txt
@@ -21,6 +21,7 @@ add_qt_test(tst_qmakelib
PROEVALUATOR_FULL
PROEVALUATOR_SETENV
PROPARSER_DEBUG
+ QT_USE_QSTRINGBUILDER
INCLUDE_DIRECTORIES
../../../../qmake/library
)
diff --git a/tests/auto/tools/qmakelib/qmakelib.pro b/tests/auto/tools/qmakelib/qmakelib.pro
index 5e9e9fe637..0e39d3115e 100644
--- a/tests/auto/tools/qmakelib/qmakelib.pro
+++ b/tests/auto/tools/qmakelib/qmakelib.pro
@@ -22,4 +22,4 @@ SOURCES += \
qmakebuiltins.cpp \
qmakeevaluator.cpp
-DEFINES += PROPARSER_DEBUG PROEVALUATOR_FULL PROEVALUATOR_SETENV
+DEFINES += PROPARSER_DEBUG PROEVALUATOR_FULL PROEVALUATOR_SETENV QT_USE_QSTRINGBUILDER