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
This commit is contained in:
David Brazdil 2018-10-19 20:05:07 +01:00
parent fac7b1de9c
commit 8a6b9a7baf
1 changed files with 14 additions and 2 deletions

View File

@ -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