Merge "Use system modules generated by soong when using javac -target 1.9"

This commit is contained in:
Colin Cross 2017-10-17 18:37:35 +00:00 committed by Gerrit Code Review
commit 58cd98dc47
6 changed files with 57 additions and 15 deletions

View file

@ -804,6 +804,9 @@ TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
# We don't have prebuilt test_current SDK yet.
TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS)
TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT := $(call numbers_less_than,27,$(TARGET_AVAILABLE_SDK_VERSIONS))
INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt

View file

@ -2251,9 +2251,11 @@ $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
$(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
$(addprefix -bootclasspath ,$(strip \
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
$(PRIVATE_EMPTY_BOOTCLASSPATH))) \
$(if $(PRIVATE_USE_SYSTEM_MODULES), \
$(addprefix --system=,$(PRIVATE_SYSTEM_MODULES)), \
$(addprefix -bootclasspath ,$(strip \
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
$(PRIVATE_EMPTY_BOOTCLASSPATH)))) \
$(addprefix -classpath ,$(strip \
$(call normalize-path-list,$(2)))) \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
@ -2300,6 +2302,7 @@ $(1): \
$(3) \
$(5) \
$$(full_java_bootclasspath_libs) \
$$(full_java_system_modules_deps) \
$$(layers_file) \
$$(annotation_processor_deps) \
$$(NORMALIZE_PATH) \

View file

@ -93,6 +93,7 @@ $(full_classes_compiled_jar): \
$(java_sources_deps) \
$(full_java_header_libs) \
$(full_java_bootclasspath_libs) \
$(full_java_system_modules_deps) \
$(annotation_processor_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \

View file

@ -499,6 +499,7 @@ $(full_classes_turbine_jar): \
$(java_sources_deps) \
$(full_java_header_libs) \
$(full_java_bootclasspath_libs) \
$(full_java_system_modules_deps) \
$(NORMALIZE_PATH) \
$(JAR_ARGS) \
$(ZIPTIME) \

View file

@ -15,20 +15,17 @@
# Modules can override this logic by specifying
# LOCAL_JAVA_LANGUAGE_VERSION explicitly.
ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION))
private_sdk_versions_without_any_java_18_support := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_18_support)))
ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT)))
LOCAL_JAVA_LANGUAGE_VERSION := 1.7
else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT)))
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
else ifneq (,$(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS))
# TODO(ccross): allow 1.9 for current and unbundled once we have SDK system modules
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
else
ifneq ($(EXPERIMENTAL_USE_OPENJDK9),true)
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
else
private_sdk_versions_without_any_java_19_support := 24 25 26
ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_19_support)))
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
else
LOCAL_JAVA_LANGUAGE_VERSION := 1.9
endif
endif
# DEFAULT_JAVA_LANGUAGE_VERSION is 1.8 unless EXPERIMENTAL_USE_OPENJDK9=true
# in which case it is 1.9
LOCAL_JAVA_LANGUAGE_VERSION := $(DEFAULT_JAVA_LANGUAGE_VERSION)
endif
endif
LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
@ -201,6 +198,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
full_java_bootclasspath_libs :=
empty_bootclasspath :=
my_system_modules :=
# full_java_libs: The list of files that should be used as the classpath.
# Using this list as a dependency list WILL NOT WORK.
@ -209,8 +207,13 @@ ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
# No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
empty_bootclasspath := ""
# Most users of LOCAL_NO_STANDARD_LIBRARIES really mean no framework libs,
# and manually add back the core libs. The ones that don't are in soong
# now, so just always assume that they want the default system modules
my_system_modules := $(DEFAULT_SYSTEM_MODULES)
else # LOCAL_NO_STANDARD_LIBRARIES
full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES))
my_system_modules := $(DEFAULT_SYSTEM_MODULES)
endif # LOCAL_NO_STANDARD_LIBRARIES
else
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
@ -255,6 +258,7 @@ else # LOCAL_IS_HOST_MODULE
full_java_bootclasspath_libs := $(call java-lib-header-files,$(addsuffix -hostdex,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)),true)
endif
my_system_modules := $(DEFAULT_SYSTEM_MODULES)
full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),true)
else # !USE_CORE_LIB_BOOTCLASSPATH
@ -270,8 +274,25 @@ ifdef empty_bootclasspath
endif
endif
full_java_system_modules_deps :=
my_system_modules_dir :=
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES :=
ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.9)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES := true
ifdef my_system_modules
ifneq ($(my_system_modules),none)
ifndef SOONG_SYSTEM_MODULES_$(my_system_modules)
$(call pretty-error, Invalid system modules $(my_system_modules))
endif
full_java_system_modules_deps := $(SOONG_SYSTEM_MODULES_$(my_system_modules))
my_system_modules_dir := $(patsubst %/lib/modules,%,$(SOONG_SYSTEM_MODULES_$(my_system_modules)))
endif
endif
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspath_libs)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES := $(my_system_modules_dir)
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)

View file

@ -72,6 +72,10 @@ define math_gt_or_eq
$(if $(filter $(1),$(call math_max,$(1),$(2))),true)
endef
define math_lt
$(if $(call math_gt_or_eq,$(1),$(2)),,true)
endef
#$(warning $(call math_gt_or_eq, 2, 1))
#$(warning $(call math_gt_or_eq, 1, 1))
#$(warning $(if $(call math_gt_or_eq, 1, 2),false,true))
@ -81,6 +85,15 @@ define inc_and_print
$(strip $(eval $(1) := $($(1)) .)$(words $($(1))))
endef
# Returns the words in $2 that are numbers and are less than $1
define numbers_less_than
$(strip \
$(foreach n,$2, \
$(if $(call math_is_number,$(n)), \
$(if $(call math_lt,$(n),$(1)), \
$(n)))))
endef
_INT_LIMIT_WORDS := $(foreach a,x x,$(foreach b,x x x x x x x x x x x x x x x x,\
$(foreach c,x x x x x x x x x x x x x x x x,x x x x x x x x x x x x x x x x)))