From 9b70b376c3f28203d09ab1f8c033e39ed7977834 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 16 Jun 2017 17:30:09 +0800 Subject: [PATCH] vndk-def: Add --enumerate to deps-closure This commit adds --enumerate to deps-closure so that a user can print the dependency closure for each specified libraries or all libraries. Bug: 62644173 Test: ./vndk_definition_tool.py deps-closure \ --system ... --vendor ... --enumerate Change-Id: I18bb27be10c565538356f774cc6752f8cfc79bd4 --- .../definition-tool/vndk_definition_tool.py | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py index 302cc5c15..0b5fc3dc8 100755 --- a/vndk/tools/definition-tool/vndk_definition_tool.py +++ b/vndk/tools/definition-tool/vndk_definition_tool.py @@ -2218,7 +2218,7 @@ class DepsClosureCommand(ELFGraphCommand): def add_argparser_options(self, parser): super(DepsClosureCommand, self).add_argparser_options(parser) - parser.add_argument('lib', nargs='+', + parser.add_argument('lib', nargs='*', help='root set of the shared libraries') parser.add_argument('--exclude-lib', action='append', default=[], @@ -2230,6 +2230,20 @@ class DepsClosureCommand(ELFGraphCommand): parser.add_argument('--revert', action='store_true', help='print usage dependency') + parser.add_argument('--enumerate', action='store_true', + help='print closure for each lib instead of union') + + def print_deps_closure(self, root_libs, graph, is_excluded_libs, + is_reverted, indent): + if is_reverted: + closure = graph.compute_users_closure(root_libs, is_excluded_libs) + else: + closure = graph.compute_deps_closure(root_libs, is_excluded_libs) + + for lib in sorted_lib_path_list(closure): + print(indent + lib) + + def main(self, args): generic_refs, graph = self.create_from_args(args) @@ -2239,7 +2253,7 @@ class DepsClosureCommand(ELFGraphCommand): root_libs = graph.get_libs(args.lib, report_error) excluded_libs = graph.get_libs(args.exclude_lib, report_error) - # Compute and print the closure. + # Define the exclusion filter. if args.exclude_ndk: def is_excluded_libs(lib): return lib.is_ndk or lib in excluded_libs @@ -2247,13 +2261,16 @@ class DepsClosureCommand(ELFGraphCommand): def is_excluded_libs(lib): return lib in excluded_libs - if args.revert: - closure = graph.compute_users_closure(root_libs, is_excluded_libs) + if not args.enumerate: + self.print_deps_closure(root_libs, graph, is_excluded_libs, + args.revert, '') else: - closure = graph.compute_deps_closure(root_libs, is_excluded_libs) - - for lib in sorted_lib_path_list(closure): - print(lib) + if not root_libs: + root_libs = list(graph.all_libs()) + for lib in sorted(root_libs): + print(lib.path) + self.print_deps_closure({lib}, graph, is_excluded_libs, + args.revert, '\t') return 0