From 01a4f9b2e317a0e945d4ddfb620834315902778f Mon Sep 17 00:00:00 2001 From: Rob Seymour Date: Fri, 25 Mar 2022 18:28:01 +0000 Subject: [PATCH] Do not install host snapshot modules with existing prebuilts. Host fake snapshot includes a prebuilt attribute for a host module that already contains a prebuilt version in the source tree. When installing the host snapshot ignore any modules that already contains a prebuilt version. Bug: 225890931 Test: m HOST_FAKE_SNAPSHOT_ENABLE=true host-fake-snapshot dist Test: install fake snapshot with update.py and validate prebuilt modules are not included Change-Id: Ia8bb44c00ad5fc448ab9110d840d9059ae3294f9 --- vendor_snapshot/update.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vendor_snapshot/update.py b/vendor_snapshot/update.py index e209584b7..9563380fe 100644 --- a/vendor_snapshot/update.py +++ b/vendor_snapshot/update.py @@ -111,6 +111,7 @@ JSON_TO_BP = { 'Required': 'required', 'Filename': 'filename', 'CrateName': 'crate_name', + 'Prebuilt': 'prebuilt', } SANITIZER_VARIANT_PROPS = { @@ -406,16 +407,22 @@ def convert_json_host_data_to_bp(mod, install_dir): All host modules are created as a cc_prebuilt_binary blueprint module with the prefer attribute set to true. + Modules that already have a prebuilt are not created. + Args: mod: JSON definition of the module install_dir: installation directory of the host snapshot """ rust_proc_macro = mod.pop('RustProcMacro', False) prop = convert_json_data_to_bp_prop(mod, install_dir) + if 'prebuilt' in prop: + return + if not rust_proc_macro: prop['host_supported'] = True prop['device_supported'] = False prop['stl'] = 'none' + prop['prefer'] = True ## Move install file to host source file prop['target'] = dict() @@ -449,7 +456,8 @@ def gen_host_bp_file(install_dir): props = json.load(rfp) for mod in props: prop = convert_json_host_data_to_bp(mod, install_dir) - wfp.write(prop) + if prop: + wfp.write(prop) def gen_bp_files(image, vndk_dir, install_dir, snapshot_version): """Generates Android.bp for each archtecture. @@ -657,7 +665,7 @@ def check_host_usage(install_dir, ninja_binary, ninja_file, goals, output): with open(output, 'w') as f: f.write('vsdk_host_tools = [ \n') for m in sorted(used_modules): - f.write(' "%s", \n' % m) + f.write(' "%s",\n' % m) f.write('] \n') def check_module_usage(install_dir, ninja_binary, image, ninja_file, goals,