From a9b9e6e5ff978bca000de4bb7ad915420b11a76d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 14 Aug 2020 17:43:35 -0700 Subject: [PATCH] Merged and dist lists of unused methods from R8 Merge all the proguard_usage.zip files produced by the R8 rules and dist the result. Bug: 151857441 Test: m TARGET_BUILD_APPS=DocumentsUI dist Change-Id: I7e6d73241478016093a203dc7bd86407ab86a4ac --- core/Makefile | 25 +++++++++++++++++++++++++ core/clear_vars.mk | 1 + core/main.mk | 4 ++++ core/soong_app_prebuilt.mk | 8 ++++++++ core/soong_java_prebuilt.mk | 8 ++++++++ 5 files changed, 46 insertions(+) diff --git a/core/Makefile b/core/Makefile index 92723d327..7980c3f6f 100644 --- a/core/Makefile +++ b/core/Makefile @@ -4892,6 +4892,31 @@ $(PROGUARD_DICT_ZIP): $(SOONG_ZIP) sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE) +#------------------------------------------------------------------ +# A zip of Proguard usage files. +# +PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip +# For apps_only build we'll establish the dependency later in build/make/core/main.mk. +ifeq (,$(TARGET_BUILD_UNBUNDLED)) +$(PROGUARD_USAGE_ZIP): \ + $(INSTALLED_SYSTEMIMAGE_TARGET) \ + $(INSTALLED_RAMDISK_TARGET) \ + $(INSTALLED_BOOTIMAGE_TARGET) \ + $(INSTALLED_USERDATAIMAGE_TARGET) \ + $(INSTALLED_VENDORIMAGE_TARGET) \ + $(INSTALLED_PRODUCTIMAGE_TARGET) \ + $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \ + $(INSTALLED_ODMIMAGE_TARGET) \ + $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \ + $(INSTALLED_ODM_DLKMIMAGE_TARGET) \ + $(updater_dep) +endif +$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist +$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS) + @echo "Packaging Proguard usage files." + mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE)) + find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE) + $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE) ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 307c2c227..79f1bb439 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -275,6 +275,7 @@ LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR := LOCAL_SOONG_LINK_TYPE := LOCAL_SOONG_LINT_REPORTS := LOCAL_SOONG_PROGUARD_DICT := +LOCAL_SOONG_PROGUARD_USAGE_ZIP := LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE := LOCAL_SOONG_DEVICE_RRO_DIRS := LOCAL_SOONG_PRODUCT_RRO_DIRS := diff --git a/core/main.mk b/core/main.mk index a3d594bba..897483a2e 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1666,6 +1666,9 @@ ifneq ($(TARGET_BUILD_APPS),) $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files) $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP)) + $(PROGUARD_USAGE_ZIP) : $(apps_only_installed_files) + $(call dist-for-goals,apps_only, $(PROGUARD_USAGE_ZIP)) + $(SYMBOLS_ZIP) : $(apps_only_installed_files) $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP)) @@ -1694,6 +1697,7 @@ else ifeq (,$(TARGET_BUILD_UNBUNDLED)) $(BUILT_OTATOOLS_PACKAGE) \ $(SYMBOLS_ZIP) \ $(PROGUARD_DICT_ZIP) \ + $(PROGUARD_USAGE_ZIP) \ $(COVERAGE_ZIP) \ $(APPCOMPAT_ZIP) \ $(INSTALLED_FILES_FILE) \ diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk index b994b17ad..50ac93a96 100644 --- a/core/soong_app_prebuilt.mk +++ b/core/soong_app_prebuilt.mk @@ -7,6 +7,7 @@ # LOCAL_SOONG_HEADER_JAR # LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR # LOCAL_SOONG_PROGUARD_DICT +# LOCAL_SOONG_PROGUARD_USAGE # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE # LOCAL_SOONG_RRO_DIRS # LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH) @@ -85,6 +86,13 @@ ifdef LOCAL_SOONG_PROGUARD_DICT $(intermediates.COMMON)/proguard_dictionary) endif +ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP + $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\ + $(intermediates.COMMON)/proguard_usage.zip)) + $(call add-dependency,$(LOCAL_BUILT_MODULE),\ + $(intermediates.COMMON)/proguard_usage.zip) +endif + ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE resource_export_package := $(intermediates.COMMON)/package-export.apk resource_export_stamp := $(intermediates.COMMON)/src/R.stamp diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index 05f700d67..5444d960c 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -58,6 +58,14 @@ ifdef LOCAL_SOONG_PROGUARD_DICT $(intermediates.COMMON)/proguard_dictionary) endif +ifdef LOCAL_SOONG_PROGUARD_USAGE + $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\ + $(intermediates.COMMON)/proguard_usage.zip)) + $(call add-dependency,$(LOCAL_BUILT_MODULE),\ + $(intermediates.COMMON)/proguard_usage.zip) +endif + + ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE my_res_package := $(intermediates.COMMON)/package-res.apk