diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-17 15:41:12 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-08-25 16:22:42 +0200 |
commit | 834f63b6ea447056aba279439e7531f55062f588 (patch) | |
tree | fe2401fedbac926738f39423892f9c19c6d4da3c | |
parent | ad6d8ab4e3cb4fa4f4e91ac23347ea23fb8945a9 (diff) | |
download | justbuild-834f63b6ea447056aba279439e7531f55062f588.tar.gz |
just describe: also show the implict dependencies
... in the human-readable description. More precisely, for
any implicit target field, show
- the field documentation given (if any), and
- the resolved targets this field contains.
However, do not show the actual name of the field, as this name
is internal to the rule and not part of the interface.
-rw-r--r-- | src/buildtool/main/describe.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/buildtool/main/describe.cpp b/src/buildtool/main/describe.cpp index 292ea7b9..1fcdf44e 100644 --- a/src/buildtool/main/describe.cpp +++ b/src/buildtool/main/describe.cpp @@ -52,7 +52,8 @@ void PrintFields(nlohmann::json const& fields, } } -void PrettyPrintRule(nlohmann::json const& rdesc) { +void PrettyPrintRule(nlohmann::json const& rdesc, + BuildMaps::Base::EntityName const& rule_name) { auto doc = rdesc.find("doc"); if (doc != rdesc.end()) { PrintDoc(*doc, " | "); @@ -72,6 +73,31 @@ void PrettyPrintRule(nlohmann::json const& rdesc) { std::cout << " Target fields\n"; PrintFields(*target_fields, field_doc, " - ", " | "); } + auto implicit_targets = rdesc.find("implicit"); + if (implicit_targets != rdesc.end()) { + for (auto const& [key, value] : implicit_targets->items()) { + std::cout << " - implict dependency\n"; // + auto doc = field_doc.find(key); + if (doc != field_doc.end()) { + PrintDoc(*doc, " | "); + } + for (auto const& entry : value) { + auto resolved_entry = BuildMaps::Base::ParseEntityNameFromJson( + entry, + rule_name, + [&entry, &rule_name](std::string const& parse_err) { + Logger::Log(LogLevel::Warning, + "Failed to resolve {} relative to {}:\n{}", + entry.dump(), + rule_name.ToString(), + parse_err); + }); + if (resolved_entry) { + std::cout << " - " << resolved_entry->ToString() << "\n"; + } + } + } + } auto config_fields = rdesc.find("config_fields"); if (config_fields != rdesc.end() and (not config_fields->empty())) { std::cout << " Config fields\n"; @@ -224,7 +250,7 @@ auto DescribeUserDefinedRule(BuildMaps::Base::EntityName const& rule_name, PrintRuleAsOrderedJson(*ruledesc_it, rule_name.ToJson()); return kExitSuccess; } - PrettyPrintRule(*ruledesc_it); + PrettyPrintRule(*ruledesc_it, rule_name); return kExitSuccess; } |