mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-23 11:07:10 +01:00
Merge pull request #6055 from jediry/depend_info_no_recurse
Add --no-recurse flag to "depend-info" command
This commit is contained in:
commit
7e65405c31
@ -55,6 +55,7 @@ namespace vcpkg::Commands
|
||||
|
||||
namespace DependInfo
|
||||
{
|
||||
extern const CommandStructure COMMAND_STRUCTURE;
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user