diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index 10b41bdc7..c3d47f79a 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -69,61 +69,24 @@ ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) # For a Java library, we build odex for both 1st arch and 2nd arch, if we have one. # ################################################# # Odex for the 1st arch -built_odex := $(call get-odex-file-path,$(DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE)) -ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION -my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION) -else -my_dex_preopt_image_location := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) -endif -my_dex_preopt_image_filename := $(call get-image-file-path,$(DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location)) -$(built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := -$(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) -$(built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location) -$(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) +my_2nd_arch_prefix := +include $(BUILD_SYSTEM)/setup_one_odex.mk # ################################################# # Odex for the 2nd arch ifdef TARGET_2ND_ARCH -built_odex2 := $(call get-odex-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE)) -ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION -my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION) -else -my_dex_preopt_image_location := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) -endif -my_dex_preopt_image_filename := $(call get-image-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location)) -$(built_odex2): PRIVATE_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) -$(built_odex2): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) -$(built_odex2): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location) -$(built_odex2) : $($(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ - $(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 += $(installed_odex2) -built_installed_odex += $(built_odex2):$(installed_odex2) +my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) +include $(BUILD_SYSTEM)/setup_one_odex.mk endif # TARGET_2ND_ARCH # ################################################# else # must be APPS -# For an app, we build for the multilib arch it's targeted for. -built_odex := $(call get-odex-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE)) -ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION -my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION) -else -my_dex_preopt_image_location := $($(LOCAL_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) -endif -my_dex_preopt_image_filename := $(call get-image-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location)) -$(built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) -$(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) -$(built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location) -$(built_odex) : $($(LOCAL_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ - $(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) +# The preferred arch +my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) +include $(BUILD_SYSTEM)/setup_one_odex.mk +ifeq ($(LOCAL_MULTILIB),both) +# The non-preferred arch +my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) +include $(BUILD_SYSTEM)/setup_one_odex.mk +endif # LOCAL_MULTILIB is both endif # LOCAL_MODULE_CLASS endif # libart endif # boot jar diff --git a/core/package_internal.mk b/core/package_internal.mk index 0d6f9eafd..d1e421248 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -403,7 +403,8 @@ endif ## Rule to build the odex file ifdef LOCAL_DEX_PREOPT $(built_odex): PRIVATE_DEX_FILE := $(built_dex) -$(built_odex) : $(built_dex) +# Use pattern rule - we may have multiple built odex files. +$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) $(hide) mkdir -p $(dir $@) && rm -f $@ $(add-dex-to-package) $(hide) mv $@ $@.input diff --git a/core/setup_one_odex.mk b/core/setup_one_odex.mk new file mode 100644 index 000000000..ec8a28a5b --- /dev/null +++ b/core/setup_one_odex.mk @@ -0,0 +1,39 @@ +# +# Copyright (C) 2014 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Set up variables and dependency for one odex file +# Input variables: my_2nd_arch_prefix +# Output(modified) variables: built_odex, installed_odex, built_installed_odex + +my_built_odex := $(call get-odex-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE)) +ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION +my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION) +else +my_dex_preopt_image_location := $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) +endif +my_dex_preopt_image_filename := $(call get-image-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location)) +$(my_built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix) +$(my_built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) +$(my_built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location) +$(my_built_odex) : $($(my_2nd_arch_prefix)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ + $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \ + $(my_dex_preopt_image_filename) + +my_installed_odex := $(call get-odex-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE)) + +built_odex += $(my_built_odex) +installed_odex += $(my_installed_odex) +built_installed_odex += $(my_built_odex):$(my_installed_odex)