6db5b0ea9a
Move the dexpreopting logic into Soong. Make modules will be dexpreopted by executing the Soong logic in the standalone dexpreopt_gen binary, which will generate scripts that will perform dexpreopting for each module. Export global configuration as JSON to $OUT/dexpreopt.config, which will be used by dexpreopt_gen and Soong, and per-module JSON configuration that will be used by dexpreopt_gen. This relands I59b20c931ee3e5a8d35eb30da4148691c5095502, I39d580999947ee54cfefe875b57a028be5333bd7, Ie7daa94e107d53eff075ca58dbe721bd9d7fc8c2 and Ica006a007d112c232311435aaac0c0e476232b67, with a minor update to match the changes made to dexpreopt_gen arguments and a fix to correctly keep dexpreopt disabled on mac builds. Bug: 119412419 Bug: 120273280 Test: no differences to dexpreopt outputs on aosp_sailfish system/, only expected changes to dexpreopt outputs on system_other (.vdex files for privileged Soong modules no longer incorrectly contain .dex contents). Change-Id: I25163e91886cea6941afa25cdb529ed053278dcb
109 lines
3.8 KiB
Makefile
109 lines
3.8 KiB
Makefile
###########################################################
|
|
## Standard rules for building a java library.
|
|
##
|
|
###########################################################
|
|
$(call record-module-type,JAVA_LIBRARY)
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
$(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY)
|
|
endif
|
|
|
|
LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
|
|
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
|
|
|
ifneq (,$(LOCAL_ASSET_DIR))
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR)
|
|
endif
|
|
|
|
ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY))
|
|
ifneq (,$(LOCAL_RESOURCE_DIR))
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR)
|
|
endif
|
|
# base_rules.mk looks at this
|
|
all_res_assets :=
|
|
endif
|
|
|
|
LOCAL_BUILT_MODULE_STEM := javalib.jar
|
|
|
|
# For java libraries, other modules should depend on
|
|
# out/target/common/obj/JAVA_LIBRARIES/.../classes.jar.
|
|
# There are some dependencies outside the build system that assume static
|
|
# java libraries produce javalib.jar, so we will copy classes.jar there too.
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
|
common_javalib.jar := $(intermediates.COMMON)/javalib.jar
|
|
dex_preopt_profile_src_file := $(common_javalib.jar)
|
|
LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
|
|
|
|
ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
|
|
LOCAL_PROGUARD_ENABLED :=
|
|
endif
|
|
|
|
ifeq (true,$(EMMA_INSTRUMENT))
|
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
|
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
|
# Exclude jacoco classes from proguard
|
|
LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
|
|
endif # LOCAL_EMMA_INSTRUMENT
|
|
endif # EMMA_INSTRUMENT_STATIC
|
|
else
|
|
LOCAL_EMMA_INSTRUMENT := false
|
|
endif # EMMA_INSTRUMENT
|
|
|
|
my_dex_jar := $(common_javalib.jar)
|
|
|
|
#################################
|
|
include $(BUILD_SYSTEM)/java.mk
|
|
#################################
|
|
|
|
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
|
|
# There are some dependencies outside the build system that assume classes.jar
|
|
# is available as javalib.jar so copy it there too.
|
|
$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar)))
|
|
|
|
$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE)))
|
|
|
|
else # !LOCAL_IS_STATIC_JAVA_LIBRARY
|
|
|
|
$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
|
|
$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
|
$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
|
|
$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN)
|
|
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
|
|
rm -rf $@.parts && mkdir -p $@.parts
|
|
$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
|
|
$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
|
|
$(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip
|
|
rm -rf $@.parts
|
|
$(hide) $(ZIPTIME) $@.tmp
|
|
$(call commit-change-for-toc,$@)
|
|
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
|
|
$(uncompress-dexs)
|
|
$(align-package)
|
|
endif # LOCAL_UNCOMPRESS_DEX
|
|
|
|
.KATI_RESTAT: $(common_javalib.jar)
|
|
|
|
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
|
|
$(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE)))
|
|
|
|
# For libart boot jars, we don't have .odex files.
|
|
else # ! boot jar
|
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
|
|
$(LOCAL_BUILT_MODULE): $(intermediates)/strip.sh
|
|
$(LOCAL_BUILT_MODULE): | $(DEXPREOPT_GEN_DEPS)
|
|
$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d
|
|
$(LOCAL_BUILT_MODULE): $(common_javalib.jar)
|
|
$(PRIVATE_STRIP_SCRIPT) $< $@
|
|
|
|
endif # ! boot jar
|
|
|
|
else # LOCAL_DEX_PREOPT
|
|
$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
|
|
|
|
endif # LOCAL_DEX_PREOPT
|
|
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
|