From 80965287d1483f98f49ba83e026f022369798990 Mon Sep 17 00:00:00 2001 From: Ryan Saunders Date: Wed, 10 Apr 2019 23:01:37 -0700 Subject: Add --no-recurse switch to depend-info command. --- toolsrc/include/vcpkg/commands.h | 1 + toolsrc/src/vcpkg/commands.dependinfo.cpp | 15 +++++++++------ toolsrc/src/vcpkg/help.cpp | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index fd7d832b3..6a94b389a 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/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); } diff --git a/toolsrc/src/vcpkg/commands.dependinfo.cpp b/toolsrc/src/vcpkg/commands.dependinfo.cpp index 455f3b7c5..6c3697ab4 100644 --- a/toolsrc/src/vcpkg/commands.dependinfo.cpp +++ b/toolsrc/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 DEPEND_SWITCHES = {{ + constexpr std::array 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& packages_to_keep, const std::string& requested_package, - const std::vector>& source_control_files) + const std::vector>& source_control_files, + const std::unordered_set& 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 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); diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index 5df878a91..67a7e852b 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -49,9 +49,10 @@ namespace vcpkg::Help nullptr, }; - static constexpr std::array topics = {{ + static constexpr std::array topics = {{ {"create", command_topic_fn}, {"edit", command_topic_fn}, + {"depend-info", command_topic_fn}, {"env", command_topic_fn}, {"export", command_topic_fn}, {"help", command_topic_fn}, -- cgit v1.2.3