From 33fea7e7a9155632f7ac3804a1a6d1d35324b6d0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Jun 2018 16:00:44 +0200 Subject: qmake: use consistent path separators in makefile dependencies Task-number: QTBUG-65072 Change-Id: I3456d9b2cdfa9c65be5933f592abb640f81c39f2 Reviewed-by: Liang Qi Reviewed-by: Joerg Bornemann --- qmake/generators/makefile.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'qmake/generators/makefile.cpp') diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 99aecdd8ce..dda323535d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1141,7 +1141,7 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src) QString srcf = (*sit).toQString(); QString dstf = (*oit).toQString(); t << escapeDependencyPath(dstf) << ": " << escapeDependencyPath(srcf) - << " " << escapeDependencyPaths(findDependencies(srcf)).join(" \\\n\t\t"); + << " " << finalizeDependencyPaths(findDependencies(srcf)).join(" \\\n\t\t"); ProKey comp; for (const ProString &compiler : project->values("QMAKE_BUILTIN_COMPILERS")) { @@ -2013,7 +2013,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) if (config.indexOf("explicit_dependencies") != -1) { t << " " << valList(escapeDependencyPaths(fileFixify(tmp_dep, FileFixifyFromOutdir))); } else { - t << " " << valList(escapeDependencyPaths(inputs)) << " " << valList(escapeDependencyPaths(deps)); + t << " " << valList(escapeDependencyPaths(inputs)) << " " << valList(finalizeDependencyPaths(deps)); } t << "\n\t" << cmd << endl << endl; continue; @@ -2133,7 +2133,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) else ++i; } - t << escapeDependencyPath(out) << ": " << valList(escapeDependencyPaths(deps)) << "\n\t" + t << escapeDependencyPath(out) << ": " << valList(finalizeDependencyPaths(deps)) << "\n\t" << cmd << endl << endl; } } @@ -2851,6 +2851,17 @@ MakefileGenerator::escapeDependencyPaths(const ProStringList &paths) const return ret; } +QStringList +MakefileGenerator::finalizeDependencyPaths(const QStringList &paths) const +{ + QStringList ret; + const int size = paths.size(); + ret.reserve(size); + for (int i = 0; i < size; ++i) + ret.append(escapeDependencyPath(Option::fixPathToTargetOS(paths.at(i), false))); + return ret; +} + QStringList MakefileGenerator::fileFixify(const QStringList &files, FileFixifyTypes fix, bool canon) const { -- cgit v1.2.3 From 7c34e0a7b48572be1f9e3fb45911a13b01798e37 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Jun 2018 21:18:11 +0200 Subject: qmake: escape colons and hashmarks in dependency paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit these characters can appear in file names, but are meta characters in dependency context. they have different semantics in make commands, so this required some reshuffling in the windows generator (which just treated dependencies and commands the same way). we don't actually escape colons for nmake, because it has magic treatment of drive letters anyway (and colons cannot appear elsewhere). also, if a target's filename gets quoted, batch rules will blow up. therefore, "funny" file names are really only supported as inputs - which is just enough to make resource embedding work. Task-number: QTBUG-22863 Task-number: QTBUG-68635 Change-Id: I473b0bf47d045298fd2ae481a29de603a3c1be30 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Joerg Bornemann --- qmake/generators/makefile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'qmake/generators/makefile.cpp') diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index dda323535d..580df85c1e 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2823,6 +2823,19 @@ MakefileGenerator::escapeFilePaths(const ProStringList &paths) const return ret; } +QString +MakefileGenerator::escapeDependencyPath(const QString &path) const +{ + QString ret = path; + if (!ret.isEmpty()) { + // Unix make semantics, to be inherited by unix and mingw generators. + static const QRegExp criticalChars(QStringLiteral("([\t :#])")); + ret.replace(criticalChars, QStringLiteral("\\\\1")); + debug_msg(2, "escapeDependencyPath: %s -> %s", path.toLatin1().constData(), ret.toLatin1().constData()); + } + return ret; +} + ProString MakefileGenerator::escapeDependencyPath(const ProString &path) const { -- cgit v1.2.3