diff options
| author | Griffin Downs <35574547+grdowns@users.noreply.github.com> | 2019-04-11 22:47:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-11 22:47:14 -0700 |
| commit | 7e65405c3154b4dcd81b04f2275546a280945176 (patch) | |
| tree | 384236ba92d60c1fa9d30b242d836d0ee0fd29d8 | |
| parent | 803b27b66e5697ad2f331fcc55916663ce7777dd (diff) | |
| parent | 022cfa2329362b102e641f5882be270de6beb8b3 (diff) | |
| download | vcpkg-7e65405c3154b4dcd81b04f2275546a280945176.tar.gz vcpkg-7e65405c3154b4dcd81b04f2275546a280945176.zip | |
Merge pull request #6055 from jediry/depend_info_no_recurse
Add --no-recurse flag to "depend-info" command
| -rw-r--r-- | toolsrc/include/vcpkg/commands.h | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/commands.dependinfo.cpp | 15 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/help.cpp | 4 |
3 files changed, 13 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 c4441883c..92ba15c1f 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<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::print2(graph_as_string, '\n');
diff --git a/toolsrc/src/vcpkg/help.cpp b/toolsrc/src/vcpkg/help.cpp index bac44506d..84a054e0f 100644 --- a/toolsrc/src/vcpkg/help.cpp +++ b/toolsrc/src/vcpkg/help.cpp @@ -47,9 +47,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>}, @@ -103,6 +104,7 @@ namespace vcpkg::Help " vcpkg create <pkg> <url>\n" " [archivename] Create a new package\n" " vcpkg owns <pat> Search for files in installed packages\n" + " vcpkg depend-info [pkg]... Display a list of dependencies for packages\n" " vcpkg env Creates a clean shell environment for development or " "compiling.\n" " vcpkg version Display version information\n" |
