From 8f99d6ffd260fb38aa24d6639091a30dfb6222ce Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Mon, 15 Jun 2020 22:10:59 +0900 Subject: [PATCH] Skip not existing VNDK prebuilts Due to a bug of some past versions of VNDK, invalid VNDK modules without any prebuilt sources may exist. Skipping them instead of creating useless modules. Bug: 154777533 Test: capture snapshot, delete some .so files, and then install Android.bp Change-Id: I5579c1ae86453d1b6c8738455ff71bf106afbda4 --- vndk/snapshot/gen_buildfiles.py | 36 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/vndk/snapshot/gen_buildfiles.py b/vndk/snapshot/gen_buildfiles.py index f00b207fb..818aee5ca 100644 --- a/vndk/snapshot/gen_buildfiles.py +++ b/vndk/snapshot/gen_buildfiles.py @@ -353,13 +353,14 @@ class GenBuildFile(object): build_rules = [] for prebuilt in prebuilts: - build_rules.append( - self._gen_vndk_shared_prebuilt( - prebuilt, - arch, - is_vndk_sp=is_vndk_sp, - is_binder32=is_binder32, - module_names=module_names)) + bp_module = self._gen_vndk_shared_prebuilt( + prebuilt, + arch, + is_vndk_sp=is_vndk_sp, + is_binder32=is_binder32, + module_names=module_names) + if bp_module: + build_rules.append(bp_module) return build_rules def _gen_vndk_shared_prebuilt(self, @@ -368,7 +369,8 @@ class GenBuildFile(object): is_vndk_sp, is_binder32, module_names): - """Returns build rule for given prebuilt. + """Returns build rule for given prebuilt, or an empty string if the + prebuilt is invalid (e.g. srcs doesn't exist). Args: prebuilt: string, name of prebuilt object @@ -391,7 +393,7 @@ class GenBuildFile(object): notice_filegroup=self._get_notice_filegroup_name(prebuilt)) return notice - def get_arch_props(prebuilt, arch): + def get_arch_props(prebuilt, arch, src_paths): """Returns build rule for arch specific srcs. e.g., @@ -415,12 +417,9 @@ class GenBuildFile(object): Args: prebuilt: string, name of prebuilt object arch: string, VNDK snapshot arch (e.g. 'arm64') + src_paths: list of string paths, prebuilt source paths """ arch_props = '{ind}arch: {{\n'.format(ind=self.INDENT) - src_paths = utils.find(src_root, [prebuilt]) - # filter out paths under 'binder32' subdirectory - src_paths = filter(lambda src: not src.startswith(utils.BINDER32), - src_paths) def list_to_prop_value(l, name): if len(l) == 0: @@ -487,6 +486,15 @@ class GenBuildFile(object): if is_binder32 and self._vndk_version >= 28: src_root = os.path.join(src_root, utils.BINDER32) + src_paths = utils.find(src_root, [prebuilt]) + # filter out paths under 'binder32' subdirectory + src_paths = list(filter(lambda src: not src.startswith(utils.BINDER32), + src_paths)) + # This prebuilt is invalid if no srcs are found. + if not src_paths: + logging.info('No srcs found for {}; skipping'.format(prebuilt)) + return "" + if prebuilt in module_names: name = module_names[prebuilt] else: @@ -500,7 +508,7 @@ class GenBuildFile(object): ind=self.INDENT) notice = get_notice_file(prebuilt) - arch_props = get_arch_props(prebuilt, arch) + arch_props = get_arch_props(prebuilt, arch, src_paths) binder32bit = '' if is_binder32: