Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f960257c authored by Colin Cross's avatar Colin Cross
Browse files

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

Soong has support for building system modules.  Use the directories
produced by Soong with --system to replace -bootclasspath arguments
when using javac -target 1.9.

Since soong can't generate current SDK stubs yet, and no existing
SDK stubs need -target, only use -target 1.9 for modules that are
not compiling against the SDK.  That means in practice the only
system modules that will be used for now is the default one,
core-system-modules.

Bug: 63986449
Test: m -j EXPERIMENTAL_USE_OPENJDK9=true makes some progress
Change-Id: I350ef50aedf36fdd72458c23d4fe8a2edf1a9a02
parent ff806ece
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+6 −3
Original line number Diff line number Diff line
@@ -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) $(1) -encoding UTF-8 \
    $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
    $(if $(PRIVATE_USE_SYSTEM_MODULES), \
      $(addprefix --system=,$(PRIVATE_SYSTEM_MODULES)), \
      $(addprefix -bootclasspath ,$(strip \
          $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
        $(PRIVATE_EMPTY_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) \
+1 −0
Original line number Diff line number Diff line
@@ -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) \
+1 −0
Original line number Diff line number Diff line
@@ -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) \
+33 −12
Original line number Diff line number Diff line
@@ -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 ($(EXPERIMENTAL_USE_OPENJDK9),true)
  else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT)))
    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)))
  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
        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)
Loading