From 9f77c9152220abb26a4d6a9dfa46fec7f87d60e6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 24 May 2019 11:29:03 +0200 Subject: [PATCH] Sequentialize install targets in debug_and_release builds Debug/release install targets can potentially install the same files which leads to errors on install when running make with -j > 1. If build_all is set, make the 'install' dependent of the new target 'debug-release-install' which contains the commands of 'debug-install' and 'release-install'. Of course, debug/release is not hard-coded, but the content of the BUILDS variable is used. Change-Id: I67b504a95b83daf43bc89dcc0e3391b67e19c027 Reviewed-by: Christian Kandeler Reviewed-by: Simon Hausmann --- qmake/generators/makefile.cpp | 39 ++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 6a6cb244415..bf8eb3f5daf 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1046,9 +1046,9 @@ MakefileGenerator::writeProjectMakefile() //install t << "install: "; - for(it = targets.begin(); it != targets.end(); ++it) - t << (*it)->target << "-install "; - t << Qt::endl; + for (SubTarget *s : qAsConst(targets)) + t << s->target << '-'; + t << "install " << Qt::endl; //uninstall t << "uninstall: "; @@ -2498,6 +2498,16 @@ MakefileGenerator::writeSubTargetCall(QTextStream &t, writeSubMakeCall(t, out_directory_cdin + pfx, makefilein); } +static void chopEndLines(QString *s) +{ + while (!s->isEmpty()) { + const ushort c = s->at(s->size() - 1).unicode(); + if (c != '\n' && c != '\r') + break; + s->chop(1); + } +} + void MakefileGenerator::writeSubTargets(QTextStream &t, QList targets, int flags) { @@ -2523,6 +2533,14 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList sequentialInstallData; bool dont_recurse = project->isActiveConfig("dont_recurse"); // generate target rules @@ -2591,6 +2609,16 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListisActiveConfig("build_all") && s == "install") { + if (!sequentialInstallData) + sequentialInstallData.reset(new SequentialInstallData); + sequentialInstallData->targetPrefix += subtarget->target + '-'; + writeSubTargetCall(sequentialInstallData->commandsStream, in_directory, in, + out_directory, out, out_directory_cdin, + makefilein + " " + s); + chopEndLines(&sequentialInstallData->commands); + } + if(flags & SubTargetOrdered) { t << subtarget->target << "-" << targetSuffixes.at(suffix) << "-ordered:"; if(target) @@ -2610,6 +2638,11 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListtargetPrefix << "install: FORCE" + << sequentialInstallData->commands << Qt::endl << Qt::endl; + } + if (!(flags & SubTargetSkipDefaultTargets)) { writeMakeQmake(t, true);