From f384c3097911c523e67620b77b1086e4788cd209 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 19 Jan 2016 10:55:32 +0300 Subject: QMake: replace QStringLiteral with QLatin1String ... in string comparisons. It's more efficient. Change-Id: I5d54ab7777a0838455eaaac671e735eb37bfe243 Reviewed-by: Oswald Buddenhagen --- qmake/generators/mac/pbuilder_pbx.cpp | 6 +++--- qmake/generators/win32/cesdkhandler.cpp | 10 +++++----- qmake/generators/win32/msbuild_objectmodel.cpp | 4 ++-- qmake/generators/win32/msvc_nmake.cpp | 4 ++-- qmake/generators/win32/msvc_vcproj.cpp | 2 +- qmake/library/qmakeevaluator.cpp | 2 +- qmake/main.cpp | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 42dd6c8aeb..ef9aa9a2e6 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -498,11 +498,11 @@ static QString xcodeFiletypeForFilename(const QString &filename) return QStringLiteral("sourcecode.cpp.objcpp"); if (filename.endsWith(Option::objc_ext)) return QStringLiteral("sourcecode.c.objc"); - if (filename.endsWith(QStringLiteral(".framework"))) + if (filename.endsWith(QLatin1String(".framework"))) return QStringLiteral("wrapper.framework"); - if (filename.endsWith(QStringLiteral(".a"))) + if (filename.endsWith(QLatin1String(".a"))) return QStringLiteral("archive.ar"); - if (filename.endsWith(QStringLiteral(".pro")) || filename.endsWith(QStringLiteral(".qrc"))) + if (filename.endsWith(QLatin1String(".pro")) || filename.endsWith(QLatin1String(".qrc"))) return QStringLiteral("text"); return QString(); diff --git a/qmake/generators/win32/cesdkhandler.cpp b/qmake/generators/win32/cesdkhandler.cpp index f8235bae27..4550cc8aed 100644 --- a/qmake/generators/win32/cesdkhandler.cpp +++ b/qmake/generators/win32/cesdkhandler.cpp @@ -63,8 +63,8 @@ struct ContainsPathKey { bool operator()(const QString &val) const { - return !(val.endsWith(QStringLiteral("MSBuildToolsPath")) - || val.endsWith(QStringLiteral("MSBuildToolsRoot"))); + return !(val.endsWith(QLatin1String("MSBuildToolsPath")) + || val.endsWith(QLatin1String("MSBuildToolsRoot"))); } }; @@ -141,7 +141,7 @@ bool CeSdkHandler::parseMsBuildFile(QFile *file, CeSdkInfo *info) if (success) { const QString startPattern = QStringLiteral("$(Registry:"); const int startIndex = sdkRootPath.indexOf(startPattern); - const int endIndex = sdkRootPath.lastIndexOf(QStringLiteral(")")); + const int endIndex = sdkRootPath.lastIndexOf(QLatin1Char(')')); const QString regString = sdkRootPath.mid(startIndex + startPattern.size(), endIndex - startIndex - startPattern.size()); QSettings sdkRootPathRegistry(regString, QSettings::NativeFormat); @@ -180,7 +180,7 @@ QStringList CeSdkHandler::filterMsBuildToolPaths(const QStringList &paths) const QStringList result; foreach (const QString &path, paths) { QDir dirVC110(path); - if (path.endsWith(QStringLiteral("bin"))) + if (path.endsWith(QLatin1String("bin"))) dirVC110.cdUp(); QDir dirVC120 = dirVC110; if (dirVC110.cd(QStringLiteral("Microsoft.Cpp\\v4.0\\V110\\Platforms"))) @@ -279,7 +279,7 @@ void CeSdkHandler::retrieveWEC2013SDKs() if (cpuInfo.properties.isEmpty()) continue; const PropertyContainer &cpuInfoVal = cpuInfo.properties.first().properties.value(QLatin1String("CpuName")); - if (cpuInfoVal.name != QStringLiteral("CpuName")) + if (cpuInfoVal.name != QLatin1String("CpuName")) continue; const QString SDKName = QStringLiteral("SDK name"); currentSdk.m_name = currentProperty.properties.value(SDKName).value+ diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 8e2be589cd..bcfab80ccf 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -608,8 +608,8 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) xml.setIndentString(" "); - const QString toolsVersion = (tool.SdkVersion == QStringLiteral("10.0")) ? QStringLiteral("14.0") - : QStringLiteral("4.0"); + const QString toolsVersion = (tool.SdkVersion == QLatin1String("10.0")) ? QStringLiteral("14.0") + : QStringLiteral("4.0"); xml << decl("1.0", "utf-8") << tag("Project") diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index d6753b4ed6..7499d76e75 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -110,10 +110,10 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); QString compiler; QString compilerArch; - if (arch == QStringLiteral("arm")) { + if (arch == QLatin1String("arm")) { compiler = QStringLiteral("x86_arm"); compilerArch = QStringLiteral("arm"); - } else if (arch == QStringLiteral("x64")) { + } else if (arch == QLatin1String("x64")) { const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); if (hostArch.contains("x86_64")) compiler = QStringLiteral("amd64"); diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 465c8fc312..c900cafbf2 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1199,7 +1199,7 @@ void VcprojGenerator::initResourceTool() foreach (const ProString &path, project->values("RC_INCLUDEPATH")) { QString fixedPath = fileFixify(path.toQString()); if (fileInfo(fixedPath).isRelative()) { - if (fixedPath == QStringLiteral(".")) + if (fixedPath == QLatin1String(".")) fixedPath = QStringLiteral("$(ProjectDir)"); else fixedPath.prepend(QStringLiteral("$(ProjectDir)\\")); diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 4c5ce2e097..e9da45c14d 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -957,7 +957,7 @@ static ProString msvcBinDirToQMakeArch(QString subdir) if (idx >= 0) subdir.remove(0, idx + 1); subdir = subdir.toLower(); - if (subdir == QStringLiteral("amd64")) + if (subdir == QLatin1String("amd64")) return ProString("x86_64"); return ProString(subdir); } diff --git a/qmake/main.cpp b/qmake/main.cpp index bde537dcca..5f848d4820 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -309,8 +309,8 @@ int runQMake(int argc, char **argv) dir = tmp_dir; } #ifdef Q_OS_MAC - if (fi.fileName().endsWith(QStringLiteral(".pbxproj")) - && dir.endsWith(QStringLiteral(".xcodeproj"))) + if (fi.fileName().endsWith(QLatin1String(".pbxproj")) + && dir.endsWith(QLatin1String(".xcodeproj"))) dir += QStringLiteral("/.."); #endif if(!dir.isNull() && dir != ".") -- cgit v1.2.3 From f33c6f37a8226c67a199181a8721f09983089448 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 14 Jan 2016 13:01:39 +0100 Subject: Work around MinGW-make's magic prefixing of paths. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building QNX on MS-Windows, make magically adds the Msys root as prefix to variables whose values look like paths; this applies to both environment variables and variables given values on the command-line. When we don't actually want to install under the Msys root, this is unwelcome "help". So (for MinGW's make) support a magic prefix of our own, @msyshack@, that'll make a path value for INSTALL_ROOT not look like a path to make; we can then strip it off when we come to use it. Change-Id: I951ad3c8fe3e5cfb49e6e361d7fff779f3a9d716 Reviewed-by: Jędrzej Nowacki Reviewed-by: Oswald Buddenhagen Reviewed-by: Frederik Gladhorn --- qmake/generators/makefile.cpp | 2 +- qmake/generators/makefile.h | 4 ++++ qmake/generators/unix/unixmake.cpp | 16 +++++++++++++++- qmake/generators/unix/unixmake.h | 3 +++ qmake/generators/win32/mingw_make.cpp | 12 ++++++++++++ qmake/generators/win32/mingw_make.h | 1 + qmake/generators/win32/msvc_nmake.cpp | 2 +- qmake/generators/win32/winmakefile.cpp | 2 +- 8 files changed, 38 insertions(+), 4 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index a54083c04d..4dfe69fbde 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1212,7 +1212,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) } bool do_default = true; - const QString root = "$(INSTALL_ROOT)"; + const QString root = installRoot(); QString dst; if (installConfigValues.indexOf("no_path") == -1 && installConfigValues.indexOf("dummy_install") == -1) { diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h index 97159eaef4..19ff5d57a3 100644 --- a/qmake/generators/makefile.h +++ b/qmake/generators/makefile.h @@ -192,6 +192,7 @@ protected: //for installs virtual QString defaultInstall(const QString &); + virtual QString installRoot() const; //for prl QString prlFileName(bool fixify=true); @@ -277,6 +278,9 @@ inline bool MakefileGenerator::noIO() const inline QString MakefileGenerator::defaultInstall(const QString &) { return QString(""); } +inline QString MakefileGenerator::installRoot() const +{ return QStringLiteral("$(INSTALL_ROOT)"); } + inline bool MakefileGenerator::findLibraries(bool, bool) { return true; } diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 57c0a97228..12b9f09edd 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -514,6 +514,20 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) return false; } +#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 + QString UnixMakefileGenerator::defaultInstall(const QString &t) { @@ -522,7 +536,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) enum { NoBundle, SolidBundle, SlicedBundle } bundle = NoBundle; bool isAux = (project->first("TEMPLATE") == "aux"); - const QString root = "$(INSTALL_ROOT)"; + const QString root = installRoot(); ProStringList &uninst = project->values(ProKey(t + ".uninstall")); QString ret, destdir = project->first("DESTDIR").toQString(); if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) diff --git a/qmake/generators/unix/unixmake.h b/qmake/generators/unix/unixmake.h index db3f59f517..17270ffce9 100644 --- a/qmake/generators/unix/unixmake.h +++ b/qmake/generators/unix/unixmake.h @@ -52,6 +52,9 @@ public: protected: virtual bool doPrecompiledHeaders() const { return project->isActiveConfig("precompile_header"); } virtual bool doDepends() const { return !Option::mkfile::do_stub_makefile && MakefileGenerator::doDepends(); } +#ifdef Q_OS_WIN // MinGW x-compiling for QNX + virtual QString installRoot() const; +#endif virtual QString defaultInstall(const QString &); virtual ProString fixLibFlag(const ProString &lib); diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 97bfef88a4..1837c6c0cf 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -112,6 +112,18 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t) return false; } +QString MingwMakefileGenerator::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@%=%)"); +} + void createLdObjectScriptFile(const QString &fileName, const ProStringList &objList) { QString filePath = Option::output_dir + QDir::separator() + fileName; diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h index 4e94a23ae2..1525f04955 100644 --- a/qmake/generators/win32/mingw_make.h +++ b/qmake/generators/win32/mingw_make.h @@ -50,6 +50,7 @@ protected: virtual QString getManifestFileForRcFile() const; bool writeMakefile(QTextStream &); void init(); + virtual QString installRoot() const; private: void writeMingwParts(QTextStream &); void writeIncPart(QTextStream &t); diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 7499d76e75..27427db68b 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -268,7 +268,7 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t) QString ret = Win32MakefileGenerator::defaultInstall(t); - const QString root = "$(INSTALL_ROOT)"; + const QString root = installRoot(); ProStringList &uninst = project->values(ProKey(t + ".uninstall")); QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute); if(targetdir.right(1) != Option::dir_sep) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 1fba7057ab..a042cb0d4b 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -689,7 +689,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t) project->first("TEMPLATE") == "subdirs" || project->first("TEMPLATE") == "aux") return QString(); - const QString root = "$(INSTALL_ROOT)"; + const QString root = installRoot(); ProStringList &uninst = project->values(ProKey(t + ".uninstall")); QString ret; QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute); -- cgit v1.2.3 From a01146aac104b05dcf5c7ddbe7b79a897e8bf414 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Tue, 19 Jan 2016 14:22:28 +0100 Subject: Use QFileInfo::exists(f) instead of QFileInfo(f).exists() QFileInfo::exists(f) is somewhat faster than the version which creates an temporary object. Change-Id: I5f931a86d9dfad57d99efe04ca115422de43def9 Reviewed-by: Thiago Macieira --- qmake/generators/win32/msvc_vcproj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index c900cafbf2..a1a8407a11 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1334,7 +1334,7 @@ void VcprojGenerator::initDeploymentTool() if (!vcInstallDir.isEmpty()) { vcInstallDir += "\\ce\\dll\\"; vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' ')); - if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) + if (!QFileInfo::exists(vcInstallDir + QDir::separator() + runtimeVersion)) runtime.clear(); else runtime = vcInstallDir; -- cgit v1.2.3