Use BUILD_*_IMAGE flags in add_img_to_target_files.
Modify add_img_to_target_files.py to use the BUILDING_*_IMAGE flags when
deciding whether to create and add a given image to a target files
archive.
To do this, the BUILDING_*_IMAGE flags are now dumped to misc_info.txt.
The origin of this change was to use the BUILDING_USERDATA_IMAGE and
BUILDING_CACHE_IMAGE flags in add_img_to_target_files.py so that we
could reliably turn off the generation of the userdata and cache images.
The other image flags were added for symmetry.
Bug: 130307439
Test: m -j out/target/product/bonito/misc_info.txt
Test: m -j droid dist
Change-Id: I32d5a8d6c9ebb5f329d856030084d698ee8d271d
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 490b44a..45a2a2e 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -741,23 +741,32 @@
# target_files.zip as a prebuilt blob. We consider either of them as
# {vendor,product,system_ext}.img being available, which could be
# used when generating vbmeta.img for AVB.
- has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or
- os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES",
- "vendor.img")))
- has_odm = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "ODM")) or
- os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES",
- "odm.img")))
- has_product = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "PRODUCT")) or
- os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES",
- "product.img")))
- has_system_ext = (os.path.isdir(os.path.join(OPTIONS.input_tmp,
- "SYSTEM_EXT")) or
- os.path.exists(os.path.join(OPTIONS.input_tmp,
- "IMAGES",
- "system_ext.img")))
- has_system = os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM"))
- has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp,
- "SYSTEM_OTHER"))
+ has_vendor = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) and
+ OPTIONS.info_dict.get("building_vendor_image") == "true") or
+ os.path.exists(
+ os.path.join(OPTIONS.input_tmp, "IMAGES", "vendor.img")))
+ has_odm = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "ODM")) and
+ OPTIONS.info_dict.get("building_odm_image") == "true") or
+ os.path.exists(
+ os.path.join(OPTIONS.input_tmp, "IMAGES", "odm.img")))
+ has_product = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "PRODUCT")) and
+ OPTIONS.info_dict.get("building_product_image") == "true") or
+ os.path.exists(
+ os.path.join(OPTIONS.input_tmp, "IMAGES", "product.img")))
+ has_system_ext = (
+ (os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_EXT")) and
+ OPTIONS.info_dict.get("building_system_ext_image") == "true") or
+ os.path.exists(
+ os.path.join(OPTIONS.input_tmp, "IMAGES", "system_ext.img")))
+ has_system = (
+ os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM")) and
+ OPTIONS.info_dict.get("building_system_image") == "true")
+
+ has_system_other = (
+ os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_OTHER")) and
+ OPTIONS.info_dict.get("building_system_other_image") == "true")
+ has_userdata = OPTIONS.info_dict.get("building_userdata_image") == "true"
+ has_cache = OPTIONS.info_dict.get("building_cache_image") == "true"
# Set up the output destination. It writes to the given directory for dir
# mode; otherwise appends to the given ZIP.