1 #
2 # Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29
30 include JavaCompilation.gmk
31 include Modules.gmk
32
33 ################################################################################
34 # If this is an imported module that has prebuilt classes, only compile
35 # module-info.java.
36 ifneq ($(IMPORT_MODULES_CLASSES), )
37 IMPORT_MODULE_DIR := $(IMPORT_MODULES_CLASSES)/$(MODULE)
38 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), )
39 $(MODULE)_INCLUDE_FILES := module-info.java
40 endif
41 else
42 IMPORT_MODULE_DIR :=
43 endif
44
45 ################################################################################
46 # Setup the compilation for the module
47 #
48 MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE))
49
50 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
51 # JDK_FILTER at the make command line, only a subset of the JDK java files will
52 # be recompiled. If multiple paths are separated by comma, convert that into a
81 ), \
82 .properties \
83 )
84
85 ################################################################################
86 # Include module specific build settings
87
88 THIS_SNIPPET := $(call GetModuleSnippetName, Java)
89
90 ifneq ($(wildcard $(THIS_SNIPPET)), )
91 include MakeSnippetStart.gmk
92
93 include $(THIS_SNIPPET)
94
95 include MakeSnippetEnd.gmk
96 endif
97
98 ################################################################################
99 # Setup the main compilation
100
101 $(eval $(call SetupJavaCompilation, $(MODULE), \
102 SMALL_JAVA := false, \
103 MODULE := $(MODULE), \
104 SRC := $(wildcard $(MODULE_SRC_DIRS)), \
105 INCLUDES := $(JDK_USER_DEFINED_FILTER), \
106 FAIL_NO_SRC := $(FAIL_NO_SRC), \
107 BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \
108 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
109 CREATE_API_DIGEST := true, \
110 CLEAN := $(CLEAN), \
111 CLEAN_FILES := $(CLEAN_FILES), \
112 COPY := $(COPY), \
113 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java), \
114 EXCLUDES := $(EXCLUDES), \
115 EXCLUDE_FILES := $(EXCLUDE_FILES), \
116 EXCLUDE_PATTERNS := -files, \
117 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \
118 TARGET_RELEASE := $(TARGET_RELEASE), \
119 JAVAC_FLAGS := \
120 $(DOCLINT) \
121 $(JAVAC_FLAGS) \
122 --module-source-path $(MODULESOURCEPATH) \
123 --module-path $(MODULEPATH) \
124 --system none, \
125 ))
126
127 TARGETS += $($(MODULE))
128
129 # Declare dependencies between java compilations of different modules.
130 # Since the other modules are declared in different invocations of this file,
131 # use the macro to find the correct target file to depend on.
132 # Only the javac compilation actually depends on other modules so limit
133 # dependency declaration to that by using the *_MODFILELIST variable.
134 $($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
135 $(call SetupJavaCompilationApiTarget, $d, \
136 $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d)))
137
138 ################################################################################
139 # If this is an imported module, copy the pre built classes and resources into
140 # the modules output dir
141
142 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), )
143 $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \
144 $(call FindFiles, $(IMPORT_MODULE_DIR))
145 $(call MakeDir, $(@D))
146 # Do not delete marker and build meta data files
147 $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*))
148 $(CP) -R $(IMPORT_MODULE_DIR)/* $(@D)/
|
1 #
2 # Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29
30 include JavaCompilation.gmk
31 include Modules.gmk
32
33 include CopyFiles.gmk
34
35 ################################################################################
36 # If this is an imported module that has prebuilt classes, only compile
37 # module-info.java.
38 ifneq ($(IMPORT_MODULES_CLASSES), )
39 IMPORT_MODULE_DIR := $(IMPORT_MODULES_CLASSES)/$(MODULE)
40 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), )
41 $(MODULE)_INCLUDE_FILES := module-info.java
42 endif
43 else
44 IMPORT_MODULE_DIR :=
45 endif
46
47 ################################################################################
48 # Setup the compilation for the module
49 #
50 MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE))
51
52 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
53 # JDK_FILTER at the make command line, only a subset of the JDK java files will
54 # be recompiled. If multiple paths are separated by comma, convert that into a
83 ), \
84 .properties \
85 )
86
87 ################################################################################
88 # Include module specific build settings
89
90 THIS_SNIPPET := $(call GetModuleSnippetName, Java)
91
92 ifneq ($(wildcard $(THIS_SNIPPET)), )
93 include MakeSnippetStart.gmk
94
95 include $(THIS_SNIPPET)
96
97 include MakeSnippetEnd.gmk
98 endif
99
100 ################################################################################
101 # Setup the main compilation
102
103 COMPILATION_OUTPUTDIR := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules)
104
105 $(eval $(call SetupJavaCompilation, $(MODULE), \
106 SMALL_JAVA := false, \
107 MODULE := $(MODULE), \
108 SRC := $(wildcard $(MODULE_SRC_DIRS)), \
109 INCLUDES := $(JDK_USER_DEFINED_FILTER), \
110 FAIL_NO_SRC := $(FAIL_NO_SRC), \
111 BIN := $(COMPILATION_OUTPUTDIR), \
112 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
113 CREATE_API_DIGEST := true, \
114 CLEAN := $(CLEAN), \
115 CLEAN_FILES := $(CLEAN_FILES), \
116 COPY := $(COPY), \
117 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java), \
118 EXCLUDES := $(EXCLUDES), \
119 EXCLUDE_FILES := $(EXCLUDE_FILES), \
120 EXCLUDE_PATTERNS := -files, \
121 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \
122 TARGET_RELEASE := $(TARGET_RELEASE), \
123 JAVAC_FLAGS := \
124 $(DOCLINT) \
125 $(JAVAC_FLAGS) \
126 --module-source-path $(MODULESOURCEPATH) \
127 --module-path $(MODULEPATH) \
128 --system none, \
129 ))
130
131 TARGETS += $($(MODULE))
132
133 ################################################################################
134 # Setup compilation for preview classes in the module
135 # TBD: When $(DOCLINT) was included there was an NPE in JavacTypes.getOverriddenMethods
136
137 # Directory and file name suffix for jar file containing preview classes/resources.
138 PREVIEW_CLASSES_LABEL := preview
139 # Module relative path in which preview classes/resources are placed.
140 PREVIEW_PATH := META-INF/preview
141
142 ifneq ($(COMPILER), bootjdk)
143 MODULE_PREVIEW_SRC_DIRS := $(call FindModulePreviewSrcDirs, $(MODULE))
144 MODULE_PREVIEW_SOURCEPATH := $(call GetModulePreviewSrcPath)
145 ifneq ($(MODULE_PREVIEW_SRC_DIRS),)
146 # Temporarily compile preview classes into a separate directory, and then
147 # copy into the correct output path location.
148 # We cannot compile directly into the desired directory because it's the
149 # compiler which creates the original '<module>/<classpath>/...' hierarchy.
150 TEMP_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/$(PREVIEW_CLASSES_LABEL)
151
152 $(eval $(call SetupJavaCompilation, $(MODULE)-$(PREVIEW_CLASSES_LABEL), \
153 SMALL_JAVA := false, \
154 MODULE := $(MODULE), \
155 SRC := $(wildcard $(MODULE_PREVIEW_SRC_DIRS)), \
156 INCLUDES := $(JDK_USER_DEFINED_FILTER), \
157 FAIL_NO_SRC := $(FAIL_NO_SRC), \
158 BIN := $(TEMP_OUTPUTDIR)/, \
159 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
160 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java) preview, \
161 EXCLUDES := $(EXCLUDES), \
162 EXCLUDE_FILES := $(EXCLUDE_FILES) \
163 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \
164 DEPENDS := $($(MODULE)), \
165 JAVAC_FLAGS := \
166 $(JAVAC_FLAGS) \
167 --module-source-path $(MODULE_PREVIEW_SOURCEPATH) \
168 --module-path $(JDK_OUTPUTDIR)/modules \
169 --system none \
170 --enable-preview -source $(JDK_SOURCE_TARGET_VERSION), \
171 ))
172
173 # Don't add '$($(MODULE)-$(PREVIEW_CLASSES_LABEL))' to TARGETS (it's transient).
174 # The 'preview' target below depends on it, and that's the non-transient
175 # result we care about.
176
177 # Copy compiled output from "$TEMP_OUTPUTDIR/$MODULE/<classpath>/..."
178 # to "$COMPILATION_OUTPUTDIR/$MODULE/$PREVIEW_PATH/<classpath>/...".
179 MOD_SRC := $(TEMP_OUTPUTDIR)/$(MODULE)
180 MOD_DST := $(COMPILATION_OUTPUTDIR)/$(MODULE)
181
182 # NOTE: We cannot use '$(CP) -R $(MOD_SRC)/*/ ...' to select sub-directories (it
183 # does not work on MacOS/BSD). Use 'filter-out' to explicitly exclude marker files.
184 $(MOD_DST)/_the.$(MODULE).preview: $($(MODULE)-$(PREVIEW_CLASSES_LABEL))
185 $(RM) -r $(@D)/$(PREVIEW_PATH)
186 $(MKDIR) -p $(@D)/$(PREVIEW_PATH)
187 $(CP) -R $(filter-out $(MOD_SRC)/_%, $(wildcard $(MOD_SRC)/*)) $(@D)/$(PREVIEW_PATH)
188 $(TOUCH) $@
189
190 TARGETS += $(MOD_DST)/_the.$(MODULE).preview
191 endif
192 endif
193
194 # Declare dependencies between java compilations of different modules.
195 # Since the other modules are declared in different invocations of this file,
196 # use the macro to find the correct target file to depend on.
197 # Only the javac compilation actually depends on other modules so limit
198 # dependency declaration to that by using the *_MODFILELIST variable.
199 $($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
200 $(call SetupJavaCompilationApiTarget, $d, \
201 $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d)))
202
203 ################################################################################
204 # If this is an imported module, copy the pre built classes and resources into
205 # the modules output dir
206
207 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), )
208 $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \
209 $(call FindFiles, $(IMPORT_MODULE_DIR))
210 $(call MakeDir, $(@D))
211 # Do not delete marker and build meta data files
212 $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*))
213 $(CP) -R $(IMPORT_MODULE_DIR)/* $(@D)/
|