summaryrefslogtreecommitdiffstats
path: root/qmake/generators/metamakefile.cpp
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-09-04 14:33:40 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-09-04 14:33:40 +0200
commitf255b1e8e297e7e1363921580007145cff574e0d (patch)
tree9a799be282e6c0d6544d9f8c872073f83e6c0475 /qmake/generators/metamakefile.cpp
parent7e8705f6632428a8d9a937ab5fe087999347b3dd (diff)
parentbf8fcab8bb92ff534c5cec048d6dbebb3b73a348 (diff)
Merge remote-tracking branch 'origin/dev' into wip/qt6
Diffstat (limited to 'qmake/generators/metamakefile.cpp')
-rw-r--r--qmake/generators/metamakefile.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp
index 705ad7008a..22a72100f7 100644
--- a/qmake/generators/metamakefile.cpp
+++ b/qmake/generators/metamakefile.cpp
@@ -33,6 +33,10 @@
#include "project.h"
#include "cachekeys.h"
+#include <algorithm>
+#include <iterator>
+#include <utility>
+
#define BUILDSMETATYPE 1
#define SUBDIRSMETATYPE 2
@@ -58,6 +62,7 @@ private:
void clearBuilds();
MakefileGenerator *processBuild(const ProString &);
void accumulateVariableFromBuilds(const ProKey &name, Build *build) const;
+ void checkForConflictingTargets() const;
public:
@@ -186,6 +191,7 @@ BuildsMetaMakefileGenerator::write()
if(!build->makefile) {
ret = false;
} else if(build == glue) {
+ checkForConflictingTargets();
accumulateVariableFromBuilds("QMAKE_INTERNAL_INCLUDED_FILES", build);
ret = build->makefile->writeProjectMakefile();
} else {
@@ -239,6 +245,39 @@ void BuildsMetaMakefileGenerator::accumulateVariableFromBuilds(const ProKey &nam
values.removeDuplicates();
}
+void BuildsMetaMakefileGenerator::checkForConflictingTargets() const
+{
+ if (makefiles.count() < 3) {
+ // Checking for conflicts only makes sense if we have more than one BUILD,
+ // and the last entry in makefiles is the "glue" Build.
+ return;
+ }
+ using TargetInfo = std::pair<Build *, ProString>;
+ QVector<TargetInfo> targets;
+ const int last = makefiles.count() - 1;
+ targets.resize(last);
+ for (int i = 0; i < last; ++i) {
+ Build *b = makefiles.at(i);
+ auto mkf = b->makefile;
+ auto prj = mkf->projectFile();
+ targets[i] = std::make_pair(b, prj->first(mkf->fullTargetVariable()));
+ }
+ std::stable_sort(targets.begin(), targets.end(),
+ [](const TargetInfo &lhs, const TargetInfo &rhs)
+ {
+ return lhs.second < rhs.second;
+ });
+ for (auto prev = targets.begin(), it = std::next(prev); it != targets.end(); ++prev, ++it) {
+ if (prev->second == it->second) {
+ warn_msg(WarnLogic, "Targets of builds '%s' and '%s' conflict: %s.",
+ qPrintable(prev->first->build),
+ qPrintable(it->first->build),
+ qPrintable(prev->second.toQString()));
+ break;
+ }
+ }
+}
+
class SubdirsMetaMakefileGenerator : public MetaMakefileGenerator
{
protected: