Merge "Pass release configuration to create_reference_dumps.py" into main am: 3b20634c59

Original change: https://android-review.googlesource.com/c/platform/development/+/2728816

Change-Id: I8b9ac49d3ba36be6c2d6eda72c056c700e73a312
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hsin-Yi Chen
2023-08-29 09:43:34 +00:00
committed by Automerger Merge Worker
2 changed files with 42 additions and 38 deletions

View File

@@ -5,8 +5,8 @@ import os
import time
from utils import (
AOSP_DIR, SOURCE_ABI_DUMP_EXT_END, SO_EXT, Target,
copy_reference_dump, find_lib_lsdumps, get_build_vars_for_product,
AOSP_DIR, SOURCE_ABI_DUMP_EXT_END, SO_EXT, BuildTarget, Target,
copy_reference_dump, find_lib_lsdumps, get_build_vars,
make_libraries, make_tree, read_lsdump_paths)
@@ -45,14 +45,13 @@ class GetVersionedRefDumpDirStem:
self.binder_bitness, arch)
def make_libs_for_product(libs, product, variant, vndk_version, targets,
def make_libs_for_product(libs, build_target, vndk_version, targets,
exclude_tags):
print('making libs for', product + '-' + variant)
print('making libs for', '-'.join(filter(None, build_target)))
if libs:
make_libraries(product, variant, vndk_version, targets, libs,
exclude_tags)
make_libraries(build_target, vndk_version, targets, libs, exclude_tags)
else:
make_tree(product, variant)
make_tree(build_target)
def tag_to_dir_name(tag):
@@ -95,14 +94,14 @@ def create_source_abi_reference_dumps(args, get_ref_dump_dir_stem,
def create_source_abi_reference_dumps_for_all_products(args):
"""Create reference ABI dumps for all specified products."""
num_processed = 0
for product in args.products:
build_vars = get_build_vars_for_product(
build_target = BuildTarget(product, args.release, args.build_variant)
build_vars = get_build_vars(
['PLATFORM_VNDK_VERSION', 'BOARD_VNDK_VERSION', 'BINDER32BIT',
'PLATFORM_VERSION_CODENAME', 'PLATFORM_SDK_VERSION'],
product, args.build_variant)
build_target)
platform_vndk_version = build_vars[0]
board_vndk_version = build_vars[1]
@@ -126,7 +125,8 @@ def create_source_abi_reference_dumps_for_all_products(args):
if platform_version_codename == 'REL'
else 'current')
targets = [t for t in (Target(True, product), Target(False, product))
targets = [t for t in
(Target(True, build_target), Target(False, build_target))
if t.arch]
if args.ref_dump_dir:
@@ -143,11 +143,11 @@ def create_source_abi_reference_dumps_for_all_products(args):
if not args.no_make_lib:
# Build .lsdump for all the specified libs, or build
# `findlsdumps` if no libs are specified.
make_libs_for_product(args.libs, product, args.build_variant,
make_libs_for_product(args.libs, build_target,
platform_vndk_version, targets,
exclude_tags)
lsdump_paths = read_lsdump_paths(product, args.build_variant,
lsdump_paths = read_lsdump_paths(build_target,
platform_vndk_version, targets,
exclude_tags, build=False)
@@ -175,6 +175,9 @@ def _parse_args():
help='libs to create references for')
parser.add_argument('-products', action='append',
help='products to create references for')
parser.add_argument('-release',
help='release configuration to create references for. '
'e.g., trunk_staging, next.')
parser.add_argument('--build-variant', default='userdebug',
help='build variant to create references for')
parser.add_argument('--compress', action='store_true',

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import collections
import os
import re
import shutil
@@ -35,15 +36,18 @@ DEFAULT_CFLAGS = ['-std=gnu99']
DEFAULT_HEADER_FLAGS = ["-dump-function-declarations"]
DEFAULT_FORMAT = 'ProtobufTextFormat'
BuildTarget = collections.namedtuple(
'BuildTarget', ['product', 'release', 'variant'])
class Target(object):
def __init__(self, is_2nd, product):
def __init__(self, is_2nd, build_target):
extra = '_2ND' if is_2nd else ''
build_vars_to_fetch = ['TARGET_ARCH',
'TARGET{}_ARCH'.format(extra),
'TARGET{}_ARCH_VARIANT'.format(extra),
'TARGET{}_CPU_VARIANT'.format(extra)]
build_vars = get_build_vars_for_product(build_vars_to_fetch, product)
build_vars = get_build_vars(build_vars_to_fetch, build_target)
self.primary_arch = build_vars[0]
assert self.primary_arch != ''
self.arch = build_vars[1]
@@ -150,22 +154,24 @@ def run_header_abi_linker(inputs, output_path, version_script, api, arch,
_validate_dump_content(output_path)
def make_targets(product, variant, targets):
def make_targets(build_target, targets):
make_cmd = ['build/soong/soong_ui.bash', '--make-mode', '-j',
'TARGET_PRODUCT=' + product, 'TARGET_BUILD_VARIANT=' + variant]
'TARGET_PRODUCT=' + build_target.product,
'TARGET_BUILD_VARIANT=' + build_target.variant]
if build_target.release:
make_cmd.append('TARGET_RELEASE=' + build_target.release)
make_cmd += targets
subprocess.check_call(make_cmd, cwd=AOSP_DIR)
def make_tree(product, variant):
def make_tree(build_target):
"""Build all lsdump files."""
return make_targets(product, variant, ['findlsdumps'])
return make_targets(build_target, ['findlsdumps'])
def make_libraries(product, variant, vndk_version, targets, libs,
exclude_tags):
def make_libraries(build_target, vndk_version, targets, libs, exclude_tags):
"""Build lsdump files for specific libs."""
lsdump_paths = read_lsdump_paths(product, variant, vndk_version, targets,
lsdump_paths = read_lsdump_paths(build_target, vndk_version, targets,
exclude_tags, build=True)
make_target_paths = []
for name in libs:
@@ -173,13 +179,12 @@ def make_libraries(product, variant, vndk_version, targets, libs,
raise KeyError('Cannot find lsdump for %s.' % name)
for tag_path_dict in lsdump_paths[name].values():
make_target_paths.extend(tag_path_dict.values())
make_targets(product, variant, make_target_paths)
make_targets(build_target, make_target_paths)
def get_lsdump_paths_file_path(product, variant):
def get_lsdump_paths_file_path(build_target):
"""Get the path to lsdump_paths.txt."""
product_out = get_build_vars_for_product(
['PRODUCT_OUT'], product, variant)[0]
product_out = get_build_vars(['PRODUCT_OUT'], build_target)[0]
return os.path.join(product_out, 'lsdump_paths.txt')
@@ -261,15 +266,15 @@ def _read_lsdump_paths(lsdump_paths_file_path, vndk_version, targets,
return lsdump_paths
def read_lsdump_paths(product, variant, vndk_version, targets, exclude_tags,
def read_lsdump_paths(build_target, vndk_version, targets, exclude_tags,
build):
"""Build lsdump_paths.txt and read the paths."""
lsdump_paths_file_path = get_lsdump_paths_file_path(product, variant)
lsdump_paths_file_path = get_lsdump_paths_file_path(build_target)
lsdump_paths_file_abspath = os.path.join(AOSP_DIR, lsdump_paths_file_path)
if build:
if os.path.lexists(lsdump_paths_file_abspath):
os.unlink(lsdump_paths_file_abspath)
make_targets(product, variant, [lsdump_paths_file_path])
make_targets(build_target, [lsdump_paths_file_path])
return _read_lsdump_paths(lsdump_paths_file_abspath, vndk_version,
targets, exclude_tags)
@@ -324,17 +329,13 @@ def run_and_read_abi_diff(old_dump_path, new_dump_path, arch, lib_name,
return result, output_file.read()
def get_build_vars_for_product(names, product=None, variant=None):
def get_build_vars(names, build_target):
""" Get build system variable for the launched target."""
if product is None and 'ANDROID_PRODUCT_OUT' not in os.environ:
return None
env = os.environ.copy()
if product:
env['TARGET_PRODUCT'] = product
if variant:
env['TARGET_BUILD_VARIANT'] = variant
env['TARGET_PRODUCT'] = build_target.product
env['TARGET_BUILD_VARIANT'] = build_target.variant
if build_target.release:
env['TARGET_RELEASE'] = build_target.release
cmd = [
os.path.join('build', 'soong', 'soong_ui.bash'),
'--dumpvars-mode', '-vars', ' '.join(names),