summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoMocUic.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmQtAutoMocUic.cxx')
-rw-r--r--Source/cmQtAutoMocUic.cxx54
1 files changed, 46 insertions, 8 deletions
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 9cb172b..c9d4268 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -15,6 +15,7 @@
#include <vector>
#include <cm/memory>
+#include <cm/optional>
#include <cm/string_view>
#include <cmext/algorithm>
@@ -26,7 +27,6 @@
#include "cmCryptoHash.h"
#include "cmFileTime.h"
#include "cmGccDepfileReader.h"
-#include "cmGccDepfileReaderTypes.h"
#include "cmGeneratedFileStream.h"
#include "cmQtAutoGen.h"
#include "cmQtAutoGenerator.h"
@@ -2452,17 +2452,20 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info)
Json::Value const& entry = val[ii];
if (testEntry(entry.isArray(), "JSON value is not an array.") ||
- testEntry(entry.size() == 3, "JSON array size invalid.")) {
+ testEntry(entry.size() == 4, "JSON array size invalid.")) {
return false;
}
Json::Value const& entryName = entry[0u];
Json::Value const& entryFlags = entry[1u];
- Json::Value const& entryBuild = entry[2u];
+ Json::Value const& entryConfigs = entry[2u];
+ Json::Value const& entryBuild = entry[3u];
if (testEntry(entryName.isString(),
"JSON value for name is not a string.") ||
testEntry(entryFlags.isString(),
"JSON value for flags is not a string.") ||
+ testEntry(entryConfigs.isNull() || entryConfigs.isArray(),
+ "JSON value for configs is not null or array.") ||
testEntry(entryBuild.isString(),
"JSON value for build path is not a string.")) {
return false;
@@ -2475,6 +2478,22 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info)
return false;
}
+ if (entryConfigs.isArray()) {
+ bool configFound = false;
+ Json::ArrayIndex const configArraySize = entryConfigs.size();
+ for (Json::ArrayIndex ci = 0; ci != configArraySize; ++ci) {
+ Json::Value const& config = entryConfigs[ci];
+ if (testEntry(config.isString(),
+ "JSON value in config array is not a string.")) {
+ return false;
+ }
+ configFound = configFound || config.asString() == this->InfoConfig();
+ }
+ if (!configFound) {
+ continue;
+ }
+ }
+
cmFileTime fileTime;
if (!fileTime.Load(name)) {
return info.LogError(cmStrCat(
@@ -2515,16 +2534,19 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info)
Json::Value const& entry = val[ii];
if (testEntry(entry.isArray(), "JSON value is not an array.") ||
- testEntry(entry.size() == 2, "JSON array size invalid.")) {
+ testEntry(entry.size() == 3, "JSON array size invalid.")) {
return false;
}
Json::Value const& entryName = entry[0u];
Json::Value const& entryFlags = entry[1u];
+ Json::Value const& entryConfigs = entry[2u];
if (testEntry(entryName.isString(),
"JSON value for name is not a string.") ||
testEntry(entryFlags.isString(),
- "JSON value for flags is not a string.")) {
+ "JSON value for flags is not a string.") ||
+ testEntry(entryConfigs.isNull() || entryConfigs.isArray(),
+ "JSON value for configs is not null or array.")) {
return false;
}
@@ -2534,6 +2556,22 @@ bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info)
return false;
}
+ if (entryConfigs.isArray()) {
+ bool configFound = false;
+ Json::ArrayIndex const configArraySize = entryConfigs.size();
+ for (Json::ArrayIndex ci = 0; ci != configArraySize; ++ci) {
+ Json::Value const& config = entryConfigs[ci];
+ if (testEntry(config.isString(),
+ "JSON value in config array is not a string.")) {
+ return false;
+ }
+ configFound = configFound || config.asString() == this->InfoConfig();
+ }
+ if (!configFound) {
+ continue;
+ }
+ }
+
cmFileTime fileTime;
if (!fileTime.Load(name)) {
return info.LogError(cmStrCat(
@@ -2841,14 +2879,14 @@ bool cmQtAutoMocUicT::CreateDirectories()
std::vector<std::string> cmQtAutoMocUicT::dependenciesFromDepFile(
const char* filePath)
{
- cmGccDepfileContent content = cmReadGccDepfile(filePath);
- if (content.empty()) {
+ auto const content = cmReadGccDepfile(filePath);
+ if (!content || content->empty()) {
return {};
}
// Moc outputs a depfile with exactly one rule.
// Discard the rule and return the dependencies.
- return content.front().paths;
+ return content->front().paths;
}
void cmQtAutoMocUicT::Abort(bool error)