diff --git a/core/Makefile b/core/Makefile index 2aab14333b..62da48a81b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -613,6 +613,7 @@ define generate-userimage-prop-dictionary $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1)) $(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1)) endef @@ -767,7 +768,7 @@ $(call dist-for-goals, sdk_addon, $(INSTALLED_FILES_FILE)) endif systemimage_intermediates := \ - $(call intermediates-dir-for,PACKAGING,systemimage) + $(call intermediates-dir-for,PACKAGING,systemimage) BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img # $(1): output file @@ -877,10 +878,10 @@ boottarball-nodeps btnod: $(FS_GET_STATS) \ # ----------------------------------------------------------------- # data partition image INTERNAL_USERDATAIMAGE_FILES := \ - $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) + $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) userdataimage_intermediates := \ - $(call intermediates-dir-for,PACKAGING,userdata) + $(call intermediates-dir-for,PACKAGING,userdata) BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img define build-userdataimage-target @@ -925,6 +926,35 @@ userdatatarball-nodeps: $(FS_GET_STATS) $(build-userdatatarball-target) +# ----------------------------------------------------------------- +# cache partition image +INTERNAL_CACHEIMAGE_FILES := \ + $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) + +cacheimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,cache) +BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img + +define build-cacheimage-target + $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)") + @mkdir -p $(TARGET_OUT_CACHE) + @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt + $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) + $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE),yaffs) +endef + +# We just build this directly to the install location. +INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET) +$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) + $(build-cacheimage-target) + +.PHONY: cacheimage-nodeps +cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) + $(build-cacheimage-target) + # ----------------------------------------------------------------- # bring in the installer image generation defines if necessary ifeq ($(TARGET_USE_DISKINSTALLER),true) @@ -1006,6 +1036,7 @@ $(BUILT_TARGET_FILES_PACKAGE): \ $(INSTALLED_RECOVERYIMAGE_TARGET) \ $(INSTALLED_SYSTEMIMAGE) \ $(INSTALLED_USERDATAIMAGE_TARGET) \ + $(INSTALLED_CACHEIMAGE_TARGET) \ $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ $(built_ota_tools) \ $(APKCERTS_FILE) \ diff --git a/core/envsetup.mk b/core/envsetup.mk index b564ce6a71..84578808e9 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -214,6 +214,8 @@ TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC) TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES) TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest +TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache + TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR) TARGET_OUT_VENDOR_EXECUTABLES:= $(TARGET_OUT_VENDOR)/bin TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES:= $(TARGET_OUT_VENDOR)/xbin diff --git a/core/main.mk b/core/main.mk index e35f2286fd..057c11bb4a 100644 --- a/core/main.mk +++ b/core/main.mk @@ -743,6 +743,9 @@ endif .PHONY: userdatatarball userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET) +.PHONY: cacheimage +cacheimage: $(INSTALLED_CACHEIMAGE_TARGET) + .PHONY: bootimage bootimage: $(INSTALLED_BOOTIMAGE_TARGET) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index b5140a92e0..8ef8975077 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -83,6 +83,9 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): elif mount_point == "data": if "userdata_size" in glob_dict: d["partition_size"] = str(glob_dict["userdata_size"]) + elif mount_point == "cache": + if "cache_size" in glob_dict: + d["partition_size"] = str(glob_dict["cache_size"]) return d @@ -117,6 +120,8 @@ def main(argv): mount_point = "system" elif image_filename == "userdata.img": mount_point = "data" + elif image_filename == "cache.img": + mount_point = "cache" image_properties = ImagePropFromGlobalDict(glob_dict, mount_point) if not BuildImage(in_dir, image_properties, out_file): diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 4957354af6..1049591c8d 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -138,6 +138,7 @@ def LoadInfoDict(zip): makeint("blocksize") makeint("system_size") makeint("userdata_size") + makeint("cache_size") makeint("recovery_size") makeint("boot_size") diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files index 4388f69c94..7292d551b9 100755 --- a/tools/releasetools/img_from_target_files +++ b/tools/releasetools/img_from_target_files @@ -80,6 +80,34 @@ def AddUserdata(output_zip): os.rmdir(temp_dir) +def AddCache(output_zip): + """Create an empty cache image and store it in output_zip.""" + + print "creating cache.img..." + + # The name of the directory it is making an image out of matters to + # mkyaffs2image. So we create a temp dir, and within it we create an + # empty dir named "cache", and build the image from that. + temp_dir = tempfile.mkdtemp() + user_dir = os.path.join(temp_dir, "cache") + os.mkdir(user_dir) + img = tempfile.NamedTemporaryFile() + + image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, + "cache") + fstab = OPTIONS.info_dict["fstab"] + if fstab: + image_props["fs_type" ] = fstab["/cache"].fs_type + succ = build_image.BuildImage(user_dir, image_props, img.name) + assert succ, "build cache.img image failed" + + common.CheckSize(img.name, "cache.img", OPTIONS.info_dict) + output_zip.write(img.name, "cache.img") + img.close() + os.rmdir(user_dir) + os.rmdir(temp_dir) + + def AddSystem(output_zip): """Turn the contents of SYSTEM into a system image and store it in output_zip.""" @@ -163,6 +191,7 @@ def main(argv): if not bootable_only: AddSystem(output_zip) AddUserdata(output_zip) + AddCache(output_zip) CopyInfo(output_zip) print "cleaning up..."