summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2019-05-24 11:29:03 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2019-05-24 11:34:32 +0200
commit9f77c9152220abb26a4d6a9dfa46fec7f87d60e6 (patch)
tree3144a6e87348dbb5bc6c611b97f1bab2f1e37ff2
parentc034544767965be3e66b25b46fa9378e43e60395 (diff)
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 <christian.kandeler@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--qmake/generators/makefile.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 6a6cb24441..bf8eb3f5da 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<MakefileGenerator::SubTarget*> targets, int flags)
{
@@ -2523,6 +2533,14 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT
<< QString((flags & SubTargetInstalls) ? "uninstall_subtargets" : "uninstall");
}
+ struct SequentialInstallData
+ {
+ QString targetPrefix;
+ QString commands;
+ QTextStream commandsStream;
+ SequentialInstallData() : commandsStream(&commands) {}
+ };
+ std::unique_ptr<SequentialInstallData> sequentialInstallData;
bool dont_recurse = project->isActiveConfig("dont_recurse");
// generate target rules
@@ -2591,6 +2609,16 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT
else if(s == "make_first")
s = QString();
+ if (project->isActiveConfig("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, QList<MakefileGenerator::SubT
}
t << Qt::endl;
+ if (sequentialInstallData) {
+ t << sequentialInstallData->targetPrefix << "install: FORCE"
+ << sequentialInstallData->commands << Qt::endl << Qt::endl;
+ }
+
if (!(flags & SubTargetSkipDefaultTargets)) {
writeMakeQmake(t, true);