Run pyformat on merge_target_files.py
Test: n/a
Change-Id: I25c1dc20c367e6b733e9fa4ea77d1873f5ba9a9b
diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py
index da5e93f..5c273c2 100755
--- a/tools/releasetools/merge_target_files.py
+++ b/tools/releasetools/merge_target_files.py
@@ -843,11 +843,12 @@
Args:
temp_dir: Location containing an 'output' directory where target files have
- been extracted, e.g. <temp_dir>/output/SYSTEM, <temp_dir>/output/IMAGES, etc.
+ been extracted, e.g. <temp_dir>/output/SYSTEM, <temp_dir>/output/IMAGES,
+ etc.
framework_meta: The name of a directory containing the special items
extracted from the framework target files package.
- vendor_meta: The name of a directory containing the special items
- extracted from the vendor target files package.
+ vendor_meta: The name of a directory containing the special items extracted
+ from the vendor target files package.
output_target_files_temp_dir: The name of a directory that will be used to
create the output target files package after all the special cases are
processed.
@@ -858,9 +859,7 @@
partitions. Used to filter apexkeys.txt and apkcerts.txt.
vendor_partition_set: Partitions that are considered vendor partitions. Used
to filter apexkeys.txt and apkcerts.txt.
-
- The following are only used if dexpreopt is applied:
-
+ Args used if dexpreopt is applied:
framework_dexpreopt_tools: Location of dexpreopt_tools.zip.
framework_dexpreopt_config: Location of framework's dexpreopt_config.zip.
vendor_dexpreopt_config: Location of vendor's dexpreopt_config.zip.
@@ -915,14 +914,14 @@
def process_dexopt(temp_dir, framework_meta, vendor_meta,
- output_target_files_temp_dir,
- framework_dexpreopt_tools, framework_dexpreopt_config,
- vendor_dexpreopt_config):
+ output_target_files_temp_dir, framework_dexpreopt_tools,
+ framework_dexpreopt_config, vendor_dexpreopt_config):
"""If needed, generates dexopt files for vendor apps.
Args:
temp_dir: Location containing an 'output' directory where target files have
- been extracted, e.g. <temp_dir>/output/SYSTEM, <temp_dir>/output/IMAGES, etc.
+ been extracted, e.g. <temp_dir>/output/SYSTEM, <temp_dir>/output/IMAGES,
+ etc.
framework_meta: The name of a directory containing the special items
extracted from the framework target files package.
vendor_meta: The name of a directory containing the special items extracted
@@ -940,8 +939,7 @@
os.path.join(vendor_meta, *misc_info_path))
if (vendor_misc_info_dict.get('building_with_vsdk') != 'true' or
- framework_dexpreopt_tools is None or
- framework_dexpreopt_config is None or
+ framework_dexpreopt_tools is None or framework_dexpreopt_config is None or
vendor_dexpreopt_config is None):
return
@@ -984,8 +982,10 @@
# package.vdex
# package.odex
dexpreopt_tools_files_temp_dir = os.path.join(temp_dir, 'tools')
- dexpreopt_framework_config_files_temp_dir = os.path.join(temp_dir, 'system_config')
- dexpreopt_vendor_config_files_temp_dir = os.path.join(temp_dir, 'vendor_config')
+ dexpreopt_framework_config_files_temp_dir = os.path.join(
+ temp_dir, 'system_config')
+ dexpreopt_vendor_config_files_temp_dir = os.path.join(temp_dir,
+ 'vendor_config')
extract_items(
target_files=OPTIONS.framework_dexpreopt_tools,
@@ -1000,10 +1000,12 @@
target_files_temp_dir=dexpreopt_vendor_config_files_temp_dir,
extract_item_list=('*',))
- os.symlink(os.path.join(output_target_files_temp_dir, "SYSTEM"),
- os.path.join(temp_dir, "system"))
- os.symlink(os.path.join(output_target_files_temp_dir, "VENDOR"),
- os.path.join(temp_dir, "vendor"))
+ os.symlink(
+ os.path.join(output_target_files_temp_dir, 'SYSTEM'),
+ os.path.join(temp_dir, 'system'))
+ os.symlink(
+ os.path.join(output_target_files_temp_dir, 'VENDOR'),
+ os.path.join(temp_dir, 'vendor'))
# The directory structure for flatteded APEXes is:
#
@@ -1026,7 +1028,7 @@
# com.android.appsearch.apex
# com.android.art.apex
# ...
- apex_root = os.path.join(output_target_files_temp_dir, "SYSTEM", "apex")
+ apex_root = os.path.join(output_target_files_temp_dir, 'SYSTEM', 'apex')
framework_misc_info_dict = common.LoadDictionaryFromFile(
os.path.join(framework_meta, *misc_info_path))
@@ -1094,13 +1096,14 @@
dex_img = 'VENDOR'
# Open vendor_filesystem_config to append the items generated by dexopt.
vendor_file_system_config = open(
- os.path.join(temp_dir, 'output', 'META', 'vendor_filesystem_config.txt'),
- 'a')
+ os.path.join(temp_dir, 'output', 'META',
+ 'vendor_filesystem_config.txt'), 'a')
# Dexpreopt vendor apps.
dexpreopt_config_suffix = '_dexpreopt.config'
- for config in glob.glob(os.path.join(
- dexpreopt_vendor_config_files_temp_dir, '*' + dexpreopt_config_suffix)):
+ for config in glob.glob(
+ os.path.join(dexpreopt_vendor_config_files_temp_dir,
+ '*' + dexpreopt_config_suffix)):
app = os.path.basename(config)[:-len(dexpreopt_config_suffix)]
logging.info('dexpreopt config: %s %s', config, app)
@@ -1110,8 +1113,9 @@
apk_dir = 'priv-app'
apk_path = os.path.join(temp_dir, 'vendor', apk_dir, app, app + '.apk')
if not os.path.exists(apk_path):
- logging.warning('skipping dexpreopt for %s, no apk found in vendor/app '
- 'or vendor/priv-app', app)
+ logging.warning(
+ 'skipping dexpreopt for %s, no apk found in vendor/app '
+ 'or vendor/priv-app', app)
continue
# Generate dexpreopting script. Note 'out_dir' is not the output directory
@@ -1121,10 +1125,11 @@
command = [
os.path.join(dexpreopt_tools_files_temp_dir, 'dexpreopt_gen'),
'-global',
- os.path.join(dexpreopt_framework_config_files_temp_dir, 'dexpreopt.config'),
+ os.path.join(dexpreopt_framework_config_files_temp_dir,
+ 'dexpreopt.config'),
'-global_soong',
- os.path.join(
- dexpreopt_framework_config_files_temp_dir, 'dexpreopt_soong.config'),
+ os.path.join(dexpreopt_framework_config_files_temp_dir,
+ 'dexpreopt_soong.config'),
'-module',
config,
'-dexpreopt_script',
@@ -1137,13 +1142,13 @@
]
# Run the command from temp_dir so all tool paths are its descendants.
- logging.info("running %s", command)
- subprocess.check_call(command, cwd = temp_dir)
+ logging.info('running %s', command)
+ subprocess.check_call(command, cwd=temp_dir)
# Call the generated script.
command = ['sh', 'dexpreopt_app.sh', apk_path]
- logging.info("running %s", command)
- subprocess.check_call(command, cwd = temp_dir)
+ logging.info('running %s', command)
+ subprocess.check_call(command, cwd=temp_dir)
# Output files are in:
#
@@ -1171,14 +1176,17 @@
# TODO(b/188179859): Support for other architectures.
arch = 'arm64'
- dex_destination = os.path.join(temp_dir, 'output', dex_img, apk_dir, app, 'oat', arch)
+ dex_destination = os.path.join(temp_dir, 'output', dex_img, apk_dir, app,
+ 'oat', arch)
os.makedirs(dex_destination)
- dex2oat_path = os.path.join(
- temp_dir, 'out', 'dex2oat_result', 'vendor', apk_dir, app, 'oat', arch)
- shutil.copy(os.path.join(dex2oat_path, 'package.vdex'),
- os.path.join(dex_destination, app + '.vdex'))
- shutil.copy(os.path.join(dex2oat_path, 'package.odex'),
- os.path.join(dex_destination, app + '.odex'))
+ dex2oat_path = os.path.join(temp_dir, 'out', 'dex2oat_result', 'vendor',
+ apk_dir, app, 'oat', arch)
+ shutil.copy(
+ os.path.join(dex2oat_path, 'package.vdex'),
+ os.path.join(dex_destination, app + '.vdex'))
+ shutil.copy(
+ os.path.join(dex2oat_path, 'package.odex'),
+ os.path.join(dex_destination, app + '.odex'))
# Append entries to vendor_file_system_config.txt, such as:
#
@@ -1192,8 +1200,10 @@
vendor_file_system_config.writelines([
vendor_app_prefix + ' 0 2000 755 ' + selabel + '\n',
vendor_app_prefix + '/' + arch + ' 0 2000 755 ' + selabel + '\n',
- vendor_app_prefix + '/' + arch + '/' + app + '.odex 0 0 644 ' + selabel + '\n',
- vendor_app_prefix + '/' + arch + '/' + app + '.vdex 0 0 644 ' + selabel + '\n',
+ vendor_app_prefix + '/' + arch + '/' + app + '.odex 0 0 644 ' +
+ selabel + '\n',
+ vendor_app_prefix + '/' + arch + '/' + app + '.vdex 0 0 644 ' +
+ selabel + '\n',
])
if not use_system_other_odex:
@@ -1202,7 +1212,8 @@
# TODO(b/188179859): Rebuilding a vendor image in GRF mode (e.g., T(framework)
# and S(vendor) may require logic similar to that in
# rebuild_image_with_sepolicy.
- vendor_img = os.path.join(output_target_files_temp_dir, 'IMAGES', 'vendor.img')
+ vendor_img = os.path.join(output_target_files_temp_dir, 'IMAGES',
+ 'vendor.img')
if os.path.exists(vendor_img):
logging.info('Deleting %s', vendor_img)
os.remove(vendor_img)
@@ -1236,9 +1247,7 @@
vendor instance.
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
devices and write it to the system image.
-
- The following are only used if dexpreopt is applied:
-
+ Args used if dexpreopt is applied:
framework_dexpreopt_tools: Location of dexpreopt_tools.zip.
framework_dexpreopt_config: Location of framework's dexpreopt_config.zip.
vendor_dexpreopt_config: Location of vendor's dexpreopt_config.zip.
@@ -1535,9 +1544,7 @@
vendor_otatools: Path to an otatools zip used for recompiling vendor images.
rebuild_sepolicy: If true, rebuild odm.img (if target uses ODM) or
vendor.img using a merged precompiled_sepolicy file.
-
- The following are only used if dexpreopt is applied:
-
+ Args used if dexpreopt is applied:
framework_dexpreopt_tools: Location of dexpreopt_tools.zip.
framework_dexpreopt_config: Location of framework's dexpreopt_config.zip.
vendor_dexpreopt_config: Location of vendor's dexpreopt_config.zip.
@@ -1820,7 +1827,8 @@
rebuild_sepolicy=OPTIONS.rebuild_sepolicy,
framework_dexpreopt_tools=OPTIONS.framework_dexpreopt_tools,
framework_dexpreopt_config=OPTIONS.framework_dexpreopt_config,
- vendor_dexpreopt_config=OPTIONS.vendor_dexpreopt_config), OPTIONS.keep_tmp)
+ vendor_dexpreopt_config=OPTIONS.vendor_dexpreopt_config),
+ OPTIONS.keep_tmp)
if __name__ == '__main__':