Remove duplication of bootclasspath in LOCAL_JAVA_LIBRARIES

The bootclasspath libraries have direct dependencies now, so
remove them from LOCAL_JAVA_LIBRARIES so they don't also end
up in the classpath.

Test: m -j checkbuild
Test: m -j ANDROID_COMPILE_WITH_JACK=true java
Test: manually inspection of build-${TARGET_PRODUCT}.ninja
      only has expected changes
Test: no changes to system.img
Change-Id: Icbc8987468f237aa351708b33c3abe5ea3d1816e
This commit is contained in:
Colin Cross 2017-09-23 19:52:43 -07:00
parent 1d1e5ef61b
commit b541aae17c
3 changed files with 72 additions and 50 deletions

View File

@ -2237,8 +2237,7 @@ endef
# Common definition to invoke javac on the host and target.
#
# $(1): javac
# $(2): bootclasspath
# $(3): classpath_libs
# $(2): classpath_libs
define compile-java
$(hide) rm -f $@
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
@ -2248,9 +2247,10 @@ $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
$(SOONG_JAVAC_WRAPPER) $(1) -encoding UTF-8 \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
$(addprefix -bootclasspath ,$(strip \
$(call normalize-path-list,$(2)))) \
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
$(PRIVATE_EMPTY_BOOTCLASSPATH))) \
$(addprefix -classpath ,$(strip \
$(call normalize-path-list,$(3)))) \
$(call normalize-path-list,$(2)))) \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
-d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
$(PRIVATE_JAVACFLAGS) \
@ -2277,7 +2277,7 @@ endef
define transform-java-to-classes.jar
@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
endef
define transform-java-to-header.jar
@ -2290,8 +2290,9 @@ $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
--output $@.premerged --temp_dir $(dir $@)/classes-turbine \
--sources \@$(PRIVATE_JAVA_SOURCE_LIST) \
--javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) \
$(addprefix --bootclasspath, $(strip \
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)))) \
$(addprefix --bootclasspath ,$(strip \
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
$(PRIVATE_EMPTY_BOOTCLASSPATH))) \
$(addprefix --classpath ,$(strip \
$(call normalize-path-list,$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)))) \
|| ( rm -rf $(dir $@)/classes-turbine ; exit 41 ) && \
@ -2492,10 +2493,6 @@ $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLU
$(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53)
endef
define desugar-bootclasspath
$(filter-out -classpath -bootclasspath "",$(subst :,$(space),$(1)))
endef
# Takes an sdk version that might be PLATFORM_VERSION_CODENAME (for example P),
# returns a number greater than the highest existing sdk version if it is, or
# the input if it is not.
@ -2515,7 +2512,7 @@ $(hide) $(JAVA) \
$(if $(EXPERIMENTAL_USE_OPENJDK9),--add-opens java.base/java.lang.invoke=ALL-UNNAMED,) \
-Djdk.internal.lambda.dumpProxyClasses=$(abspath $(dir $@))/desugar_dumped_classes \
-jar $(DESUGAR) \
$(addprefix --bootclasspath_entry ,$(call desugar-bootclasspath,$(PRIVATE_BOOTCLASSPATH))) \
$(addprefix --bootclasspath_entry ,$(PRIVATE_BOOTCLASSPATH)) \
$(addprefix --classpath_entry ,$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)) \
--min_sdk_version $(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
--desugar_try_with_resources_if_needed=false \
@ -2744,14 +2741,14 @@ endef
# in transform-java-to-classes for the sake of vm-tests.
define transform-host-java-to-package
@echo "Host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH),$(PRIVATE_ALL_JAVA_LIBRARIES))
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_LIBRARIES))
endef
# Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR
# in transform-java-to-classes for the sake of vm-tests.
define transform-host-java-to-dalvik-package
@echo "Dalvik Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
endef
###########################################################
@ -2897,7 +2894,8 @@ endef
define transform-jar-to-proguard
@echo Proguard: $@
$(hide) $(PROGUARD) -injars '$<$(PRIVATE_PROGUARD_INJAR_FILTERS)' \
-outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
-outjars $@ \
$(PRIVATE_PROGUARD_FLAGS) \
$(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR))
endef

View File

@ -31,45 +31,52 @@ ifneq ($(LOCAL_MODULE),jacocoagent)
endif # !LOCAL_NO_STANDARD_LIBRARIES
endif # LOCAL_MODULE == jacocoagent
ifneq ($(LOCAL_SDK_VERSION),)
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
$(error $(LOCAL_PATH): Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)
else
ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),)
$(error $(LOCAL_PATH): Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \
Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))
# This duplicates the bootclasspath logic in java_common.mk because jack doesn't use
# bootclasspath.
ifdef LOCAL_JACK_ENABLED
ifneq ($(LOCAL_SDK_VERSION),)
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
$(error $(LOCAL_PATH): Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)
else
ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
# Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES)
else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES)
else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),)
$(error $(LOCAL_PATH): Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \
Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))
else
LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
endif
ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
# Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES)
else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES)
else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
else
LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
endif
ifeq ($(LOCAL_SDK_VERSION),current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else ifeq ($(LOCAL_SDK_VERSION),system_current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else ifeq ($(LOCAL_SDK_VERSION),test_current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else
my_jack_min_sdk_version := $(LOCAL_SDK_VERSION)
ifeq ($(LOCAL_SDK_VERSION),current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else ifeq ($(LOCAL_SDK_VERSION),system_current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else ifeq ($(LOCAL_SDK_VERSION),test_current)
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
else
my_jack_min_sdk_version := $(LOCAL_SDK_VERSION)
endif
endif
endif
else
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
endif
else
my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
LOCAL_JAVA_LIBRARIES := $(TARGET_DEFAULT_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES)
ifneq (,$(strip $(LOCAL_MIN_SDK_VERSION)))
my_jack_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
endif
endif
ifneq (,$(strip $(LOCAL_MIN_SDK_VERSION)))
my_jack_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
ifndef LOCAL_SDK_VERSION
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
LOCAL_JAVA_LIBRARIES := $(TARGET_DEFAULT_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES)
endif
endif
proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
@ -620,14 +627,16 @@ endif
else
# For platform build, we can't just raise to the "current" SDK,
# that would break apps that use APIs removed from the current SDK.
my_support_library_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_JAVA_LIBRARIES))
my_support_library_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
endif
endif
endif
# jack already has the libraries in its classpath and doesn't support jars
legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) \
$(filter-out $(my_support_library_sdk_raise),$(full_shared_java_header_libs)))
$(filter-out $(my_support_library_sdk_raise), \
$(full_java_bootclasspath_libs) \
$(full_shared_java_header_libs)))
legacy_proguard_lib_deps := $(my_support_library_sdk_raise) \
$(filter-out $(my_support_library_sdk_raise),$(full_shared_java_header_libs))

View File

@ -212,9 +212,16 @@ ifndef LOCAL_IS_HOST_MODULE
# No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
empty_bootclasspath := ""
else # LOCAL_NO_STANDARD_LIBRARIES
full_java_bootclasspath_libs := $(call java-lib-header-files,core-oj core-libart)
full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES))
endif # LOCAL_NO_STANDARD_LIBRARIES
else
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
$(call pretty-error,Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)
endif
ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),)
$(call pretty-error,Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \
Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))
endif
ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
full_java_bootclasspath_libs := $(call java-lib-header-files,android_stubs_current)
@ -248,7 +255,7 @@ else # LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
empty_bootclasspath := ""
else
full_java_bootclasspath_libs := $(call java-lib-header-files,core-oj-hostdex core-libart-hostdex,true)
full_java_bootclasspath_libs := $(call java-lib-header-files,$(addsuffix -hostdex,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)),true)
endif
full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
@ -266,7 +273,8 @@ ifdef empty_bootclasspath
endif
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(empty_bootclasspath)$(full_java_bootclasspath_libs)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspath_libs)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath)
full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs)
@ -376,6 +384,13 @@ full_static_jack_libs := \
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs)
full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
my_jack_bootclasspath := $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)
ifdef LOCAL_IS_HOST_MODULE
my_jack_bootclasspath := $(addsuffix -hostdex,$(my_jack_bootclasspath))
endif
full_shared_jack_libs := $(call jack-lib-files,$(my_jack_bootclasspath),$(LOCAL_IS_HOST_MODULE)) $(full_shared_jack_libs)
endif
full_jack_deps := $(full_shared_jack_libs)
ifndef LOCAL_IS_HOST_MODULE