Merge "Add a desugar step between javac and proguard" am: 9e92c2fd18

am: e4381dcac2

Change-Id: I5c72358097629e3ffe597c517e86a38ffbf51d82
This commit is contained in:
Colin Cross 2017-02-18 01:15:21 +00:00 committed by android-build-merger
commit d48f9252d5
3 changed files with 37 additions and 2 deletions

View File

@ -602,6 +602,7 @@ E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
MKTARBALL := build/tools/mktarball.sh
TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
DESUGAR := $(HOST_OUT_JAVA_LIBRARIES)/desugar.jar
DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
FAT16COPY := build/tools/fat16copy.py
CHECK_LINK_TYPE := build/tools/check_link_type.py

View File

@ -2534,6 +2534,24 @@ $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \
$(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER))
endef
define desugar-classpath
$(filter-out -classpath -bootclasspath "",$(subst :,$(space),$(1)))
endef
define desugar-classes-jar
@echo Desugar: $@
@mkdir -p $(dir $@)
$(hide) rm -f $@ $@.tmp
$(hide) java -jar $(DESUGAR) \
$(addprefix --bootclasspath_entry ,$(call desugar-bootclasspath,$(PRIVATE_BOOTCLASSPATH))) \
$(addprefix --classpath_entry ,$(PRIVATE_ALL_JAVA_LIBRARIES)) \
--min_sdk_version 24 --allow_empty_bootclasspath \
$(if $(filter --core-library,$(PRIVATE_DX_FLAGS)),--core_library) \
-i $< -o $@.tmp
mv $@.tmp $@
endef
#TODO: use a smaller -Xmx value for most libraries;
# only core.jar and framework.jar need a heap this big.
define transform-classes.jar-to-dex

View File

@ -116,6 +116,7 @@ proguard_jar_leaf := noproguard.classes.jar
endif
full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf)
full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
jarjar_leaf := classes-jarjar.jar
full_classes_jarjar_jar := $(intermediates.COMMON)/$(jarjar_leaf)
emma_intermediates_dir := $(intermediates.COMMON)/emma_out
@ -142,6 +143,7 @@ jack_check_timestamp := $(intermediates.COMMON)/jack.check.timestamp
LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_compiled_jar) \
$(full_classes_desugar_jar) \
$(full_classes_jarjar_jar) \
$(full_classes_emma_jar) \
$(full_classes_jar) \
@ -446,14 +448,28 @@ $(full_classes_compiled_jar): \
javac-check : $(full_classes_compiled_jar)
javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
my_desugaring :=
ifndef LOCAL_JACK_ENABLED
ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.8)
my_desugaring := true
$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
$(full_classes_desugar_jar): $(full_classes_compiled_jar) $(DESUGAR)
$(desugar-classes-jar)
endif
endif
ifndef my_desugaring
full_classes_desugar_jar := $(full_classes_compiled_jar)
endif
# Run jarjar if necessary, otherwise just copy the file.
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
@echo JarJar: $@
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else
$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) | $(ACP)
@echo Copying: $@
$(hide) $(ACP) -fp $< $@
endif