Merge "Add min_sdk_version prop to snapshots"

This commit is contained in:
Inseob Kim
2023-04-20 07:36:58 +00:00
committed by Gerrit Code Review
2 changed files with 30 additions and 14 deletions

View File

@@ -113,6 +113,7 @@ JSON_TO_BP = {
'CrateName': 'crate_name', 'CrateName': 'crate_name',
'Prebuilt': 'prebuilt', 'Prebuilt': 'prebuilt',
'Overrides': 'overrides', 'Overrides': 'overrides',
'MinSdkVersion': 'min_sdk_version',
} }
SANITIZER_VARIANT_PROPS = { SANITIZER_VARIANT_PROPS = {

View File

@@ -595,7 +595,7 @@ class GenBuildFile(object):
break break
return notice return notice
def get_arch_props(name, arch, src_paths): def get_arch_props(name, arch, srcs_props):
"""Returns build rule for arch specific srcs. """Returns build rule for arch specific srcs.
e.g., e.g.,
@@ -619,7 +619,7 @@ class GenBuildFile(object):
Args: Args:
name: string, name of prebuilt module 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 srcs_props: dict, prebuilt source paths and corresponding flags
""" """
arch_props = '{ind}arch: {{\n'.format(ind=self.INDENT) arch_props = '{ind}arch: {{\n'.format(ind=self.INDENT)
@@ -639,21 +639,12 @@ class GenBuildFile(object):
# Rename out/soong/.intermediates to generated-headers for better readability. # Rename out/soong/.intermediates to generated-headers for better readability.
return [d.replace(utils.SOONG_INTERMEDIATES_DIR, utils.GENERATED_HEADERS_DIR, 1) for d in dirs] return [d.replace(utils.SOONG_INTERMEDIATES_DIR, utils.GENERATED_HEADERS_DIR, 1) for d in dirs]
for src in sorted(src_paths): for src in sorted(srcs_props.keys()):
include_dirs = '' include_dirs = ''
system_include_dirs = '' system_include_dirs = ''
flags = '' flags = ''
relative_install_path = '' relative_install_path = ''
prop_path = os.path.join(src_root, src+'.json') props = srcs_props[src]
props = dict()
try:
with open(prop_path, 'r') as f:
props = json.loads(f.read())
os.unlink(prop_path)
except:
# TODO(b/70312118): Parse from soong build system
if name == 'android.hidl.memory@1.0-impl':
props['RelativeInstallPath'] = 'hw'
if 'ExportedDirs' in props: if 'ExportedDirs' in props:
dirs = rename_generated_dirs(props['ExportedDirs']) dirs = rename_generated_dirs(props['ExportedDirs'])
l = ['include/%s' % d for d in dirs] l = ['include/%s' % d for d in dirs]
@@ -733,7 +724,21 @@ class GenBuildFile(object):
vndk_sp=vndk_sp, vndk_sp=vndk_sp,
vndk_private=vndk_private)) vndk_private=vndk_private))
arch_props = get_arch_props(name, arch, src_paths) srcs_props = dict()
for src in src_paths:
props = dict()
prop_path = os.path.join(src_root, src+'.json')
try:
with open(prop_path, 'r') as f:
props = json.loads(f.read())
os.unlink(prop_path)
except:
# TODO(b/70312118): Parse from soong build system
if name == 'android.hidl.memory@1.0-impl':
props['RelativeInstallPath'] = 'hw'
srcs_props[src] = props
arch_props = get_arch_props(name, arch, srcs_props)
if self._license_in_json: if self._license_in_json:
license = get_license_prop(name) license = get_license_prop(name)
else: else:
@@ -743,6 +748,14 @@ class GenBuildFile(object):
if is_binder32: if is_binder32:
binder32bit = '{ind}binder32bit: true,\n'.format(ind=self.INDENT) binder32bit = '{ind}binder32bit: true,\n'.format(ind=self.INDENT)
min_sdk_version = ''
for src, props in srcs_props.items():
if 'MinSdkVersion' in props:
min_sdk_version = '{ind}min_sdk_version: "{ver}",\n'.format(
ind=self.INDENT,
ver=props['MinSdkVersion'])
break
return ('vndk_prebuilt_shared {{\n' return ('vndk_prebuilt_shared {{\n'
'{ind}name: "{name}",\n' '{ind}name: "{name}",\n'
'{ind}version: "{ver}",\n' '{ind}version: "{ver}",\n'
@@ -751,6 +764,7 @@ class GenBuildFile(object):
'{ind}vendor_available: true,\n' '{ind}vendor_available: true,\n'
'{product_available}' '{product_available}'
'{vndk_props}' '{vndk_props}'
'{min_sdk_version}'
'{license}' '{license}'
'{arch_props}' '{arch_props}'
'}}\n'.format( '}}\n'.format(
@@ -761,6 +775,7 @@ class GenBuildFile(object):
binder32bit=binder32bit, binder32bit=binder32bit,
product_available=product_available, product_available=product_available,
vndk_props=vndk_props, vndk_props=vndk_props,
min_sdk_version=min_sdk_version,
license=license, license=license,
arch_props=arch_props)) arch_props=arch_props))