Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions make/CompileJavaModules.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ endif

################################################################################
# Setup the main compilation

COMPILATION_OUTPUTDIR := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules)

$(eval $(call SetupJavaCompilation, $(MODULE), \
SMALL_JAVA := false, \
MODULE := $(MODULE), \
SRC := $(wildcard $(MODULE_SRC_DIRS)), \
INCLUDES := $(JDK_USER_DEFINED_FILTER), \
FAIL_NO_SRC := $(FAIL_NO_SRC), \
BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \
BIN := $(COMPILATION_OUTPUTDIR), \
HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
CREATE_API_DIGEST := true, \
CLEAN := $(CLEAN), \
Expand Down Expand Up @@ -137,14 +140,23 @@ ifneq ($(COMPILER), bootjdk)
MODULE_VALUECLASS_SRC_DIRS := $(call FindModuleValueClassSrcDirs, $(MODULE))
MODULE_VALUECLASS_SOURCEPATH := $(call GetModuleValueClassSrcPath)

# Temporarily compile valueclasses into a separate directory with the form:
# <tempdir>/<module>/<classpath>
# and then copy the class files into:
# <outdir>/<module>/META-INF/preview/<classpath>
# We cannot compile directly into the desired directory because it's the
# compiler which creates the original '<module>/<classpath>/...' hierarchy.
VALUECLASS_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR)
PREVIEW_OUTPUTDIR := $(COMPILATION_OUTPUTDIR)/$(MODULE)/META-INF/preview

ifneq ($(MODULE_VALUECLASS_SRC_DIRS),)
$(eval $(call SetupJavaCompilation, $(MODULE)-$(VALUECLASSES_STR), \
SMALL_JAVA := false, \
MODULE := $(MODULE), \
SRC := $(wildcard $(MODULE_VALUECLASS_SRC_DIRS)), \
INCLUDES := $(JDK_USER_DEFINED_FILTER), \
FAIL_NO_SRC := $(FAIL_NO_SRC), \
BIN := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR)/, \
BIN := $(VALUECLASS_OUTPUTDIR)/, \
JAR := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \
HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
DISABLED_WARNINGS := $(DISABLED_WARNINGS_java) preview, \
Expand All @@ -162,6 +174,14 @@ ifneq ($(COMPILER), bootjdk)

TARGETS += $($(MODULE)-$(VALUECLASSES_STR))

# Restructure the class file hierarchy from <module>/<classpath>/... to <module>/META-INF/preview/<classpath>/...
$(PREVIEW_OUTPUTDIR)/_copy_valueclasses.marker: $($(MODULE)-$(VALUECLASSES_STR))
$(call MakeTargetDir)
$(CP) -R $(VALUECLASS_OUTPUTDIR)/$(MODULE)/. $(@D)/
$(TOUCH) $@

TARGETS += $(PREVIEW_OUTPUTDIR)/_copy_valueclasses.marker

Comment on lines +177 to +184
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect build reviewer will suggest using the SetupCopyFiles mechanism to copy files.

$(eval $(call SetupCopyFiles, $(MODULE)-copy-valueclass-jar, \
FILES := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \
DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/$(VALUECLASSES_STR), \
Expand Down