diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-09-04 14:33:40 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-09-04 14:33:40 +0200 |
commit | f255b1e8e297e7e1363921580007145cff574e0d (patch) | |
tree | 9a799be282e6c0d6544d9f8c872073f83e6c0475 /qmake/generators/metamakefile.cpp | |
parent | 7e8705f6632428a8d9a937ab5fe087999347b3dd (diff) | |
parent | bf8fcab8bb92ff534c5cec048d6dbebb3b73a348 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/qt6
Change-Id: I54741635460bb2d8f3fd0be535ee1968d6c442bb
Diffstat (limited to 'qmake/generators/metamakefile.cpp')
-rw-r--r-- | qmake/generators/metamakefile.cpp | 39 |
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: |