summaryrefslogtreecommitdiff
path: root/qmake
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-09-18 09:06:01 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-11-30 11:07:13 +0100
commitfdfa34f4b21dc7908223ee6508ecd778f7504c70 (patch)
tree34b8cc416947bf21bce343186cf051181e0eca44 /qmake
parent61281b928bf5f2d228fb810af38bba71032f63a6 (diff)
downloadqtbase-fdfa34f4b21dc7908223ee6508ecd778f7504c70.tar.gz
Minor refactor of installMetaFile
Move some lines into createSedArgs. This is used in follow up patch. Task-number: QTBUG-87154 Change-Id: I226f4aad4aaf703a4726c42b40afb4bde3a9d878 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 9bade12c2ca78a2dc5effda568342ae11adb0f42) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/makefile.cpp40
-rw-r--r--qmake/generators/makefile.h7
2 files changed, 27 insertions, 20 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 5c61a3c65c..41df1ef4bb 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -3412,35 +3412,41 @@ static QString windowsifyPath(const QString &str)
return QString(str).replace('/', QLatin1String("\\\\\\\\"));
}
-QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QString &src, const QString &dst)
+QString MakefileGenerator::createSedArgs(const ProKey &replace_rule) const
{
- QString ret;
- if (project->isEmpty(replace_rule)
- || project->isActiveConfig("no_sed_meta_install")) {
- ret += "$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst);
- } else {
- QString sedargs;
+ QString sedargs;
+ if (!project->isEmpty(replace_rule) && !project->isActiveConfig("no_sed_meta_install")) {
const ProStringList &replace_rules = project->values(replace_rule);
for (int r = 0; r < replace_rules.size(); ++r) {
const ProString match = project->first(ProKey(replace_rules.at(r) + ".match")),
- replace = project->first(ProKey(replace_rules.at(r) + ".replace"));
+ replace = project->first(ProKey(replace_rules.at(r) + ".replace"));
if (!match.isEmpty() /*&& match != replace*/) {
sedargs += " -e " + shellQuote("s," + match + "," + replace + ",g");
- if (isWindowsShell() && project->first(ProKey(replace_rules.at(r) + ".CONFIG")).contains("path"))
- sedargs += " -e " + shellQuote("s," + windowsifyPath(match.toQString())
- + "," + windowsifyPath(replace.toQString()) + ",gi");
+ if (isWindowsShell()
+ && project->first(ProKey(replace_rules.at(r) + ".CONFIG")).contains("path"))
+ sedargs += " -e "
+ + shellQuote("s," + windowsifyPath(match.toQString()) + ","
+ + windowsifyPath(replace.toQString()) + ",gi");
}
}
- if (sedargs.isEmpty()) {
- ret += "$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst);
- } else {
- ret += "$(SED) " + sedargs + ' ' + escapeFilePath(src) + " > " + escapeFilePath(dst);
- }
+ }
+ return sedargs;
+}
+
+QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QString &src,
+ const QString &dst) const
+{
+ QString ret;
+ QString sedargs = createSedArgs(replace_rule);
+ if (sedargs.isEmpty()) {
+ ret = "$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst);
+ } else {
+ ret = "$(SED) " + sedargs + ' ' + escapeFilePath(src) + " > " + escapeFilePath(dst);
}
return ret;
}
-QString MakefileGenerator::shellQuote(const QString &str)
+QString MakefileGenerator::shellQuote(const QString &str) const
{
return isWindowsShell() ? IoUtils::shellQuoteWin(str) : IoUtils::shellQuoteUnix(str);
}
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index a96b9c54da..0f193298be 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -251,8 +251,9 @@ public:
protected:
QString fileFixify(const QString &file, FileFixifyTypes fix = FileFixifyDefault, bool canon = true) const;
QStringList fileFixify(const QStringList &files, FileFixifyTypes fix = FileFixifyDefault, bool canon = true) const;
-
- QString installMetaFile(const ProKey &replace_rule, const QString &src, const QString &dst);
+ QString createSedArgs(const ProKey &replace_rule) const;
+ QString installMetaFile(const ProKey &replace_rule, const QString &src,
+ const QString &dst) const;
virtual bool processPrlFileBase(QString &origFile, const QStringRef &origName,
const QStringRef &fixedBase, int slashOff);
@@ -278,7 +279,7 @@ public:
virtual bool mergeBuildProject(MakefileGenerator * /*other*/) { return false; }
virtual bool openOutput(QFile &, const QString &build) const;
bool isWindowsShell() const { return Option::dir_sep == QLatin1String("\\"); }
- QString shellQuote(const QString &str);
+ QString shellQuote(const QString &str) const;
virtual ProKey fullTargetVariable() const;
};
Q_DECLARE_TYPEINFO(MakefileGenerator::Compiler, Q_MOVABLE_TYPE);