Explicit record the modules' built-file:installed-file

- This simplifies the logic to get the mapping of built-file to
  installed-file. Previously we used file suffix matching which is error
  prone and not scalable.
- With this change the .odex files will be included automatically.

Bug: 13585955
Change-Id: I4599abf93b9d501bac7aca7758d7f3aee21b3e36
This commit is contained in:
Ying Wang 2014-05-19 13:03:36 -07:00
parent 9b9b98376a
commit 3380d3a1ae
3 changed files with 26 additions and 18 deletions

View File

@ -594,8 +594,12 @@ ALL_MODULES.$(my_register_name).CHECKED := \
$(ALL_MODULES.$(my_register_name).CHECKED) $(LOCAL_CHECKED_MODULE)
ALL_MODULES.$(my_register_name).BUILT := \
$(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ALL_MODULES.$(my_register_name).INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE))
ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED)$(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE))
endif
ifdef LOCAL_PICKUP_FILES
# Files or directories ready to pick up by the build system
# when $(LOCAL_BUILT_MODULE) is done.

View File

@ -33,12 +33,14 @@ endif
built_odex :=
installed_odex :=
built_installed_odex :=
ifdef LOCAL_DEX_PREOPT
dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
ifdef dexpreopt_boot_jar_module
ifeq ($(DALVIK_VM_LIB),libdvm.so)
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
built_installed_odex := $(built_odex):$(installed_odex)
else # libdvm.so
# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
# We use this installed_odex trick to get boot.art installed.
@ -50,6 +52,7 @@ else # boot jar
ifeq ($(DALVIK_VM_LIB),libdvm.so)
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
built_installed_odex := $(built_odex):$(installed_odex)
$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
$(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
@ -72,7 +75,7 @@ $(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
$(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
$(my_dex_preopt_image_filename)
installed_odex := $(call get-odex-file-path,$(DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
built_installed_odex := $(built_odex):$(installed_odex)
# #################################################
# Odex for the 2nd arch
ifdef TARGET_2ND_ARCH
@ -90,8 +93,10 @@ $(built_odex2) : $($(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BU
$(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
$(my_dex_preopt_image_filename)
installed_odex2 := $(call get-odex-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
built_odex += $(built_odex2)
installed_odex += $(call get-odex-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
installed_odex += $(installed_odex2)
built_installed_odex += $(built_odex2):$(installed_odex2)
endif # TARGET_2ND_ARCH
# #################################################
else # must be APPS
@ -111,6 +116,7 @@ $(LOCAL_BUILT_MODULE) $(built_odex) : $($(LOCAL_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ON
$(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
$(my_dex_preopt_image_filename)
installed_odex := $(call get-odex-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
built_installed_odex := $(built_odex):$(installed_odex)
endif # LOCAL_MODULE_CLASS
endif # libart
endif # boot jar
@ -128,7 +134,9 @@ $(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%/$(notdir $(word 1,$(instal
endif
# Add the installed_odex to the list of installed files for this module.
ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(installed_odex)
ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
# Make sure to install the .odex when you run "make <module_name>"
$(my_register_name): $(installed_odex)

View File

@ -14,27 +14,23 @@ my_built_modules :=
my_copy_pairs :=
my_pickup_files :=
# Search for modules' built files and installed files;
# Iterate over modules' built files and installed files;
# Calculate the dest files in the output zip file.
# If for 1 module name we found multiple installed files,
# we use suffix matching to find the corresponding built file.
$(foreach m,$(my_modules),\
$(if $(ALL_MODULES.$(m).INSTALLED),,\
$(if $(ALL_MODULES.$(m).BUILT_INSTALLED),,\
$(warning Unknown installed file for module '$(m)'))\
$(eval my_pickup_files += $(ALL_MODULES.$(m).PICKUP_FILES))\
$(foreach i,$(filter $(TARGET_OUT_ROOT)/%,$(ALL_MODULES.$(m).INSTALLED)),\
$(eval my_suffix := $(suffix $(i))) \
$(if $(my_suffix),\
$(eval my_patt := $(TARGET_OUT_ROOT)/%$(my_suffix)),\
$(eval my_patt := $(TARGET_OUT_ROOT)/%$(notdir $(i))))\
$(eval b := $(filter $(my_patt),$(ALL_MODULES.$(m).BUILT)))\
$(if $(filter 1,$(words $(b))),\
$(eval my_built_modules += $(b))\
$(foreach i, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
$(eval bui_ins := $(subst :,$(space),$(i)))\
$(eval ins := $(word 2,$(bui_ins)))\
$(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
$(eval bui := $(word 1,$(bui_ins)))\
$(eval my_built_modules += $(bui))\
$(eval my_copy_dest := $(patsubst data/%,DATA/%,\
$(patsubst system/%,DATA/%,\
$(patsubst $(PRODUCT_OUT)/%,%,$(i)))))\
$(eval my_copy_pairs += $(b):$(my_staging_dir)/$(my_copy_dest)),\
$(warning Unexpected module built file '$(b)' for module '$(m)'))\
$(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
$(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
))
my_package_zip := $(my_staging_dir)/$(my_package_name).zip