diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-08-30 21:13:10 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-09-07 15:53:19 (GMT) |
commit | d8d064abbc10239cf61655da31d3e6a4a46298e7 (patch) | |
tree | bccc6ce5924ba62aa1e249eabb3a5a8389648206 /Source/cmQtAutoGen.cxx | |
parent | 37714f884be3c37fbbcbf7bbef0ceb3b44cc5961 (diff) | |
download | CMake-d8d064abbc10239cf61655da31d3e6a4a46298e7.zip CMake-d8d064abbc10239cf61655da31d3e6a4a46298e7.tar.gz CMake-d8d064abbc10239cf61655da31d3e6a4a46298e7.tar.bz2 |
Autogen: Use the same algorithm for RCC and UIC option merging
Diffstat (limited to 'Source/cmQtAutoGen.cxx')
-rw-r--r-- | Source/cmQtAutoGen.cxx | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 98dbdd2..cdd41ca 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -7,6 +7,7 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" +#include <algorithm> #include <sstream> #include <stddef.h> @@ -19,6 +20,60 @@ const std::string genNameRcc = "AutoRcc"; // - Static functions +/// @brief Merges newOpts into baseOpts +/// @arg valueOpts list of options that accept a value +void MergeOptions(std::vector<std::string>& baseOpts, + const std::vector<std::string>& newOpts, + const std::vector<std::string>& valueOpts, bool isQt5) +{ + typedef std::vector<std::string>::iterator Iter; + typedef std::vector<std::string>::const_iterator CIter; + if (newOpts.empty()) { + return; + } + if (baseOpts.empty()) { + baseOpts = newOpts; + return; + } + + std::vector<std::string> extraOpts; + for (CIter fit = newOpts.begin(), fitEnd = newOpts.end(); fit != fitEnd; + ++fit) { + const std::string& newOpt = *fit; + Iter existIt = std::find(baseOpts.begin(), baseOpts.end(), newOpt); + if (existIt != baseOpts.end()) { + if (newOpt.size() >= 2) { + // Acquire the option name + std::string optName; + { + auto oit = newOpt.begin(); + if (*oit == '-') { + ++oit; + if (isQt5 && (*oit == '-')) { + ++oit; + } + optName.assign(oit, newOpt.end()); + } + } + // Test if this is a value option and change the existing value + if (!optName.empty() && (std::find(valueOpts.begin(), valueOpts.end(), + optName) != valueOpts.end())) { + const Iter existItNext(existIt + 1); + const CIter fitNext(fit + 1); + if ((existItNext != baseOpts.end()) && (fitNext != fitEnd)) { + *existItNext = *fitNext; + ++fit; + } + } + } + } else { + extraOpts.push_back(newOpt); + } + } + // Append options + baseOpts.insert(baseOpts.end(), extraOpts.begin(), extraOpts.end()); +} + static std::string utilStripCR(std::string const& line) { // Strip CR characters rcc may have printed (possibly more than one!). @@ -218,6 +273,28 @@ std::string cmQtAutoGen::Quoted(const std::string& text) return res; } +void cmQtAutoGen::UicMergeOptions(std::vector<std::string>& baseOpts, + const std::vector<std::string>& newOpts, + bool isQt5) +{ + static const std::vector<std::string> valueOpts = { + "tr", "translate", "postfix", "generator", + "include", // Since Qt 5.3 + "g" + }; + MergeOptions(baseOpts, newOpts, valueOpts, isQt5); +} + +void cmQtAutoGen::RccMergeOptions(std::vector<std::string>& baseOpts, + const std::vector<std::string>& newOpts, + bool isQt5) +{ + static const std::vector<std::string> valueOpts = { "name", "root", + "compress", + "threshold" }; + MergeOptions(baseOpts, newOpts, valueOpts, isQt5); +} + bool cmQtAutoGen::RccListInputs(const std::string& qtMajorVersion, const std::string& rccCommand, const std::string& fileName, |