3a61eeb6cb
To rebuild odex files of Java libraries and apps, we store the jars/apks without stripping the classes.dex inside the platform.zip. We also save the build variables that may affect how we rebuild an odex in pdk_dexpreopt_config.mk in the platform.zip. We store the files and configuration only for libraries/apps that get installed to the system.img (or vendor.img). In PDK fusion build, we auto-generate prebuilt module definitions for the javalib.jar and package.dex.apk carried in the platform.zip, using configuration stored in pdk_dexpreopt_config.mk. With the prebult modules, we override the implicit rule that directly copies the odex from the platform.zip. To rebuild odex of javalib.jar, we added support for prebuilt shared Java library to prebiult_internal.mk. An installable prebuilt Java library is treated as shared Java library, i.e. with classes.dex in the jar instead of a set of .class files. For apks in the platform.zip, we install the stripped version from platform files inside platform.zip, instead of the package.dex.apk, using a new variable LOCAL_REPLACE_PREBUILT_APK_INSTALLED. We can't strip package.dex.apk because we can't re-sign the stripped apk at this point. We generate prebuilt module only if it's not already defined in the source tree. Bug: 27543283 Change-Id: I9e146f8b713d6f57c397fd28d88c9ab700757ca1
81 lines
3.1 KiB
Makefile
81 lines
3.1 KiB
Makefile
####################################
|
|
# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
|
|
#
|
|
####################################
|
|
|
|
# list of boot classpath jars for dexpreopt
|
|
DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
|
|
DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
|
|
PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
|
|
|
|
PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar))
|
|
|
|
DEXPREOPT_BUILD_DIR := $(OUT_DIR)
|
|
DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
|
|
DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
|
|
DEXPREOPT_BOOT_JAR_DIR := system/framework
|
|
DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
|
|
|
|
# The default value for LOCAL_DEX_PREOPT
|
|
DEX_PREOPT_DEFAULT ?= true
|
|
|
|
# The default values for pre-opting: always preopt PIC.
|
|
# Conditional to building on linux, as dex2oat currently does not work on darwin.
|
|
ifeq ($(HOST_OS),linux)
|
|
WITH_DEXPREOPT_PIC ?= true
|
|
WITH_DEXPREOPT ?= true
|
|
# For an eng build only pre-opt the boot image. This gives reasonable performance and still
|
|
# allows a simple workflow: building in frameworks/base and syncing.
|
|
ifeq (eng,$(TARGET_BUILD_VARIANT))
|
|
WITH_DEXPREOPT_BOOT_IMG_ONLY ?= true
|
|
endif
|
|
endif
|
|
|
|
GLOBAL_DEXPREOPT_FLAGS :=
|
|
ifeq ($(WITH_DEXPREOPT_PIC),true)
|
|
# Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true
|
|
GLOBAL_DEXPREOPT_FLAGS += --compile-pic
|
|
endif
|
|
|
|
# $(1): the .jar or .apk to remove classes.dex
|
|
define dexpreopt-remove-classes.dex
|
|
$(hide) zip --quiet --delete $(1) classes.dex; \
|
|
dex_index=2; \
|
|
while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
|
|
let dex_index=dex_index+1; \
|
|
done
|
|
endef
|
|
|
|
# Special rules for building stripped boot jars that override java_library.mk rules
|
|
|
|
# $(1): boot jar module name
|
|
define _dexpreopt-boot-jar-remove-classes.dex
|
|
_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
|
|
_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
|
|
|
|
$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP)
|
|
$$(call copy-file-to-target)
|
|
ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
|
|
$$(call dexpreopt-remove-classes.dex,$$@)
|
|
endif
|
|
|
|
_dbj_jar_no_dex :=
|
|
_dbj_src_jar :=
|
|
endef
|
|
|
|
$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
|
|
|
|
include $(BUILD_SYSTEM)/dex_preopt_libart.mk
|
|
|
|
# Define dexpreopt-one-file based on current default runtime.
|
|
# $(1): the input .jar or .apk file
|
|
# $(2): the output .odex file
|
|
define dexpreopt-one-file
|
|
$(call dex2oat-one-file,$(1),$(2))
|
|
endef
|
|
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
|
|
ifdef TARGET_2ND_ARCH
|
|
$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
|
|
endif # TARGET_2ND_ARCH
|