diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-06-08 15:27:39 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-09 14:50:56 (GMT) |
commit | b0a8fa959cbf8936a7e1aa558cf0c08bfa9e0a39 (patch) | |
tree | 2bf9481e3020f62e82fed8bdc4f6a1671aec07e0 /Source/cmScanDepFormat.cxx | |
parent | 82c867ad85785cdf6efed98f8fdef27419375f29 (diff) | |
download | CMake-b0a8fa959cbf8936a7e1aa558cf0c08bfa9e0a39.zip CMake-b0a8fa959cbf8936a7e1aa558cf0c08bfa9e0a39.tar.gz CMake-b0a8fa959cbf8936a7e1aa558cf0c08bfa9e0a39.tar.bz2 |
cmScanDepFormat: P1689R4: Diagnose invalid provides/requires json type
Diffstat (limited to 'Source/cmScanDepFormat.cxx')
-rw-r--r-- | Source/cmScanDepFormat.cxx | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/Source/cmScanDepFormat.cxx b/Source/cmScanDepFormat.cxx index 8e09a78..68ed3b2 100644 --- a/Source/cmScanDepFormat.cxx +++ b/Source/cmScanDepFormat.cxx @@ -133,46 +133,56 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp, if (rule.isMember("provides")) { Json::Value const& provides = rule["provides"]; - if (provides.isArray()) { - for (auto const& provide : provides) { - cmSourceReqInfo provide_info; - - Json::Value const& logical_name = provide["logical-name"]; - PARSE_BLOB(logical_name, provide_info.LogicalName); - - if (provide.isMember("compiled-module-path")) { - Json::Value const& compiled_module_path = - provide["compiled-module-path"]; - PARSE_FILENAME(compiled_module_path, - provide_info.CompiledModulePath); - } else { - provide_info.CompiledModulePath = - cmStrCat(provide_info.LogicalName, ".mod"); - } - - info->Provides.push_back(provide_info); + if (!provides.isArray()) { + cmSystemTools::Error( + cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp, + ": provides is not an array")); + return false; + } + + for (auto const& provide : provides) { + cmSourceReqInfo provide_info; + + Json::Value const& logical_name = provide["logical-name"]; + PARSE_BLOB(logical_name, provide_info.LogicalName); + + if (provide.isMember("compiled-module-path")) { + Json::Value const& compiled_module_path = + provide["compiled-module-path"]; + PARSE_FILENAME(compiled_module_path, + provide_info.CompiledModulePath); + } else { + provide_info.CompiledModulePath = + cmStrCat(provide_info.LogicalName, ".mod"); } + + info->Provides.push_back(provide_info); } } if (rule.isMember("requires")) { Json::Value const& reqs = rule["requires"]; - if (reqs.isArray()) { - for (auto const& require : reqs) { - cmSourceReqInfo require_info; + if (!reqs.isArray()) { + cmSystemTools::Error( + cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp, + ": requires is not an array")); + return false; + } - Json::Value const& logical_name = require["logical-name"]; - PARSE_BLOB(logical_name, require_info.LogicalName); + for (auto const& require : reqs) { + cmSourceReqInfo require_info; - if (require.isMember("compiled-module-path")) { - Json::Value const& compiled_module_path = - require["compiled-module-path"]; - PARSE_FILENAME(compiled_module_path, - require_info.CompiledModulePath); - } + Json::Value const& logical_name = require["logical-name"]; + PARSE_BLOB(logical_name, require_info.LogicalName); - info->Requires.push_back(require_info); + if (require.isMember("compiled-module-path")) { + Json::Value const& compiled_module_path = + require["compiled-module-path"]; + PARSE_FILENAME(compiled_module_path, + require_info.CompiledModulePath); } + + info->Requires.push_back(require_info); } } } |