From fc782ad949515da7b4dda6067b7df3a832936619 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 22 Oct 2018 13:44:27 -0700 Subject: [PATCH] Reduce the propagation of LOCAL_DEX_PREOPT := nostripping nostripping causes confusing double negatives, allow nostripping in LOCAL_DEX_PREOPT and DEFAULT_DEX_PREOPT, but convert to LOCAL_STRIP_DEX outside of dex_preopt_odex_install.mk. Test: m checkbuild Change-Id: I996e9258ce20c394900d9fe937d638bc2ab8589d --- core/clear_vars.mk | 2 ++ core/definitions.mk | 4 ++-- core/dex_preopt.mk | 2 +- core/dex_preopt_odex_install.mk | 15 +++++++++++---- core/java_library.mk | 2 +- core/package_internal.mk | 2 +- core/prebuilt_internal.mk | 8 ++++---- core/soong_app_prebuilt.mk | 2 +- core/soong_java_prebuilt.mk | 2 +- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 07e34e1ad..bcedaba27 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -274,6 +274,7 @@ LOCAL_STATIC_ANDROID_LIBRARIES:= LOCAL_STATIC_JAVA_AAR_LIBRARIES:= LOCAL_STATIC_JAVA_LIBRARIES:= LOCAL_STATIC_LIBRARIES:= +LOCAL_STRIP_DEX:= LOCAL_STRIP_MODULE:= LOCAL_SYSTEM_SHARED_LIBRARIES:=none LOCAL_TARGET_REQUIRED_MODULES:= @@ -284,6 +285,7 @@ LOCAL_TEST_MODULE_TO_PROGUARD_WITH:= LOCAL_TIDY:= LOCAL_TIDY_CHECKS:= LOCAL_TIDY_FLAGS:= +LOCAL_UNCOMPRESS_DEX:= LOCAL_UNINSTALLABLE_MODULE:= LOCAL_UNSTRIPPED_PATH:= LOCAL_USE_AAPT2:=$(USE_AAPT2) diff --git a/core/definitions.mk b/core/definitions.mk index baa2342f3..c9df7006d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2640,12 +2640,12 @@ endef # Copy an apk to a target location while removing classes*.dex # $(1): source file # $(2): destination file -# $(3): LOCAL_DEX_PREOPT, if nostripping then leave classes*.dex +# $(3): LOCAL_STRIP_DEX, if non-empty then strip classes*.dex define dexpreopt-copy-jar $(2): $(1) @echo "Copy: $$@" $$(copy-file-to-target) - $(if $(filter nostripping,$(3)),,$$(call dexpreopt-remove-classes.dex,$$@)) + $(if $(3),$$(call dexpreopt-remove-classes.dex,$$@)) endef # $(1): the .jar or .apk to remove classes.dex. Note that if all dex files diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk index 15270478f..92ed9707f 100644 --- a/core/dex_preopt.mk +++ b/core/dex_preopt.mk @@ -73,7 +73,7 @@ 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 -$(call dexpreopt-copy-jar,$$(_dbj_src_jar),$$(_dbj_jar_no_dex),$(DEX_PREOPT_DEFAULT)) +$(call dexpreopt-copy-jar,$$(_dbj_src_jar),$$(_dbj_jar_no_dex),$(filter-out nostripping,$(DEX_PREOPT_DEFAULT))) _dbj_jar_no_dex := _dbj_src_jar := diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index cd78eda23..62597d14d 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -5,7 +5,6 @@ # We explicitly uncompress APKs of privileged apps, and used by # privileged apps -LOCAL_UNCOMPRESS_DEX := false ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)) ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) LOCAL_UNCOMPRESS_DEX := true @@ -33,6 +32,13 @@ ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined endif endif +ifeq (nostripping,$(LOCAL_DEX_PREOPT)) + LOCAL_DEX_PREOPT := true + LOCAL_STRIP_DEX := +else + LOCAL_STRIP_DEX := true +endif + ifeq (false,$(LOCAL_DEX_PREOPT)) LOCAL_DEX_PREOPT := endif @@ -81,14 +87,14 @@ endif ifeq ($(LOCAL_DEX_PREOPT),true) # Don't strip with dexes we explicitly uncompress (dexopt will not store the dex code). ifeq ($(LOCAL_UNCOMPRESS_DEX),true) - LOCAL_DEX_PREOPT := nostripping + LOCAL_STRIP_DEX := endif # LOCAL_UNCOMPRESS_DEX # system_other isn't there for an OTA, so don't strip # if module is on system, and odex is on system_other. ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) ifneq ($(call install-on-system-other, $(my_module_path)),) - LOCAL_DEX_PREOPT := nostripping + LOCAL_STRIP_DEX := endif # install-on-system-other endif # BOARD_USES_SYSTEM_OTHER_ODEX @@ -320,7 +326,8 @@ ifdef LOCAL_DEX_PREOPT ifeq (true,$(my_generate_dm)) LOCAL_DEX_PREOPT_FLAGS += --copy-dex-files=false - LOCAL_DEX_PREOPT := nostripping + LOCAL_DEX_PREOPT := true + LOCAL_STRIP_DEX := my_built_dm := $(dir $(LOCAL_BUILT_MODULE))generated.dm my_installed_dm := $(patsubst %.apk,%,$(LOCAL_INSTALLED_MODULE)).dm my_copied_vdex := $(dir $(LOCAL_BUILT_MODULE))primary.vdex diff --git a/core/java_library.mk b/core/java_library.mk index 5716f4cc9..e4e51d85c 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -96,7 +96,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" $(call dexpreopt-one-file,$<,$@) -$(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT))) +$(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_STRIP_DEX))) endif # ! boot jar diff --git a/core/package_internal.mk b/core/package_internal.mk index 84d1c2c14..9a52af78d 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -665,7 +665,7 @@ 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)) +ifdef LOCAL_STRIP_DEX $(call dexpreopt-remove-classes.dex,$@) endif endif # LOCAL_DEX_PREOPT diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 809c572f3..a4b58fc66 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -380,9 +380,9 @@ endif $(run-appcompat) endif # module_run_appcompat ifdef LOCAL_DEX_PREOPT -ifneq (nostripping,$(LOCAL_DEX_PREOPT)) +ifdef LOCAL_STRIP_DEX $(call dexpreopt-remove-classes.dex,$@) -endif # LOCAL_DEX_PREOPT != nostripping +endif # LOCAL_STRIP_DEX endif # LOCAL_DEX_PREOPT $(sign-package) # No need for align-package because sign-package takes care of alignment @@ -400,7 +400,7 @@ endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED # can do optimizations based on whether the built module only # contains uncompressed dex code. ifdef LOCAL_DEX_PREOPT -ifeq (nostripping,$(LOCAL_DEX_PREOPT)) +ifndef LOCAL_STRIP_DEX $(built_odex) : $(built_module) $(call dexpreopt-one-file,$<,$@) else @@ -470,7 +470,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file) @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" $(call dexpreopt-one-file,$<,$@) -$(eval $(call dexpreopt-copy-jar,$(my_prebuilt_src_file),$(built_module),$(LOCAL_DEX_PREOPT))) +$(eval $(call dexpreopt-copy-jar,$(my_prebuilt_src_file),$(built_module),$(LOCAL_STRIP_DEX))) endif # boot jar else # ! LOCAL_DEX_PREOPT $(built_module) : $(my_prebuilt_src_file) diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk index d34f3676f..31cb28edc 100644 --- a/core/soong_app_prebuilt.mk +++ b/core/soong_app_prebuilt.mk @@ -69,7 +69,7 @@ endif ifdef LOCAL_DEX_PREOPT $(built_odex): $(LOCAL_SOONG_DEX_JAR) $(call dexpreopt-one-file,$<,$@) - $(eval $(call dexpreopt-copy-jar,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT))) + $(eval $(call dexpreopt-copy-jar,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE),$(LOCAL_STRIP_DEX))) else $(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE))) endif diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index 20bfc662a..288a763ce 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -108,7 +108,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" $(call dexpreopt-one-file,$<,$@) - $(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT))) + $(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_STRIP_DEX))) endif # ! boot jar else # LOCAL_DEX_PREOPT $(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))