Merge "Reexport vndk for vendor snapshot modules"
This commit is contained in:
@@ -46,7 +46,6 @@ def get_arch(json_rel_path):
|
|||||||
def get_variation(json_rel_path):
|
def get_variation(json_rel_path):
|
||||||
return json_rel_path.split('/')[2]
|
return json_rel_path.split('/')[2]
|
||||||
|
|
||||||
|
|
||||||
# convert .bp prop dictionary to .bp prop string
|
# convert .bp prop dictionary to .bp prop string
|
||||||
def gen_bp_prop(prop, ind):
|
def gen_bp_prop(prop, ind):
|
||||||
bp = ''
|
bp = ''
|
||||||
@@ -55,8 +54,9 @@ def gen_bp_prop(prop, ind):
|
|||||||
|
|
||||||
# Skip empty list or dict, rather than printing empty prop like
|
# Skip empty list or dict, rather than printing empty prop like
|
||||||
# "key: []," or "key: {},"
|
# "key: []," or "key: {},"
|
||||||
if type(val) == list or type(val) == dict:
|
if type(val) == list and len(val) == 0:
|
||||||
if len(val) == 0:
|
continue
|
||||||
|
if type(val) == dict and gen_bp_prop(val, '') == '':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
bp += ind + key + ': '
|
bp += ind + key + ': '
|
||||||
@@ -116,6 +116,12 @@ SANITIZER_VARIANT_PROPS = {
|
|||||||
'src',
|
'src',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORTED_FLAGS_PROPS = {
|
||||||
|
'export_include_dirs',
|
||||||
|
'export_system_include_dirs',
|
||||||
|
'export_flags',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Converts parsed json dictionary (which is intermediate) to Android.bp prop
|
# Converts parsed json dictionary (which is intermediate) to Android.bp prop
|
||||||
# dictionary. This validates paths such as include directories and init_rc
|
# dictionary. This validates paths such as include directories and init_rc
|
||||||
@@ -147,7 +153,24 @@ def convert_json_to_bp_prop(json_path, bp_dir):
|
|||||||
def is_64bit_arch(arch):
|
def is_64bit_arch(arch):
|
||||||
return '64' in arch # arm64, x86_64
|
return '64' in arch # arm64, x86_64
|
||||||
|
|
||||||
def gen_bp_module(image, variation, name, version, target_arch, arch_props, bp_dir):
|
def remove_keys_from_dict(keys, d):
|
||||||
|
# May contain subdictionaries (e.g. cfi), so recursively erase
|
||||||
|
for k in list(d.keys()):
|
||||||
|
if k in keys:
|
||||||
|
del d[k]
|
||||||
|
elif type(d[k]) == dict:
|
||||||
|
remove_keys_from_dict(keys, d[k])
|
||||||
|
|
||||||
|
def reexport_vndk_header(name, arch_props):
|
||||||
|
remove_keys_from_dict(EXPORTED_FLAGS_PROPS, arch_props)
|
||||||
|
for arch in arch_props:
|
||||||
|
arch_props[arch]['shared_libs'] = [name]
|
||||||
|
arch_props[arch]['export_shared_lib_headers'] = [name]
|
||||||
|
|
||||||
|
def gen_bp_module(image, variation, name, version, target_arch, vndk_list, arch_props, bp_dir):
|
||||||
|
# Generate Android.bp module for given snapshot.
|
||||||
|
# If a vndk library with the same name exists, reuses exported flags of the vndk library,
|
||||||
|
# instead of the snapshot's own flags.
|
||||||
prop = {
|
prop = {
|
||||||
# These three are common for all snapshot modules.
|
# These three are common for all snapshot modules.
|
||||||
'version': str(version),
|
'version': str(version),
|
||||||
@@ -156,6 +179,15 @@ def gen_bp_module(image, variation, name, version, target_arch, arch_props, bp_d
|
|||||||
'arch': {},
|
'arch': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reexport_vndk_name = name
|
||||||
|
if reexport_vndk_name == "libc++_static":
|
||||||
|
reexport_vndk_name = "libc++"
|
||||||
|
|
||||||
|
if reexport_vndk_name in vndk_list:
|
||||||
|
if variation == 'shared':
|
||||||
|
logging.error("Module %s is both vendor snapshot shared and vndk" % name)
|
||||||
|
reexport_vndk_header(reexport_vndk_name, arch_props)
|
||||||
|
|
||||||
# Factor out common prop among architectures to minimize Android.bp.
|
# Factor out common prop among architectures to minimize Android.bp.
|
||||||
common_prop = None
|
common_prop = None
|
||||||
for arch in arch_props:
|
for arch in arch_props:
|
||||||
@@ -243,7 +275,7 @@ def get_vndk_list(vndk_dir, target_arch):
|
|||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def gen_bp_list_module(image, snapshot_version, vndk_dir, target_arch, arch_props):
|
def gen_bp_list_module(image, snapshot_version, vndk_list, target_arch, arch_props):
|
||||||
"""Generates a {image}_snapshot module which contains lists of snapshots.
|
"""Generates a {image}_snapshot module which contains lists of snapshots.
|
||||||
For vendor snapshot, vndk list is also included, extracted from vndk_dir.
|
For vendor snapshot, vndk list is also included, extracted from vndk_dir.
|
||||||
"""
|
"""
|
||||||
@@ -254,7 +286,7 @@ def gen_bp_list_module(image, snapshot_version, vndk_dir, target_arch, arch_prop
|
|||||||
bp_props['name'] = '%s_snapshot' % image
|
bp_props['name'] = '%s_snapshot' % image
|
||||||
bp_props['version'] = str(snapshot_version)
|
bp_props['version'] = str(snapshot_version)
|
||||||
if image == 'vendor':
|
if image == 'vendor':
|
||||||
bp_props['vndk_libs'] = get_vndk_list(vndk_dir, target_arch)
|
bp_props['vndk_libs'] = vndk_list
|
||||||
|
|
||||||
variant_to_property = {
|
variant_to_property = {
|
||||||
'shared': 'shared_libs',
|
'shared': 'shared_libs',
|
||||||
@@ -364,17 +396,21 @@ def gen_bp_files(image, vndk_dir, install_dir, snapshot_version):
|
|||||||
for target_arch in sorted(props):
|
for target_arch in sorted(props):
|
||||||
androidbp = ''
|
androidbp = ''
|
||||||
bp_dir = os.path.join(install_dir, target_arch)
|
bp_dir = os.path.join(install_dir, target_arch)
|
||||||
|
vndk_list = []
|
||||||
|
if image == 'vendor':
|
||||||
|
vndk_list = get_vndk_list(vndk_dir, target_arch)
|
||||||
|
|
||||||
# Generate snapshot modules.
|
# Generate snapshot modules.
|
||||||
for variation in sorted(props[target_arch]):
|
for variation in sorted(props[target_arch]):
|
||||||
for name in sorted(props[target_arch][variation]):
|
for name in sorted(props[target_arch][variation]):
|
||||||
androidbp += gen_bp_module(image, variation, name,
|
androidbp += gen_bp_module(image, variation, name,
|
||||||
snapshot_version, target_arch,
|
snapshot_version, target_arch,
|
||||||
|
vndk_list,
|
||||||
props[target_arch][variation][name],
|
props[target_arch][variation][name],
|
||||||
bp_dir)
|
bp_dir)
|
||||||
|
|
||||||
# Generate {image}_snapshot module which contains the list of modules.
|
# Generate {image}_snapshot module which contains the list of modules.
|
||||||
androidbp += gen_bp_list_module(image, snapshot_version, vndk_dir,
|
androidbp += gen_bp_list_module(image, snapshot_version, vndk_list,
|
||||||
target_arch, props[target_arch])
|
target_arch, props[target_arch])
|
||||||
with open(os.path.join(bp_dir, 'Android.bp'), 'w') as f:
|
with open(os.path.join(bp_dir, 'Android.bp'), 'w') as f:
|
||||||
logging.info('Generating Android.bp to: {}'.format(f.name))
|
logging.info('Generating Android.bp to: {}'.format(f.name))
|
||||||
|
|||||||
Reference in New Issue
Block a user