cmScanDepFormat: P1689R4: Factor out primary-output field
This commit is contained in:
parent
b0a8fa959c
commit
aab9a5fc3e
@ -44,6 +44,7 @@ by the `P1689r3`_ paper, with the following updates:
|
||||
* Omit the ``outputs``, ``inputs``, and ``depends`` fields from
|
||||
each entry in the ``rules`` array. They are unused.
|
||||
* Flatten ``future-compile`` members directly into each rule.
|
||||
* Factor a ``primary-output`` field out of the now-flattened ``outputs``.
|
||||
|
||||
Compiler writers may try out their scanning functionality using
|
||||
the `cxx-modules-sandbox`_ test project, modified to set variables
|
||||
|
@ -117,17 +117,20 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rule.isMember("primary-output")) {
|
||||
Json::Value const& primary_output = rule["primary-output"];
|
||||
PARSE_FILENAME(primary_output, info->PrimaryOutput);
|
||||
}
|
||||
|
||||
if (rule.isMember("outputs")) {
|
||||
Json::Value const& outputs = rule["outputs"];
|
||||
if (outputs.isArray()) {
|
||||
if (outputs.empty()) {
|
||||
cmSystemTools::Error(
|
||||
cmStrCat("-E cmake_ninja_dyndep failed to parse ", arg_pp,
|
||||
": expected at least one 1 output"));
|
||||
return false;
|
||||
}
|
||||
for (auto const& output : outputs) {
|
||||
std::string extra_output;
|
||||
PARSE_FILENAME(output, extra_output);
|
||||
|
||||
PARSE_FILENAME(outputs[0], info->PrimaryOutput);
|
||||
info->ExtraOutputs.emplace_back(extra_output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,8 +205,12 @@ bool cmScanDepFormat_P1689_Write(std::string const& path,
|
||||
|
||||
Json::Value rule(Json::objectValue);
|
||||
|
||||
Json::Value& outputs = rule["outputs"] = Json::arrayValue;
|
||||
outputs.append(info.PrimaryOutput);
|
||||
rule["primary-output"] = EncodeFilename(info.PrimaryOutput);
|
||||
|
||||
Json::Value& rule_outputs = rule["outputs"] = Json::arrayValue;
|
||||
for (auto const& output : info.ExtraOutputs) {
|
||||
rule_outputs.append(EncodeFilename(output));
|
||||
}
|
||||
|
||||
Json::Value& provides = rule["provides"] = Json::arrayValue;
|
||||
for (auto const& provide : info.Provides) {
|
||||
|
@ -14,6 +14,7 @@ struct cmSourceReqInfo
|
||||
struct cmScanDepInfo
|
||||
{
|
||||
std::string PrimaryOutput;
|
||||
std::vector<std::string> ExtraOutputs;
|
||||
|
||||
// Set of provided and required modules.
|
||||
std::vector<cmSourceReqInfo> Provides;
|
||||
|
Loading…
Reference in New Issue
Block a user