summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-09-18 10:44:21 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-11-30 15:22:01 +0100
commit763c4ca7255dc7f4536b83e8e5e524f0c99e8caf (patch)
tree124605908f69decad5724ff561d4b441ced1be3e /qmake
parent6c6a6f4aa9f97e5edad8592e3e8e939db2755dc4 (diff)
Add new way to mess up projects with QMAKE_INSTALL_REPLACE
Qmake supports currently: * QMAKE_PRL_INSTALL_REPLACE, * QMAKE_LIBTOOL_INSTALL_REPLACE * QMAKE_PKGCCONFIG_INSTALL_REPLACE Introduce QMAKE_INSTALL_REPLACE, where more sed magic can be put in action in more generic manner. replace_foo.filename = foo.h replace_foo.matches = /bad/looking/path/to/foo replace_foo.replace = /awesome/looking/path/to/foo QMAKE_INSTALL_REPLACE += replace_foo Task-number: QTBUG-87154 Change-Id: Ie43d0ab4f1d4575bbf6279eb36383f38047484d9 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 632da28e9ca1d67639f60e4c20ca54b38ae10dcd)
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/makefile.cpp17
-rw-r--r--qmake/generators/makefile.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 41df1ef4bb..a901332312 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1286,7 +1286,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
else
cmd = QLatin1String("$(QINSTALL)");
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
- inst << cmd;
+
+ QString sedArgs = createSedArgs(ProKey("QMAKE_INSTALL_REPLACE"), fi.fileName());
+ if (!sedArgs.isEmpty())
+ inst << "$(SED) " + sedArgs + ' ' + escapeFilePath(wild) + " > "
+ + escapeFilePath(dst_file);
+ else
+ inst << cmd;
+
if (!noStrip && !project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") &&
!fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
inst << QString("-") + var("QMAKE_STRIP") + " " +
@@ -3412,15 +3419,17 @@ static QString windowsifyPath(const QString &str)
return QString(str).replace('/', QLatin1String("\\\\\\\\"));
}
-QString MakefileGenerator::createSedArgs(const ProKey &replace_rule) const
+QString MakefileGenerator::createSedArgs(const ProKey &replace_rule, const QString &file_name) const
{
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"));
- if (!match.isEmpty() /*&& match != replace*/) {
+ replace = project->first(ProKey(replace_rules.at(r) + ".replace")),
+ filename = project->first(ProKey(replace_rules.at(r) + ".filename"));
+ if (!match.isEmpty() /*&& match != replace*/
+ && (filename.isEmpty() || filename == file_name)) {
sedargs += " -e " + shellQuote("s," + match + "," + replace + ",g");
if (isWindowsShell()
&& project->first(ProKey(replace_rules.at(r) + ".CONFIG")).contains("path"))
diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h
index 0f193298be..dc612c392c 100644
--- a/qmake/generators/makefile.h
+++ b/qmake/generators/makefile.h
@@ -251,7 +251,7 @@ 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 createSedArgs(const ProKey &replace_rule) const;
+ QString createSedArgs(const ProKey &replace_rule, const QString &file_type = QString()) const;
QString installMetaFile(const ProKey &replace_rule, const QString &src,
const QString &dst) const;