Add --no-recurse switch to depend-info command.
MODIFY
include/vcpkg/commands.h
include/vcpkg/commands.h
@@ -55,6 +55,7 @@ namespace vcpkg::Commands
namespace DependInfo
{
+ extern const CommandStructure COMMAND_STRUCTURE;
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
}

MODIFY
src/vcpkg/commands.dependinfo.cpp
src/vcpkg/commands.dependinfo.cpp
@@ -11,10 +11,12 @@ namespace vcpkg::Commands::DependInfo
{
constexpr StringLiteral OPTION_DOT = "--dot";
constexpr StringLiteral OPTION_DGML = "--dgml";
+ constexpr StringLiteral OPTION_NO_RECURSE = "--no-recurse";
- constexpr std::array<CommandSwitch, 2> DEPEND_SWITCHES = {{
+ constexpr std::array<CommandSwitch, 3> DEPEND_SWITCHES = {{
{OPTION_DOT, "Creates graph on basis of dot"},
{OPTION_DGML, "Creates graph on basis of dgml"},
+ {OPTION_NO_RECURSE, "Computes only immediate dependencies of packages explicitly specified on the command-line"},
}};
const CommandStructure COMMAND_STRUCTURE = {
@@ -121,7 +123,8 @@ namespace vcpkg::Commands::DependInfo
void build_dependencies_list(std::set<std::string>& packages_to_keep,
const std::string& requested_package,
- const std::vector<std::unique_ptr<SourceControlFile>>& source_control_files)
+ const std::vector<std::unique_ptr<SourceControlFile>>& source_control_files,
+ const std::unordered_set<std::string>& switches)
{
const auto source_control_file =
Util::find_if(source_control_files, [&requested_package](const auto& source_control_file) {
@@ -132,11 +135,11 @@ namespace vcpkg::Commands::DependInfo
{
const auto new_package = packages_to_keep.insert(requested_package).second;
- if (new_package)
+ if (new_package && !Util::Sets::contains(switches, OPTION_NO_RECURSE))
{
for (const auto& dependency : (*source_control_file)->core_paragraph->depends)
{
- build_dependencies_list(packages_to_keep, dependency.depend.name, source_control_files);
+ build_dependencies_list(packages_to_keep, dependency.depend.name, source_control_files, switches);
}
}
}
@@ -157,7 +160,7 @@ namespace vcpkg::Commands::DependInfo
std::set<std::string> packages_to_keep;
for (const auto& requested_package : args.command_arguments)
{
- build_dependencies_list(packages_to_keep, requested_package, source_control_files);
+ build_dependencies_list(packages_to_keep, requested_package, source_control_files, options.switches);
}
Util::erase_remove_if(source_control_files, [&packages_to_keep](const auto& source_control_file) {
@@ -165,7 +168,7 @@ namespace vcpkg::Commands::DependInfo
});
}
- if (!options.switches.empty())
+ if (Util::Sets::contains(options.switches, OPTION_DOT) || Util::Sets::contains(options.switches, OPTION_DGML))
{
const std::string graph_as_string = create_graph_as_string(options.switches, source_control_files);
System::println(graph_as_string);

MODIFY
src/vcpkg/help.cpp
src/vcpkg/help.cpp
@@ -49,9 +49,10 @@ namespace vcpkg::Help
nullptr,
};
- static constexpr std::array<Topic, 12> topics = {{
+ static constexpr std::array<Topic, 13> topics = {{
{"create", command_topic_fn<Commands::Create::COMMAND_STRUCTURE>},
{"edit", command_topic_fn<Commands::Edit::COMMAND_STRUCTURE>},
+ {"depend-info", command_topic_fn<Commands::DependInfo::COMMAND_STRUCTURE>},
{"env", command_topic_fn<Commands::Env::COMMAND_STRUCTURE>},
{"export", command_topic_fn<Export::COMMAND_STRUCTURE>},
{"help", command_topic_fn<Help::COMMAND_STRUCTURE>},

Add --no-recurse switch to depend-info command.