diff options
author | Dennis Song <denniscy@google.com> | 2024-02-02 04:10:54 +0000 |
---|---|---|
committer | Dennis Song <denniscy@google.com> | 2024-02-21 06:48:42 +0000 |
commit | fa55c6d3a6319fef503d1d26af4b9657d0dfa2c8 (patch) | |
tree | 31974cd656c38c89060b3baea66bba2c8db529c5 | |
parent | 435c35122a3f3ced5ef12248f8eec45295181051 (diff) | |
download | treble-fa55c6d3a6319fef503d1d26af4b9657d0dfa2c8.tar.gz |
Generate vendor_boot-chd_debug.img while building CHD
Call build_chd_debug_ramdisk while building CHD so that the
vendor_boot-chd_debug.img could be automatically generated
in CI.
Bug: 317942272
Test: build_cf_hybrid_device
Change-Id: I69a3cdbfd07f37b37929575d6fe5145e1da74c4e
-rw-r--r-- | cuttlefish/Android.bp | 23 | ||||
-rw-r--r-- | cuttlefish/build_cf_hybrid_device.py | 32 |
2 files changed, 38 insertions, 17 deletions
diff --git a/cuttlefish/Android.bp b/cuttlefish/Android.bp index 1427963..49a8ad9 100644 --- a/cuttlefish/Android.bp +++ b/cuttlefish/Android.bp @@ -17,18 +17,19 @@ package { } python_library_host { - name: "build_chd_lib", - srcs: [ - "build_chd_utils.py", - ], + name: "build_chd_lib", + srcs: [ + "build_chd_debug_ramdisk.py", + "build_chd_utils.py", + ], } python_binary_host { - name: "build_cf_hybrid_device", - srcs: [ - "build_cf_hybrid_device.py", - ], - libs: [ - "build_chd_lib", - ], + name: "build_cf_hybrid_device", + srcs: [ + "build_cf_hybrid_device.py", + ], + libs: [ + "build_chd_lib", + ], } diff --git a/cuttlefish/build_cf_hybrid_device.py b/cuttlefish/build_cf_hybrid_device.py index 3fb98fd..0207dc3 100644 --- a/cuttlefish/build_cf_hybrid_device.py +++ b/cuttlefish/build_cf_hybrid_device.py @@ -20,9 +20,8 @@ import os import subprocess import tempfile -from build_chd_utils import copy_files -from build_chd_utils import merge_chd_sepolicy -from build_chd_utils import unzip_otatools +from build_chd_debug_ramdisk import add_debug_ramdisk_files +from build_chd_utils import copy_files, merge_chd_sepolicy, unzip_otatools """Test command: @@ -107,15 +106,36 @@ def run(temp_dir): # merge CHD debug sepolicy # TODO (b/315474132): remove this when the CHD sepolicy issue is resolved. + chd_sepolicy = None try: - merge_chd_sepolicy(framework_target_files, vendor_target_files, otatools, - args.output_dir) + chd_sepolicy = merge_chd_sepolicy( + framework_target_files, vendor_target_files, otatools, args.output_dir) except Exception as error: - print(f'Warning cannot generate chd_merged_sepolicy: {error}') + print(f'Warning - cannot generate chd_merged_sepolicy: {error}') # copy files copy_files(args.copy_file, args.output_dir) + # build the CHD vendor boot debug image by adding chd_sepolicy and + # chd_debug_prop (if present) into the Cuttlefish's vendor_boot-debug.img. + files_to_add = [] + if chd_sepolicy and os.path.exists(chd_sepolicy): + files_to_add.append(f'{chd_sepolicy}:precompiled_sepolicy') + chd_debug_prop = os.path.join(args.output_dir, 'chd_debug.prop') + if os.path.exists(chd_debug_prop): + # rename the debug prop file as `adb_debug.prop` because this is the + # file name that property init expects. + files_to_add.append(f'{chd_debug_prop}:adb_debug.prop') + + cf_debug_img = os.path.join(args.output_dir, 'vendor_boot-debug.img') + if files_to_add and os.path.exists(cf_debug_img): + chd_debug_img = os.path.join(args.output_dir, 'vendor_boot-chd_debug.img') + try: + add_debug_ramdisk_files( + cf_debug_img, files_to_add, otatools, temp_dir, chd_debug_img) + except Exception as error: + print(f'Warning - cannot build {chd_debug_img}: {error}') + if __name__ == '__main__': with tempfile.TemporaryDirectory() as temp_dir: |