forked from openkylin/platform_build
Rebuild odex files in PDK fusion build.
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
This commit is contained in:
parent
914b37f4e3
commit
3a61eeb6cb
|
@ -1202,16 +1202,53 @@ systemtarball-nodeps: $(FS_GET_STATS) \
|
|||
.PHONY: stnod
|
||||
stnod: systemtarball-nodeps
|
||||
|
||||
#######
|
||||
# -----------------------------------------------------------------
|
||||
## platform.zip: system, plus other files to be used in PDK fusion build,
|
||||
## in a zip file
|
||||
##
|
||||
## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
|
||||
## The variable will be typically set from BoardConfig.mk.
|
||||
## Files under out dir will be rejected to prevent possible conflicts with other rules.
|
||||
pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
|
||||
$(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
|
||||
pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
|
||||
$(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
|
||||
pdk_classes_dex := $(strip \
|
||||
$(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
|
||||
$(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk))
|
||||
|
||||
pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
|
||||
$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
|
||||
$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
|
||||
$(pdk_odex_config_mk) :
|
||||
@echo "PDK odex config makefile: $@"
|
||||
$(hide) mkdir -p $(dir $@)
|
||||
$(hide) echo "# Auto-generated. Do not modify." > $@
|
||||
$(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
|
||||
$(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
|
||||
$(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
|
||||
)
|
||||
$(foreach m,$(PRIVATE_APPS),\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).PROPRIETARY_MODULE:=$(DEXPREOPT.$(m).PROPRIETARY_MODULE)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
|
||||
$(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
|
||||
)
|
||||
|
||||
PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
|
||||
INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
|
||||
$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES)
|
||||
|
||||
$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
|
||||
$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
|
||||
$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk)
|
||||
$(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
|
||||
$(hide) rm -f $@
|
||||
$(hide) cd $(dir $@) && zip -qryX $(notdir $@) \
|
||||
|
@ -1228,6 +1265,9 @@ endif
|
|||
ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
|
||||
$(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)
|
||||
endif
|
||||
@# Add dex-preopt files and config.
|
||||
$(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES)))
|
||||
$(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG)
|
||||
|
||||
.PHONY: platform
|
||||
platform: $(INSTALLED_PLATFORM_ZIP)
|
||||
|
@ -1240,7 +1280,7 @@ ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
|
|||
$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
|
||||
endif
|
||||
|
||||
#######
|
||||
# -----------------------------------------------------------------
|
||||
## boot tarball
|
||||
define build-boottarball-target
|
||||
$(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
|
||||
|
|
|
@ -196,6 +196,9 @@ LOCAL_NOTICE_FILE:=
|
|||
LOCAL_USE_AAPT2:=$(USE_AAPT2)
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES:=
|
||||
LOCAL_SHARED_ANDROID_LIBRARIES:=
|
||||
# Used to replace the installed file of a presigned prebuilt apk in PDK fusion build,
|
||||
# to avoid installing the presigned apks with classes.dex unstripped.
|
||||
LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=
|
||||
|
||||
# arch specific variables
|
||||
LOCAL_SRC_FILES_$(TARGET_ARCH):=
|
||||
|
|
|
@ -449,6 +449,8 @@ ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
|
|||
endif
|
||||
endif
|
||||
|
||||
BUILD_PLATFORM_ZIP := $(filter platform platform-java,$(MAKECMDGOALS))
|
||||
|
||||
#
|
||||
# Tools that are prebuilts for TARGET_BUILD_APPS
|
||||
#
|
||||
|
|
|
@ -2357,7 +2357,12 @@ endef
|
|||
|
||||
#TODO: update the manifest to point to the dex file
|
||||
define add-dex-to-package
|
||||
$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $@
|
||||
$(call add-dex-to-package-arg,$@)
|
||||
endef
|
||||
|
||||
# $(1): the package file.
|
||||
define add-dex-to-package-arg
|
||||
$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
|
||||
endef
|
||||
|
||||
# Add java resources added by the current module.
|
||||
|
@ -2396,12 +2401,17 @@ endef
|
|||
# Sign a package using the specified key/cert.
|
||||
#
|
||||
define sign-package
|
||||
$(hide) mv $@ $@.unsigned
|
||||
$(call sign-package-arg,$@)
|
||||
endef
|
||||
|
||||
# $(1): the package file we are signing.
|
||||
define sign-package-arg
|
||||
$(hide) mv $(1) $(1).unsigned
|
||||
$(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) -jar $(SIGNAPK_JAR) \
|
||||
--min-sdk-version $(call get-package-min-sdk-version-int,$@.unsigned) \
|
||||
$(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \
|
||||
$(PRIVATE_ADDITIONAL_CERTIFICATES) $@.unsigned $@.signed
|
||||
$(hide) mv $@.signed $@
|
||||
$(PRIVATE_ADDITIONAL_CERTIFICATES) $(1).unsigned $(1).signed
|
||||
$(hide) mv $(1).signed $(1)
|
||||
endef
|
||||
|
||||
# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
|
||||
|
|
|
@ -31,6 +31,12 @@ ifeq ($(HOST_OS),linux)
|
|||
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; \
|
||||
|
|
|
@ -105,5 +105,6 @@ $(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
|
|||
--include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
|
||||
--abort-on-hard-verifier-error \
|
||||
--no-inline-from=core-oj.jar \
|
||||
$(PRIVATE_DEX_PREOPT_FLAGS)
|
||||
$(PRIVATE_DEX_PREOPT_FLAGS) \
|
||||
$(GLOBAL_DEXPREOPT_FLAGS)
|
||||
endef
|
||||
|
|
|
@ -31,11 +31,6 @@ $(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$($(my_
|
|||
$(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES := $(addprefix $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)),\
|
||||
$(LIBART_TARGET_BOOT_ART_EXTRA_FILES))
|
||||
|
||||
# Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true
|
||||
ifeq (true,$(WITH_DEXPREOPT_PIC))
|
||||
PRODUCT_DEX_PREOPT_BOOT_FLAGS += --compile-pic
|
||||
endif
|
||||
|
||||
# If we have a compiled-classes file, create a parameter.
|
||||
COMPILED_CLASSES_FLAGS :=
|
||||
ifneq ($(COMPILED_CLASSES),)
|
||||
|
@ -77,4 +72,4 @@ $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGE
|
|||
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
|
||||
--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
|
||||
--multi-image --no-inline-from=core-oj.jar \
|
||||
$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(COMPILED_CLASSES_FLAGS)
|
||||
$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(GLOBAL_DEXPREOPT_FLAGS) $(COMPILED_CLASSES_FLAGS)
|
||||
|
|
|
@ -88,6 +88,9 @@ endif # TARGET_2ND_ARCH
|
|||
endif # LOCAL_MODULE_CLASS
|
||||
endif # boot jar
|
||||
|
||||
built_odex := $(strip $(built_odex))
|
||||
installed_odex := $(strip $(installed_odex))
|
||||
|
||||
ifdef built_odex
|
||||
ifndef LOCAL_DEX_PREOPT_FLAGS
|
||||
LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
|
||||
|
@ -96,11 +99,6 @@ LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
|
|||
endif
|
||||
endif
|
||||
|
||||
# Compile apps with position-independent code if WITH_DEXPREOPT_PIC=true
|
||||
ifeq (true,$(WITH_DEXPREOPT_PIC))
|
||||
LOCAL_DEX_PREOPT_FLAGS += --compile-pic
|
||||
endif
|
||||
|
||||
$(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
|
||||
|
||||
# Use pattern rule - we may have multiple installed odex files.
|
||||
|
@ -116,6 +114,19 @@ endif
|
|||
ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
|
||||
ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
|
||||
|
||||
# Record dex-preopt config.
|
||||
DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
|
||||
DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
|
||||
DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
|
||||
DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
|
||||
DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE)
|
||||
DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
|
||||
DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
|
||||
DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
|
||||
DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
|
||||
$(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
|
||||
|
||||
|
||||
# Make sure to install the .odex when you run "make <module_name>"
|
||||
$(my_register_name): $(installed_odex)
|
||||
|
||||
|
|
|
@ -545,6 +545,11 @@ endif
|
|||
|
||||
$(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk)))
|
||||
|
||||
ifdef PDK_FUSION_PLATFORM_ZIP
|
||||
# Bring in the PDK platform.zip modules.
|
||||
include $(BUILD_SYSTEM)/pdk_fusion_modules.mk
|
||||
endif # PDK_FUSION_PLATFORM_ZIP
|
||||
|
||||
endif # dont_bother
|
||||
|
||||
endif # ONE_SHOT_MAKEFILE
|
||||
|
@ -788,7 +793,7 @@ overridden_packages := $(call get-package-overrides,$(modules_to_install))
|
|||
ifdef overridden_packages
|
||||
# old_modules_to_install := $(modules_to_install)
|
||||
modules_to_install := \
|
||||
$(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
|
||||
$(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex), \
|
||||
$(modules_to_install))
|
||||
endif
|
||||
#$(error filtered out
|
||||
|
|
|
@ -541,13 +541,17 @@ endif
|
|||
ifeq ($(full_classes_jar),)
|
||||
# We don't build jar, need to add the Java resources here.
|
||||
$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
|
||||
else
|
||||
else # full_classes_jar
|
||||
$(add-dex-to-package)
|
||||
endif
|
||||
endif # full_classes_jar
|
||||
ifdef LOCAL_JACK_ENABLED
|
||||
$(add-carried-jack-resources)
|
||||
endif
|
||||
ifdef LOCAL_DEX_PREOPT
|
||||
ifneq ($(BUILD_PLATFORM_ZIP),)
|
||||
@# Keep a copy of apk with classes.dex unstripped
|
||||
$(hide) cp -f $@ $(dir $@)package.dex.apk
|
||||
endif # BUILD_PLATFORM_ZIP
|
||||
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
||||
$(call dexpreopt-remove-classes.dex,$@)
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
# Auto-generate module defitions from platform.zip.
|
||||
# We use these rules to rebuild .odex files of the .jar/.apk inside the platform.zip.
|
||||
#
|
||||
|
||||
pdk_dexpreopt_config_mk := $(TARGET_OUT_INTERMEDIATES)/pdk_dexpreopt_config.mk
|
||||
|
||||
$(shell rm -f $(pdk_dexpreopt_config_mk) && mkdir -p $(dir $(pdk_dexpreopt_config_mk)) && \
|
||||
unzip -qo $(PDK_FUSION_PLATFORM_ZIP) -d $(dir $(pdk_dexpreopt_config_mk)) pdk_dexpreopt_config.mk 2>/dev/null)
|
||||
|
||||
-include $(pdk_dexpreopt_config_mk)
|
||||
|
||||
# Define a PDK prebuilt module that comes from platform.zip.
|
||||
# Must be called with $(eval)
|
||||
define prebuilt-pdk-java-module
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$(1)
|
||||
LOCAL_MODULE_CLASS:=$(2)
|
||||
# Use LOCAL_PREBUILT_MODULE_FILE instead of LOCAL_SRC_FILES so we don't need to deal with LOCAL_PATH.
|
||||
LOCAL_PREBUILT_MODULE_FILE:=$(3)
|
||||
LOCAL_DEX_PREOPT:=$(4)
|
||||
LOCAL_MULTILIB:=$(5)
|
||||
LOCAL_DEX_PREOPT_FLAGS:=$(6)
|
||||
LOCAL_BUILT_MODULE_STEM:=$(7)
|
||||
LOCAL_MODULE_SUFFIX:=$(suffix $(7))
|
||||
LOCAL_PRIVILEGED_MODULE:=$(8)
|
||||
LOCAL_PROPRIETARY_MODULE:=$(9)
|
||||
LOCAL_MODULE_TARGET_ARCH:=$(10)
|
||||
LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=$(11)
|
||||
LOCAL_CERTIFICATE:=PRESIGNED
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
# The source prebuilts are extracted in the rule of _pdk_fusion_stamp.
|
||||
# Use a touch rule to establish the dependency.
|
||||
$(3) $(11) : $(_pdk_fusion_stamp)
|
||||
$(hide) if [ ! -f $$@ ]; then \
|
||||
echo 'Error: $$@ does not exist. Check your platform.zip.' 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(hide) touch $$@
|
||||
endef
|
||||
|
||||
##### Java libraries.
|
||||
# Only set up rules for modules that aren't built from source.
|
||||
pdk_prebuilt_libraries := $(foreach l,$(PDK.DEXPREOPT.JAVA_LIBRARIES),\
|
||||
$(if $(MODULE.TARGET.JAVA_LIBRARIES.$(l)),,$(l)))
|
||||
|
||||
$(foreach l,$(pdk_prebuilt_libraries), $(eval \
|
||||
$(call prebuilt-pdk-java-module,\
|
||||
$(l),\
|
||||
JAVA_LIBRARIES,\
|
||||
$(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(l).SRC),\
|
||||
$(PDK.DEXPREOPT.$(l).DEX_PREOPT),\
|
||||
$(PDK.DEXPREOPT.$(l).MULTILIB),\
|
||||
$(PDK.DEXPREOPT.$(l).DEX_PREOPT_FLAGS),\
|
||||
javalib.jar,\
|
||||
)))
|
||||
|
||||
###### Apps.
|
||||
pdk_prebuilt_apps := $(foreach a,$(PDK.DEXPREOPT.APPS),\
|
||||
$(if $(MODULE.TARGET.APPS.$(a)),,$(a)))
|
||||
|
||||
$(foreach a,$(pdk_prebuilt_apps), $(eval \
|
||||
$(call prebuilt-pdk-java-module,\
|
||||
$(a),\
|
||||
APPS,\
|
||||
$(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).SRC),\
|
||||
$(PDK.DEXPREOPT.$(a).DEX_PREOPT),\
|
||||
$(PDK.DEXPREOPT.$(a).MULTILIB),\
|
||||
$(PDK.DEXPREOPT.$(a).DEX_PREOPT_FLAGS),\
|
||||
package.apk,\
|
||||
$(PDK.DEXPREOPT.$(a).PRIVILEGED_MODULE),\
|
||||
$(PDK.DEXPREOPT.$(a).PROPRIETARY_MODULE),\
|
||||
$(PDK.DEXPREOPT.$(a).TARGET_ARCH),\
|
||||
$(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).STRIPPED_SRC),\
|
||||
)))
|
|
@ -77,6 +77,12 @@ ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
|
||||
prebuilt_module_is_dex_javalib := true
|
||||
else
|
||||
prebuilt_module_is_dex_javalib :=
|
||||
endif
|
||||
|
||||
ifeq ($(LOCAL_MODULE_CLASS),APPS)
|
||||
LOCAL_BUILT_MODULE_STEM := package.apk
|
||||
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
|
||||
|
@ -203,16 +209,23 @@ else
|
|||
endif
|
||||
|
||||
# Disable dex-preopt of prebuilts to save space, if requested.
|
||||
ifndef LOCAL_DEX_PREOPT
|
||||
ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
|
||||
LOCAL_DEX_PREOPT := false
|
||||
endif
|
||||
endif
|
||||
|
||||
#######################################
|
||||
# defines built_odex along with rule to install odex
|
||||
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
|
||||
#######################################
|
||||
# Sign and align non-presigned .apks.
|
||||
ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
|
||||
# There is a replacement for the prebuilt .apk we can install without any processing.
|
||||
$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP)
|
||||
$(transform-prebuilt-to-target)
|
||||
|
||||
else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
|
||||
# Sign and align non-presigned .apks.
|
||||
# The embedded prebuilt jni to uncompress.
|
||||
ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
|
||||
# For PRESIGNED apks we must uncompress every .so file:
|
||||
|
@ -229,18 +242,25 @@ $(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
|
|||
$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT)
|
||||
$(transform-prebuilt-to-target)
|
||||
$(uncompress-shared-libs)
|
||||
ifdef LOCAL_DEX_PREOPT
|
||||
ifneq ($(BUILD_PLATFORM_ZIP),)
|
||||
@# Keep a copy of apk with classes.dex unstripped
|
||||
$(hide) cp -f $@ $(dir $@)package.dex.apk
|
||||
endif # BUILD_PLATFORM_ZIP
|
||||
endif # LOCAL_DEX_PREOPT
|
||||
ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
|
||||
@# Only strip out files if we can re-sign the package.
|
||||
ifdef LOCAL_DEX_PREOPT
|
||||
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
||||
$(call dexpreopt-remove-classes.dex,$@)
|
||||
endif
|
||||
endif
|
||||
endif # LOCAL_DEX_PREOPT != nostripping
|
||||
endif # LOCAL_DEX_PREOPT
|
||||
$(sign-package)
|
||||
# No need for align-package because sign-package takes care of alignment
|
||||
else
|
||||
else # LOCAL_CERTIFICATE == PRESIGNED
|
||||
$(align-package)
|
||||
endif
|
||||
endif # LOCAL_CERTIFICATE
|
||||
endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
|
||||
|
||||
###############################
|
||||
## Rule to build the odex file
|
||||
|
@ -285,18 +305,50 @@ $(my_register_name): $(installed_apk_splits)
|
|||
endif # LOCAL_PACKAGE_SPLITS
|
||||
|
||||
else # LOCAL_MODULE_CLASS != APPS
|
||||
ifeq ($(prebuilt_module_is_dex_javalib),true)
|
||||
# This is a target shared library, i.e. a jar with classes.dex.
|
||||
#######################################
|
||||
# defines built_odex along with rule to install odex
|
||||
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
|
||||
#######################################
|
||||
ifdef LOCAL_DEX_PREOPT
|
||||
ifneq ($(dexpreopt_boot_jar_module),) # boot jar
|
||||
# boot jar's rules are defined in dex_preopt.mk
|
||||
dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
|
||||
$(built_module) : $(dexpreopted_boot_jar) | $(ACP)
|
||||
$(call copy-file-to-target)
|
||||
|
||||
# For libart boot jars, we don't have .odex files.
|
||||
else # ! boot jar
|
||||
$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
# Use pattern rule - we may have multiple built odex files.
|
||||
$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file)
|
||||
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
|
||||
$(call dexpreopt-one-file,$<,$@)
|
||||
|
||||
$(built_module) : $(my_prebuilt_src_file) | $(ACP)
|
||||
$(call copy-file-to-target)
|
||||
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
||||
$(call dexpreopt-remove-classes.dex,$@)
|
||||
endif
|
||||
endif # boot jar
|
||||
else # ! LOCAL_DEX_PREOPT
|
||||
$(built_module) : $(my_prebuilt_src_file) | $(ACP)
|
||||
$(call copy-file-to-target)
|
||||
endif # LOCAL_DEX_PREOPT
|
||||
|
||||
else # ! prebuilt_module_is_dex_javalib
|
||||
ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
|
||||
$(built_module) : $(my_prebuilt_src_file)
|
||||
$(transform-prebuilt-to-target-strip-comments)
|
||||
else
|
||||
ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
|
||||
else ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
|
||||
$(built_module) : $(my_prebuilt_src_file) | $(ACP)
|
||||
$(transform-prebuilt-to-target)
|
||||
else
|
||||
$(built_module) : $(my_prebuilt_src_file)
|
||||
$(copy-file-to-target-with-cp)
|
||||
endif
|
||||
endif
|
||||
endif # ! prebuilt_module_is_dex_javalib
|
||||
endif # LOCAL_MODULE_CLASS != APPS
|
||||
|
||||
ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
|
||||
|
@ -304,13 +356,18 @@ my_src_jar := $(my_prebuilt_src_file)
|
|||
ifeq ($(LOCAL_IS_HOST_MODULE),)
|
||||
# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
|
||||
# while the deps should be in the common dir, so we make a copy in the common dir.
|
||||
# For nonstatic library, $(common_javalib_jar) is the dependency file,
|
||||
# while $(common_classes_jar) is used to link.
|
||||
common_classes_jar := $(intermediates.COMMON)/classes.jar
|
||||
common_javalib_jar := $(intermediates.COMMON)/javalib.jar
|
||||
|
||||
$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
|
||||
ifeq ($(prebuilt_module_is_dex_javalib),true)
|
||||
# For prebuilt shared Java library we don't have classes.jar.
|
||||
$(common_javalib_jar) : $(my_src_jar) | $(ACP)
|
||||
$(transform-prebuilt-to-target)
|
||||
|
||||
else # ! prebuilt_module_is_dex_javalib
|
||||
|
||||
my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
|
||||
ifneq ($(my_src_aar),)
|
||||
# This is .aar file, archive of classes.jar and Android resources.
|
||||
|
@ -323,6 +380,7 @@ $(my_src_jar) : $(my_src_aar)
|
|||
$(hide) touch $@
|
||||
|
||||
endif
|
||||
|
||||
$(common_classes_jar) : $(my_src_jar) | $(ACP)
|
||||
$(transform-prebuilt-to-target)
|
||||
|
||||
|
@ -363,8 +421,11 @@ endif # $(my_src_aar)
|
|||
endif # LOCAL_USE_AAPT2
|
||||
# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
|
||||
$(built_module) : $(common_javalib_jar)
|
||||
|
||||
endif # ! prebuilt_module_is_dex_javalib
|
||||
endif # LOCAL_IS_HOST_MODULE is not set
|
||||
|
||||
ifneq ($(prebuilt_module_is_dex_javalib),true)
|
||||
ifneq ($(LOCAL_JILL_FLAGS),)
|
||||
$(error LOCAL_JILL_FLAGS is not supported any more, please use jack options in LOCAL_JACK_FLAGS instead)
|
||||
endif
|
||||
|
@ -380,6 +441,7 @@ $(intermediates.COMMON)/classes.jack : $(my_src_jar) $(LOCAL_MODULE_MAKEFILE_DEP
|
|||
$(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack
|
||||
touch $@
|
||||
|
||||
endif # ! prebuilt_module_is_dex_javalib
|
||||
endif # JAVA_LIBRARIES
|
||||
|
||||
$(built_module) : $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||
|
|
Loading…
Reference in New Issue