From 8a6b9a7bafaa2c9079b0226b408d73c380b6f8de Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Fri, 19 Oct 2018 20:05:07 +0100 Subject: [PATCH] Add UNSAFE_DISABLE_HIDDENAPI_FLAGS to skip hiddenapi processing Setting environment variable UNSAFE_DISABLE_HIDDENAPI_FLAGS=true will skip the build step which annotates dex files with information about public and non-public API membership. This is meant to speed up incremental local builds. USE AT OWN RISK: Dex files built with this flag will execute with hidden API access checks disabled and therefore may exhibit different behaviour compared to production code. WARNING: Some JARs cannot be compiled with this flag as ART hardcodes hidden API access flags of intrinsified methods. Attempting to compile dex files containing such methods will trigger an assertion. Test: UNSAFE_DISABLE_HIDDENAPI_FLAGS=true mmm frameworks/base Bug: 113278235 Bug: 112388925 Change-Id: I51fe99ab53e1bb2aa0db64b22a321dd1e1ed47e1 --- core/definitions.mk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 3538166d3..bb785ec2d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2679,6 +2679,10 @@ 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_LIGHT_GREYLIST) \ $(INTERNAL_PLATFORM_HIDDENAPI_DARK_GREYLIST) $(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST) @@ -2692,9 +2696,17 @@ $(2): $(1) $(HIDDENAPI) $(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST) \ --blacklist=$(INTERNAL_PLATFORM_HIDDENAPI_BLACKLIST) $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST): $(1) -$(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST): \ - PRIVATE_DEX_INPUTS := $$(PRIVATE_DEX_INPUTS) $(1) +$(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST): 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-greylist-txt