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>
This commit is contained in:
Lars Knoll 2020-04-03 11:49:27 +02:00
parent ae7e701074
commit 52f3a7d9d4
14 changed files with 80 additions and 36 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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);
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(); }
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;
}
};
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(); }
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);
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);

View File

@ -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 \

View File

@ -21,6 +21,7 @@ add_qt_test(tst_qmakelib
PROEVALUATOR_FULL
PROEVALUATOR_SETENV
PROPARSER_DEBUG
QT_USE_QSTRINGBUILDER
INCLUDE_DIRECTORIES
../../../../qmake/library
)

View File

@ -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