Avoid duplicated module name for vndk_prebuilt_shared

There may have prebuilt files that share a single name causing
duplicated module name error. Fix this bug by generating the
vndk_prebuilt_shared module per each module name.

Bug: 225265099
Bug: 225243872
Test: development/vndk/snapshot/gen_buildfiles.py
Change-Id: I2f6df9956d33b2ed0e901d73c93621ff4727370d
This commit is contained in:
Justin Yun
2022-03-18 20:24:33 +09:00
parent 8d976b785a
commit fea111c2a7

View File

@@ -486,52 +486,71 @@ class GenBuildFile(object):
module_names: dict, module names for given prebuilts module_names: dict, module names for given prebuilts
""" """
build_rules = [] module_prebuilts = dict()
for prebuilt in prebuilts: for prebuilt in prebuilts:
if prebuilt in module_names:
name = module_names[prebuilt]
else:
name = os.path.splitext(prebuilt)[0]
if name not in module_prebuilts:
module_prebuilts[name] = list()
module_prebuilts[name].append(prebuilt)
build_rules = []
for name in module_prebuilts:
bp_module = self._gen_vndk_shared_prebuilt( bp_module = self._gen_vndk_shared_prebuilt(
prebuilt, name,
arch, arch,
srcs=module_prebuilts[name],
is_llndk=is_llndk, is_llndk=is_llndk,
is_vndk_sp=is_vndk_sp, is_vndk_sp=is_vndk_sp,
is_binder32=is_binder32, is_binder32=is_binder32)
module_names=module_names)
if bp_module: if bp_module:
build_rules.append(bp_module) build_rules.append(bp_module)
return build_rules return build_rules
def _gen_vndk_shared_prebuilt(self, def _gen_vndk_shared_prebuilt(self,
prebuilt, name,
arch, arch,
srcs,
is_llndk, is_llndk,
is_vndk_sp, is_vndk_sp,
is_binder32, is_binder32):
module_names): """Returns build rule for given prebuilt module, or an empty
"""Returns build rule for given prebuilt, or an empty string if the string if the module is invalid (e.g. srcs doesn't exist).
prebuilt is invalid (e.g. srcs doesn't exist).
Args: Args:
prebuilt: string, name of prebuilt object name: string, name of prebuilt module
arch: string, VNDK snapshot arch (e.g. 'arm64') arch: string, VNDK snapshot arch (e.g. 'arm64')
srcs: list, prebuilt source file names of this module
is_llndk: bool, True if prebuilt is a LLNDK stub is_llndk: bool, True if prebuilt is a LLNDK stub
is_vndk_sp: bool, True if prebuilt is a VNDK_SP lib is_vndk_sp: bool, True if prebuilt is a VNDK_SP lib
is_binder32: bool, True if binder interface is 32-bit is_binder32: bool, True if binder interface is 32-bit
module_names: dict, module names for given prebuilts
""" """
def get_notice_file(prebuilt): def is_prebuilts_in_list(prebuilts, vndk_list):
for prebuilt in prebuilts:
if prebuilt in vndk_list:
return True
return False
def get_notice_file(prebuilts):
"""Returns build rule for notice file (attribute 'notice'). """Returns build rule for notice file (attribute 'notice').
Args: Args:
prebuilt: string, name of prebuilt object prebuilts: list, names of prebuilt objects
""" """
notice = '' notice = ''
if prebuilt in self._modules_with_notice: for prebuilt in prebuilts:
notice = '{ind}notice: ":{notice_filegroup}",\n'.format( if prebuilt in self._modules_with_notice:
ind=self.INDENT, notice = '{ind}notice: ":{notice_filegroup}",\n'.format(
notice_filegroup=self._get_notice_filegroup_name(prebuilt)) ind=self.INDENT,
notice_filegroup=self._get_notice_filegroup_name(prebuilt))
break
return notice return notice
def get_arch_props(prebuilt, arch, src_paths): def get_arch_props(name, arch, src_paths):
"""Returns build rule for arch specific srcs. """Returns build rule for arch specific srcs.
e.g., e.g.,
@@ -553,7 +572,7 @@ class GenBuildFile(object):
} }
Args: Args:
prebuilt: string, name of prebuilt object name: string, name of prebuilt module
arch: string, VNDK snapshot arch (e.g. 'arm64') arch: string, VNDK snapshot arch (e.g. 'arm64')
src_paths: list of string paths, prebuilt source paths src_paths: list of string paths, prebuilt source paths
""" """
@@ -588,7 +607,7 @@ class GenBuildFile(object):
os.unlink(prop_path) os.unlink(prop_path)
except: except:
# TODO(b/70312118): Parse from soong build system # TODO(b/70312118): Parse from soong build system
if prebuilt == 'android.hidl.memory@1.0-impl.so': if name == 'android.hidl.memory@1.0-impl':
props['RelativeInstallPath'] = 'hw' props['RelativeInstallPath'] = 'hw'
if 'ExportedDirs' in props: if 'ExportedDirs' in props:
dirs = rename_generated_dirs(props['ExportedDirs']) dirs = rename_generated_dirs(props['ExportedDirs'])
@@ -628,23 +647,18 @@ class GenBuildFile(object):
if is_binder32: if is_binder32:
src_root = os.path.join(src_root, utils.BINDER32) src_root = os.path.join(src_root, utils.BINDER32)
src_paths = utils.find(src_root, [prebuilt]) src_paths = utils.find(src_root, srcs)
# filter out paths under 'binder32' subdirectory # filter out paths under 'binder32' subdirectory
src_paths = list(filter(lambda src: not src.startswith(utils.BINDER32), src_paths = list(filter(lambda src: not src.startswith(utils.BINDER32),
src_paths)) src_paths))
# This prebuilt is invalid if no srcs are found. # This module is invalid if no srcs are found.
if not src_paths: if not src_paths:
logging.info('No srcs found for {}; skipping'.format(prebuilt)) logging.info('No srcs found for {}; skipping'.format(name))
return "" return ""
if prebuilt in module_names:
name = module_names[prebuilt]
else:
name = os.path.splitext(prebuilt)[0]
product_available = '' product_available = ''
# if vndkproduct.libraries.txt is empty, make the VNDKs available to product by default. # if vndkproduct.libraries.txt is empty, make the VNDKs available to product by default.
if not self._vndk_product[arch] or prebuilt in self._vndk_product[arch] or is_llndk: if is_llndk or not self._vndk_product[arch] or is_prebuilts_in_list(srcs, self._vndk_product[arch]):
product_available = '{ind}product_available: true,\n'.format( product_available = '{ind}product_available: true,\n'.format(
ind=self.INDENT) ind=self.INDENT)
@@ -656,7 +670,7 @@ class GenBuildFile(object):
ind=self.INDENT) ind=self.INDENT)
vndk_private = '' vndk_private = ''
if prebuilt in self._vndk_private[arch]: if is_prebuilts_in_list(srcs, self._vndk_private[arch]):
vndk_private = '{ind}{ind}private: true,\n'.format( vndk_private = '{ind}{ind}private: true,\n'.format(
ind=self.INDENT) ind=self.INDENT)
@@ -670,8 +684,8 @@ class GenBuildFile(object):
vndk_sp=vndk_sp, vndk_sp=vndk_sp,
vndk_private=vndk_private)) vndk_private=vndk_private))
notice = get_notice_file(prebuilt) notice = get_notice_file(srcs)
arch_props = get_arch_props(prebuilt, arch, src_paths) arch_props = get_arch_props(name, arch, src_paths)
binder32bit = '' binder32bit = ''
if is_binder32: if is_binder32: