From 83fec1025ce84257d876dd2e65033ea1a6eb8a1f Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 12 Jul 2018 19:24:33 +0800 Subject: [PATCH 1/3] vtable-dumper: Update test script Test: tests/test_vndk_vtable_dumper.py Change-Id: I2038c77c930ab9b0d70b54d7e73c1a88a0c7f725 --- vndk/tools/vtable-dumper/tests/test_vndk_vtable_dumper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vndk/tools/vtable-dumper/tests/test_vndk_vtable_dumper.py b/vndk/tools/vtable-dumper/tests/test_vndk_vtable_dumper.py index 37848ee44..c08e22948 100755 --- a/vndk/tools/vtable-dumper/tests/test_vndk_vtable_dumper.py +++ b/vndk/tools/vtable-dumper/tests/test_vndk_vtable_dumper.py @@ -24,9 +24,11 @@ import tempfile """Test vndk vtable dumper""" -NDK_VERSION = 'r11' +NDK_VERSION = 'r16' API_LEVEL = 'android-24' +LLVM_PREBUILTS_VERSION = 'clang-4691093' + SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) VNDK_VTABLE_DUMPER = 'vndk-vtable-dumper' @@ -54,7 +56,7 @@ def get_prebuilts_gcc(android_build_top, arch, gcc_version): def get_prebuilts_clang(android_build_top): """Get the path to prebuilt gcc for the current platform""" return os.path.join(android_build_top, 'prebuilts', 'clang', 'host', - get_prebuilts_host(), 'clang-stable') + get_prebuilts_host(), LLVM_PREBUILTS_VERSION) def get_prebuilts_ndk(android_build_top, subdirs): """Get the path to prebuilt ndk for the current platform and API level""" From 7e9606dc3e93c1d47ccbd758244e41f544588c5e Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 12 Jul 2018 19:32:23 +0800 Subject: [PATCH 2/3] sourcedr: Check whether paths map to projects This commit checks whether the path maps to a git project specified in `manifest.xml`. If it does not map to a git project, emit an error and skip it. If we don't do so, an exception will be raised because the `sorted()` function cannot compare `None` object with `str` object. Test: Add a project to external and it does not stop the analyzer. Change-Id: I386ab7c1f76d5630a2c5f43186f38a791a3bb7b9 --- .../tools/sourcedr/blueprint/analyze_manifest_split.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py b/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py index c281bec29..e79faa4a9 100755 --- a/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py +++ b/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py @@ -22,6 +22,7 @@ import argparse import collections import os import re +import sys import xml.dom.minidom from blueprint import RecursiveParser, evaluate_defaults, fill_module_namespaces @@ -140,9 +141,16 @@ def main(): root_dir = os.path.dirname(os.path.abspath(args.blueprint)) root_prefix_len = len(root_dir) + 1 + has_error = False + for rule, attrs in parse_blueprint(args.blueprint): path = _get_property(attrs, '_path')[root_prefix_len:] project = dir_matcher.find(path) + if project is None: + print('error: Path {!r} does not belong to any git projects.' + .format(path), file=sys.stderr) + has_error = True + continue git_projects[project].add_module(path, rule, attrs) # Print output @@ -157,6 +165,8 @@ def main(): _dump_module_set('vendor_only', modules.vendor_only) _dump_module_set('both', modules.both) + if has_error: + sys.exit(2) if __name__ == '__main__': main() From bec07164e5c570536583dca62cd6f3e115a1a985 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Thu, 12 Jul 2018 20:29:23 +0800 Subject: [PATCH 3/3] sourcedr: Add more project analysis filters This commit adds `--has-group`, `--only-has-group`, and `--without-group` to filter projects. Test: analyze_manifest_split.py -b Android.bp -m .repo/manifest.xml \ --has-group=system_only Test: analyze_manifest_split.py -b Android.bp -m .repo/manifest.xml \ --only-has-group=vendor_only Test: analyze_manifest_split.py -b Android.bp -m .repo/manifest.xml \ --without-group=both Change-Id: I5199a7e940538e73a1af19cfd78afbe4427d6e3b --- .../blueprint/analyze_manifest_split.py | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py b/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py index e79faa4a9..2160fc80a 100755 --- a/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py +++ b/vndk/tools/sourcedr/blueprint/analyze_manifest_split.py @@ -28,6 +28,9 @@ import xml.dom.minidom from blueprint import RecursiveParser, evaluate_defaults, fill_module_namespaces +_GROUPS = ['system_only', 'vendor_only', 'both'] + + def parse_manifest_xml(manifest_path): """Build a dictionary that maps directories into projects.""" dir_project_dict = {} @@ -116,8 +119,15 @@ def _parse_args(): help='Path to root Android.bp') parser.add_argument('-m', '--manifest', required=True, help='Path to repo manifest xml file') - parser.add_argument('--skip-no-overlaps', action='store_true', - help='Skip projects without overlaps') + group = parser.add_mutually_exclusive_group() + group.add_argument('--skip-no-overlaps', action='store_true', + help='Skip projects without overlaps') + group.add_argument('--has-group', choices=_GROUPS, + help='List projects that some modules are in the group') + group.add_argument('--only-has-group', choices=_GROUPS, + help='List projects that all modules are in the group') + group.add_argument('--without-group', choices=_GROUPS, + help='List projects that no modules are in the group') return parser.parse_args() @@ -154,17 +164,36 @@ def main(): git_projects[project].add_module(path, rule, attrs) # Print output + total_projects = 0 for project, modules in sorted(git_projects.items()): - if args.skip_no_overlaps and (int(len(modules.system_only) > 0) + - int(len(modules.vendor_only) > 0) + - int(len(modules.both) > 0)) <= 1: - continue + if args.skip_no_overlaps: + if (int(len(modules.system_only) > 0) + + int(len(modules.vendor_only) > 0) + + int(len(modules.both) > 0)) <= 1: + continue + elif args.has_group: + if not getattr(modules, args.has_group): + continue + elif args.only_has_group: + if any(getattr(modules, group) + for group in _GROUPS if group != args.only_has_group): + continue + if not getattr(modules, args.only_has_group): + continue + elif args.without_group: + if getattr(modules, args.without_group): + continue + print(project, len(modules.system_only), len(modules.vendor_only), len(modules.both)) _dump_module_set('system_only', modules.system_only) _dump_module_set('vendor_only', modules.vendor_only) _dump_module_set('both', modules.both) + total_projects += 1 + + print('Total:', total_projects) + if has_error: sys.exit(2)