Add USE_D8_DESUGAR option in build/core

Add an option to use D8's desugar instead of the standalone version.

USE_D8_DESUGAR=true m would trigger DCHECK in dex2oat unless
https://android-review.googlesource.com/c/platform/art/+/562595 is
patched in as well.

Bug: 69329508
Test: m && USE_D8_DESUGAR=false m

Change-Id: I601dada44c361e45bbc0e2227ae1544a7d9efa90
This commit is contained in:
Alan Leung 2017-12-01 14:32:58 -08:00
parent 10c9f5d9d3
commit eaafb3cd37
3 changed files with 25 additions and 0 deletions

View file

@ -2411,6 +2411,19 @@ $(hide) $(DX_COMMAND) \
$<
endef
define transform-classes-d8.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"
@mkdir -p $(dir $@)
$(hide) rm -f $(dir $@)classes*.dex
$(hide) $(DX_COMMAND) \
--output $(dir $@) \
--min-api $(PRIVATE_MIN_SDK_VERSION) \
$(subst --no-locals, --release, \
$(filter-out --core-library --multi-dex,$(PRIVATE_DX_FLAGS))) \
$<
endef
# Create a mostly-empty .jar file that we'll add to later.
# The MacOS jar tool doesn't like creating empty jar files,
# so we need to give it something.

View file

@ -173,7 +173,11 @@ else # !LOCAL_IS_STATIC_JAVA_LIBRARY
$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
$(built_dex): $(full_classes_desugar_jar) $(DX)
ifneq ($(USE_D8_DESUGAR),true)
$(transform-classes.jar-to-dex)
else
$(transform-classes-d8.jar-to-dex)
endif
$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)

View file

@ -574,6 +574,7 @@ ifdef TARGET_OPENJDK9
LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex
endif
ifneq ($(USE_D8_DESUGAR),true)
my_desugaring :=
ifndef LOCAL_IS_STATIC_JAVA_LIBRARY
my_desugaring := true
@ -581,6 +582,9 @@ $(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
$(full_classes_desugar_jar): $(full_classes_jar) $(full_java_header_libs) $(DESUGAR)
$(desugar-classes-jar)
endif
else
my_desugaring :=
endif
ifndef my_desugaring
full_classes_desugar_jar := $(full_classes_jar)
@ -774,7 +778,11 @@ endif # LOCAL_PROGUARD_ENABLED
ifndef my_r8
$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX)
ifneq ($(USE_D8_DESUGAR),true)
$(transform-classes.jar-to-dex)
else
$(transform-classes-d8.jar-to-dex)
endif
endif
$(built_dex): $(built_dex_intermediate)