From 485c9cd400f9b4bdaef9c9b10add3dcc38e5ec60 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 4 Feb 2019 15:28:51 -0800 Subject: [PATCH] Move hiddenapi singleton rules to Soong Hiddenapi rules are now in build/soong/java/hiddenapi_singleton.go. This effectively requires any module in PRODUCT_BOOT_JARS to be defined in Soong. Bug: 123645297 Test: m checkbuild Change-Id: If72bd1c20b2014d0a3d400624d37fdb0a3052245 --- CleanSpec.mk | 2 ++ core/config.mk | 9 ------ core/definitions.mk | 52 ------------------------------- core/dex_preopt.mk | 61 ------------------------------------- core/java.mk | 21 +++---------- core/soong_config.mk | 4 --- core/soong_java_prebuilt.mk | 2 -- 7 files changed, 6 insertions(+), 145 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index f05410d6c..023d5e7c9 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -544,6 +544,8 @@ $(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libexpat.so) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/product_services) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/product_services) +# Clean up old location of hiddenapi files +$(call add-clean-step, rm -f $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/hiddenapi*) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST diff --git a/core/config.mk b/core/config.mk index e8cb1e57e..b02be0329 100644 --- a/core/config.mk +++ b/core/config.mk @@ -206,11 +206,6 @@ else JAVA_TMPDIR_ARG := endif -# A list of the jars that provide information about usages of the hidden API. -# The core-oj-hiddenapi provides information for the core-oj jar. -HIDDENAPI_EXTRA_APP_USAGE_JARS := \ - core-oj-hiddenapi \ - # ############################################################### # Broken build defaults # ############################################################### @@ -1224,10 +1219,6 @@ ifndef INTERNAL_PLATFORM_SYSTEM_PRIVATE_DEX_API_FILE INTERNAL_PLATFORM_SYSTEM_PRIVATE_DEX_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-private-dex.txt endif -INTERNAL_PLATFORM_HIDDENAPI_FLAGS := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/hiddenapi-flags.csv -INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/hiddenapi-stub-flags.txt -INTERNAL_PLATFORM_HIDDENAPI_GREYLIST_METADATA := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/hiddenapi-greylist.csv - # Missing optional uses-libraries so that the platform doesn't create build rules that depend on # them. See setup_one_odex.mk. INTERNAL_PLATFORM_MISSING_USES_LIBRARIES := com.google.android.ble com.google.android.wearable diff --git a/core/definitions.mk b/core/definitions.mk index fc766a500..4adcc4fd8 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2664,58 +2664,6 @@ done \ fi endef -# Copy dex files, invoking $(HIDDENAPI) on them in the process. -# Also make the source dex file an input of the hiddenapi singleton rule in dex_preopt.mk. -# Users can set UNSAFE_DISABLE_HIDDENAPI_FLAGS=true to skip this step. This is -# meant to speed up local incremental builds. Note that skipping this step changes -# Java semantics of the result dex bytecode. Use at own risk. -ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true) -define hiddenapi-copy-dex-files -$(2): $(1) $(HIDDENAPI) $(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) - @rm -rf $(dir $(2)) - @mkdir -p $(dir $(2)) - for INPUT_DEX in `find $(dir $(1)) -maxdepth 1 -name "classes*.dex" | sort`; do \ - echo "--input-dex=$$$${INPUT_DEX}"; \ - echo "--output-dex=$(dir $(2))/`basename $$$${INPUT_DEX}`"; \ - done | xargs $(HIDDENAPI) encode --api-flags=$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) - -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): $(1) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_DEX_INPUTS := $$(PRIVATE_DEX_INPUTS) $(1) -endef -else # UNSAFE_DISABLE_HIDDENAPI_FLAGS -define hiddenapi-copy-dex-files -$(2): $(1) - echo "WARNING: skipping hiddenapi post-processing for $(1)" 1>&2 - @rm -rf $(dir $(2)) - @mkdir -p $(dir $(2)) - find $(dir $(1)) -maxdepth 1 -name "classes*.dex" | xargs -I{} cp -f {} $(dir $(2))/ -endef -endif # UNSAFE_DISABLE_HIDDENAPI_FLAGS - -# Generate a greylist.txt from a classes.jar -define hiddenapi-generate-csv -ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true) -ifneq (,$(wildcard frameworks/base)) -# Only generate this target if we're in a tree with frameworks/base present. -$(2): $(1) $(CLASS2GREYLIST) $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS) - $(CLASS2GREYLIST) --stub-api-flags $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS) $(1) \ - --write-flags-csv $(2) - -$(3): $(1) $(CLASS2GREYLIST) $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS) - $(CLASS2GREYLIST) --stub-api-flags $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS) $(1) \ - --write-metadata-csv $(3) - -$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS): $(2) -$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS): PRIVATE_FLAGS_INPUTS := $$(PRIVATE_FLAGS_INPUTS) $(2) - -$(INTERNAL_PLATFORM_HIDDENAPI_GREYLIST_METADATA): $(3) -$(INTERNAL_PLATFORM_HIDDENAPI_GREYLIST_METADATA): \ - PRIVATE_METADATA_INPUTS := $$(PRIVATE_METADATA_INPUTS) $(3) - -endif -endif # UNSAFE_DISABLE_HIDDENAPI_FLAGS -endef - ########################################################### ## Commands to call R8 diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk index 21bac87ff..7471c47ff 100644 --- a/core/dex_preopt.mk +++ b/core/dex_preopt.mk @@ -30,67 +30,6 @@ $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-rem include $(BUILD_SYSTEM)/dex_preopt_libart.mk -# === hiddenapi rules === -ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true) - -hiddenapi_stubs_jar = $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar - -# Public API stubs -HIDDENAPI_STUBS := \ - $(call hiddenapi_stubs_jar,android_stubs_current) \ - $(call hiddenapi_stubs_jar,android.test.base.stubs) - -# System API stubs -HIDDENAPI_STUBS_SYSTEM := \ - $(call hiddenapi_stubs_jar,android_system_stubs_current) - -# Test API stubs -HIDDENAPI_STUBS_TEST := \ - $(call hiddenapi_stubs_jar,android_test_stubs_current) - -# Core Platform API stubs -HIDDENAPI_STUBS_CORE_PLATFORM := \ - $(call hiddenapi_stubs_jar,core.platform.api.stubs) - -# Allow products to define their own stubs for custom product jars that apps can use. -ifdef PRODUCT_HIDDENAPI_STUBS - HIDDENAPI_STUBS += $(foreach stub,$(PRODUCT_HIDDENAPI_STUBS), $(call hiddenapi_stubs_jar,$(stub))) -endif - -ifdef PRODUCT_HIDDENAPI_STUBS_SYSTEM - HIDDENAPI_STUBS_SYSTEM += $(foreach stub,$(PRODUCT_HIDDENAPI_STUBS_SYSTEM), $(call hiddenapi_stubs_jar,$(stub))) -endif - -ifdef PRODUCT_HIDDENAPI_STUBS_TEST - HIDDENAPI_STUBS_TEST += $(foreach stub,$(PRODUCT_HIDDENAPI_STUBS_TEST), $(call hiddenapi_stubs_jar,$(stub))) -endif - -# Singleton rule which applies $(HIDDENAPI) on all boot class path dex files. -# Additional inputs are filled with `hiddenapi-copy-dex-files` rules. -.KATI_RESTAT: $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): $(SOONG_HIDDENAPI_DEX_INPUTS) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_DEX_INPUTS := $(SOONG_HIDDENAPI_DEX_INPUTS) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_HIDDENAPI_STUBS := $(HIDDENAPI_STUBS) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_HIDDENAPI_STUBS_SYSTEM := $(HIDDENAPI_STUBS_SYSTEM) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_HIDDENAPI_STUBS_TEST := $(HIDDENAPI_STUBS_TEST) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): PRIVATE_HIDDENAPI_STUBS_CORE_PLATFORM := $(HIDDENAPI_STUBS_CORE_PLATFORM) -$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS): $(HIDDENAPI) $(HIDDENAPI_STUBS) \ - $(HIDDENAPI_STUBS_SYSTEM) $(HIDDENAPI_STUBS_TEST) \ - $(HIDDENAPI_STUBS_CORE_PLATFORM) - $(HIDDENAPI) list $(addprefix --boot-dex=,$(PRIVATE_DEX_INPUTS)) \ - --public-stub-classpath=$(call normalize-path-list, $(PRIVATE_HIDDENAPI_STUBS)) \ - --public-stub-classpath=$(call normalize-path-list, $(PRIVATE_HIDDENAPI_STUBS_SYSTEM)) \ - --public-stub-classpath=$(call normalize-path-list, $(PRIVATE_HIDDENAPI_STUBS_TEST)) \ - --core-platform-stub-classpath=$(call normalize-path-list, $(PRIVATE_HIDDENAPI_STUBS_CORE_PLATFORM)) \ - --out-api-flags=$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS).tmp - $(call commit-change-for-toc,$(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS)) - -# Inputs to singleton rules located in frameworks/base -# Additional inputs are filled with `hiddenapi-generate-csv` -$(INTERNAL_PLATFORM_HIDDENAPI_GREYLIST_METADATA): $(SOONG_HIDDENAPI_GREYLIST_METADATA) -$(INTERNAL_PLATFORM_HIDDENAPI_GREYLIST_METADATA): PRIVATE_METADATA_INPUTS := $(SOONG_HIDDENAPI_GREYLIST_METADATA) -endif # UNSAFE_DISABLE_HIDDENAPI_FLAGS - ifeq ($(PRODUCT_DIST_BOOT_AND_SYSTEM_JARS),true) boot_profile_jars_zip := $(PRODUCT_OUT)/boot_profile_jars.zip all_boot_jars := \ diff --git a/core/java.mk b/core/java.mk index e564db251..e644af7b6 100644 --- a/core/java.mk +++ b/core/java.mk @@ -71,11 +71,8 @@ full_classes_processed_jar := $(intermediates.COMMON)/classes-processed.jar full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex -built_dex_hiddenapi := $(intermediates.COMMON)/dex-hiddenapi/classes.dex full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar java_source_list_file := $(intermediates.COMMON)/java-source-list -hiddenapi_flags_csv := $(intermediates.COMMON)/hiddenapi/flags.csv -hiddenapi_metadata_csv := $(intermediates.COMMON)/hiddenapi/greylist.csv ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS) # If this is an apk without any Java code (e.g. framework-res), we should skip compiling Java. @@ -500,21 +497,11 @@ else # !LOCAL_PROGUARD_ENABLED $(transform-classes.jar-to-dex) endif -ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar - # Derive API greylist from the classes jar. - # We use full_classes_pre_proguard_jar here, as that is what is converted to - # dex later on. The difference is academic currently, as we don't proguard any - # bootclasspath code at the moment. If we were to do that, we should add keep - # rules for all members with the @UnsupportedAppUsage annotation. - $(eval $(call hiddenapi-generate-csv, $(full_classes_pre_proguard_jar),$(hiddenapi_flags_csv),$(hiddenapi_metadata_csv))) - LOCAL_INTERMEDIATE_TARGETS += $(hiddenapi_flags_csv) $(hiddenapi_metadata_csv) - $(eval $(call hiddenapi-copy-dex-files,$(built_dex_intermediate),$(built_dex_hiddenapi))) - built_dex_copy_from := $(built_dex_hiddenapi) -else # !is_boot_jar - built_dex_copy_from := $(built_dex_intermediate) -endif # is_boot_jar +ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) + $(call pretty-error,Modules in PRODUCT_BOOT_JARS must be defined in Android.bp files) +endif -$(built_dex): $(built_dex_copy_from) +$(built_dex): $(built_dex_intermediate) @echo Copying: $@ $(hide) mkdir -p $(dir $@) $(hide) rm -f $(dir $@)/classes*.dex diff --git a/core/soong_config.mk b/core/soong_config.mk index ccfcf871d..f78661e50 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -156,10 +156,6 @@ $(call add_json_list, ManifestPackageNameOverrides, $(PRODUCT_MANIFEST_PACK $(call add_json_bool, EnforceSystemCertificate, $(ENFORCE_SYSTEM_CERTIFICATE)) $(call add_json_list, EnforceSystemCertificateWhitelist, $(ENFORCE_SYSTEM_CERTIFICATE_WHITELIST)) -$(call add_json_str, HiddenAPIStubFlags, $(INTERNAL_PLATFORM_HIDDENAPI_STUB_FLAGS)) -$(call add_json_str, HiddenAPIFlags, $(INTERNAL_PLATFORM_HIDDENAPI_FLAGS)) -$(call add_json_list, HiddenAPIExtraAppUsageJars, $(HIDDENAPI_EXTRA_APP_USAGE_JARS)) - $(call add_json_map, VendorVars) $(foreach namespace,$(SOONG_CONFIG_NAMESPACES),\ $(call add_json_map, $(namespace))\ diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index 08d545d94..6214ac66f 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -19,8 +19,6 @@ full_classes_jar := $(intermediates.COMMON)/classes.jar full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar common_javalib.jar := $(intermediates.COMMON)/javalib.jar -hiddenapi_flags_csv := $(intermediates.COMMON)/hiddenapi/flags.csv -hiddenapi_metadata_csv := $(intermediates.COMMON)/hiddenapi/greylist.csv ifdef LOCAL_SOONG_AAR LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_AAR)