Modules.gmk revision 2487:5327e511b68d
1112394Ssam#
2112394Ssam# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
3112394Ssam# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4112394Ssam#
5112394Ssam# This code is free software; you can redistribute it and/or modify it
6112394Ssam# under the terms of the GNU General Public License version 2 only, as
7112394Ssam# published by the Free Software Foundation.  Oracle designates this
8112394Ssam# particular file as subject to the "Classpath" exception as provided
9112394Ssam# by Oracle in the LICENSE file that accompanied this code.
10112394Ssam#
11112394Ssam# This code is distributed in the hope that it will be useful, but WITHOUT
12112394Ssam# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13112394Ssam# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14112394Ssam# version 2 for more details (a copy is included in the LICENSE file that
15112394Ssam# accompanied this code).
16112394Ssam#
17112394Ssam# You should have received a copy of the GNU General Public License version
18112394Ssam# 2 along with this work; if not, write to the Free Software Foundation,
19112394Ssam# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20112394Ssam#
21112394Ssam# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22112394Ssam# or visit www.oracle.com if you need additional information or have any
23112394Ssam# questions.
24112394Ssam#
25112394Ssam
26112394Ssamifndef _MODULES_GMK
27112394Ssam_MODULES_GMK := 1
28112394Ssam
29112394Ssam################################################################################
30112394Ssam#
31112394Ssam# BOOT_MODULES are modules defined by the boot loader
32253767Sae# PLATFORM_MODULES are modules defined by the platform loader
33253767Sae# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
34112394Ssam#
35112394Ssam# All other modules not declared below are defined by the application loader
36112394Ssam# and are not included in JRE.
37112394Ssam
38112394SsamBOOT_MODULES :=
39112394SsamPLATFORM_MODULES :=
40112394SsamJRE_TOOL_MODULES :=
41112394SsamUPGRADEABLE_MODULES :=
42112394SsamAGGREGATOR_MODULES :=
43112394Ssam
44112394Ssam# Hook to include the corresponding custom file, if present.
45112394Ssam$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
46112394Ssam
47112394SsamBOOT_MODULES += \
48112394Ssam    java.base \
49112394Ssam    java.datatransfer \
50112394Ssam    java.desktop \
51112394Ssam    java.instrument \
52112394Ssam    java.logging \
53112394Ssam    java.management \
54112394Ssam    java.naming \
55112394Ssam    java.prefs \
56112394Ssam    java.rmi \
57112394Ssam    java.security.sasl \
58112394Ssam    java.xml \
59112394Ssam    jdk.httpserver \
60112394Ssam    jdk.management \
61112394Ssam    jdk.net \
62112394Ssam    jdk.sctp \
63112394Ssam    jdk.unsupported \
64112394Ssam    jdk.vm.ci \
65112394Ssam    #
66112394Ssam
67112394Ssam# to be deprivileged
68112394SsamBOOT_MODULES += \
69112394Ssam    jdk.naming.rmi \
70112394Ssam    #
71112394Ssam
72112394SsamUPGRADEABLE_MODULES += \
73112394Ssam    java.activation \
74112394Ssam    java.annotations.common \
75112394Ssam    java.corba \
76112394Ssam    java.transaction \
77112394Ssam    java.xml.bind \
78112394Ssam    java.xml.ws \
79112394Ssam    #
80112394Ssam
81112394Ssam# Modules explicitly declared as not being upgradeable even though they require
82112394Ssam# an upgradeable module.
83112394SsamNON_UPGRADEABLE_MODULES +=
84112394Ssam
85112394SsamAGGREGATOR_MODULES += \
86253081Sae    java.se \
87172240Sgnn    java.se.ee \
88112394Ssam    #
89112394Ssam
90112394SsamPLATFORM_MODULES += \
91112394Ssam    $(UPGRADEABLE_MODULES) \
92112394Ssam    $(AGGREGATOR_MODULES)
93112394Ssam    #
94112394Ssam
95112394SsamPLATFORM_MODULES += \
96112394Ssam    java.compiler \
97112394Ssam    jdk.incubator.httpclient \
98112394Ssam    java.scripting \
99112394Ssam    java.security.jgss \
100112394Ssam    java.smartcardio \
101112394Ssam    java.sql \
102112394Ssam    java.sql.rowset \
103253081Sae    java.xml.crypto \
104112394Ssam    jdk.accessibility \
105112394Ssam    jdk.charsets \
106112394Ssam    jdk.crypto.ec \
107112394Ssam    jdk.crypto.cryptoki \
108112394Ssam    jdk.desktop \
109112394Ssam    jdk.dynalink \
110112394Ssam    jdk.jsobject \
111112394Ssam    jdk.localedata \
112112394Ssam    jdk.naming.dns \
113112394Ssam    jdk.scripting.nashorn \
114112394Ssam    jdk.security.auth \
115112394Ssam    jdk.security.jgss \
116112394Ssam    jdk.vm.compiler \
117112394Ssam    jdk.xml.dom \
118112394Ssam    jdk.zipfs \
119112394Ssam    #
120112394Ssam
121112394SsamJRE_TOOL_MODULES += \
122112394Ssam    jdk.jdwp.agent \
123253081Sae    jdk.pack \
124112394Ssam    jdk.scripting.nashorn.shell \
125253081Sae    #
126112394Ssam
127253081Saeifeq ($(OPENJDK_TARGET_OS), windows)
128253081Sae  PLATFORM_MODULES += jdk.crypto.mscapi
129112394Ssamendif
130112394Ssamifeq ($(OPENJDK_TARGET_OS), solaris)
131253081Sae  PLATFORM_MODULES += jdk.crypto.ucrypto
132112394Ssamendif
133112394Ssam
134112394Ssam# These modules are included in the interim image which is used to run profiling
135112394Ssam# before building the real images.
136112394SsamINTERIM_IMAGE_MODULES := java.base java.logging
137112394Ssam
138112394Ssam################################################################################
139112394Ssam# Some platforms don't have the serviceability agent
140112394Ssam
141112394Ssamifeq ($(INCLUDE_SA), false)
142112394Ssam  MODULES_FILTER += jdk.hotspot.agent
143112394Ssamendif
144112394Ssam
145112394Ssam################################################################################
146112394Ssam# Filter out Graal specific modules if Graal build is disabled
147112394Ssam
148112394Ssamifeq ($(INCLUDE_GRAAL), false)
149112394Ssam  MODULES_FILTER += jdk.vm.compiler
150112394Ssamendif
151112394Ssam
152253081Sae################################################################################
153112394Ssam# Filter out aot specific modules if aot is disabled
154253081Sae
155112394Ssamifeq ($(ENABLE_AOT), false)
156253081Sae  MODULES_FILTER += jdk.aot
157253081Saeendif
158112394Ssam
159112394Ssam################################################################################
160112394Ssam# Module list macros
161112394Ssam
162253081Sae# Use append so that the custom extension may add to these variables
163253081Sae
164253081SaeGENERATED_SRC_DIRS += \
165253081Sae    $(SUPPORT_OUTPUTDIR)/gensrc \
166253081Sae    #
167253081Sae
168253081SaeTOP_SRC_DIRS += \
169253081Sae    $(CORBA_TOPDIR)/src \
170253081Sae    $(HOTSPOT_TOPDIR)/src \
171253081Sae    $(JDK_TOPDIR)/src \
172253081Sae    $(LANGTOOLS_TOPDIR)/src \
173253081Sae    $(JAXP_TOPDIR)/src \
174253081Sae    $(JAXWS_TOPDIR)/src \
175253081Sae    $(NASHORN_TOPDIR)/src \
176253081Sae    #
177112394Ssam
178112394SsamSRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
179ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
180  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
181endif
182SRC_SUBDIRS += share/classes
183
184# Find all module-info.java files for the current build target platform and
185# configuration.
186# Param 1 - Module to find for, set to * for finding all
187FindAllModuleInfos = \
188    $(wildcard \
189        $(foreach sub, $(SRC_SUBDIRS), \
190          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
191        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
192
193# Find module-info.java files in the specific source dir
194# Param 1 - Src dir to find module-info.java files in
195FindModuleInfosForSrcDir = \
196    $(wildcard \
197        $(foreach sub, $(SRC_SUBDIRS), \
198          $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
199        ) \
200        $(patsubst %,%/*/module-info.java, $(strip $1)) \
201    )
202
203# Extract the module names from the paths of module-info.java files. The
204# position of the module directory differs depending on if this is an imported
205# src dir or not.
206GetModuleNameFromModuleInfo = \
207    $(strip $(foreach mi, $1, \
208      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
209        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
210        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
211
212# Find all modules by looking for module-info.java files and looking at parent
213# directories.
214FindAllModules = \
215    $(sort $(filter-out $(MODULES_FILTER), \
216    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
217
218# Find all modules in a specific src dir
219# Param 1 - Src dir to find modules in
220FindModulesForSrcDir = \
221    $(sort $(filter-out $(MODULES_FILTER), \
222        $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
223    ))
224
225FindImportedModules = \
226    $(filter-out $(MODULES_FILTER), \
227    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
228
229# Find all source dirs for a particular module
230# $1 - Module to find source dirs for
231FindModuleSrcDirs = \
232    $(strip $(wildcard \
233        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
234        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
235
236# Construct the complete module source path
237GetModuleSrcPath = \
238    $(call PathList, \
239        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
240        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
241
242################################################################################
243# Extract module dependencies from module-info.java files.
244
245MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
246
247MODULE_INFOS := $(call FindAllModuleInfos, *)
248
249$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
250    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
251	$(MKDIR) -p $(@D)
252	$(RM) $@
253	$(foreach m, $(MODULE_INFOS), \
254	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
255	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
256	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
257	          /requires/ { sub(/;/, ""); \
258	                       sub(/requires/, ""); \
259	                       sub(/transitive/, ""); \
260	                       sub(/\/\/.*/, ""); \
261	                       sub(/\/\*.*\*\//, ""); \
262	                       gsub(/^ +\*.*/, ""); \
263	                       gsub(/ /, ""); \
264	                       printf(" %s", $$0) } \
265	          END        { printf("\n") }' $m \
266	    ) >> $@ $(NEWLINE))
267
268-include $(MODULE_DEPS_MAKEFILE)
269
270# Param 1: Module to find deps for
271FindDepsForModule = \
272  $(DEPS_$(strip $1))
273
274# Finds transitive dependencies in 3 levels.
275# Param 1: Module to find transitive deps for
276FindTransitiveDepsForModule = \
277    $(sort $(call FindDepsForModule, $1) \
278        $(foreach m, $(call FindDepsForModule, $1), \
279            $(call FindDepsForModule, $m) \
280            $(foreach n, $(call FindDepsForModule, $m), \
281                 $(call FindDepsForModule, $n))))
282
283# Upgradeable modules are those that are either defined as upgradeable or that
284# require an upradeable module.
285FindAllUpgradeableModules = \
286    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
287        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
288            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
289          $(if $(filter $(UPGRADEABLE_MODULES), \
290              $(call FindTransitiveDepsForModule, $m)), \
291            $m \
292          ) \
293        )) \
294    )
295
296################################################################################
297
298LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
299ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
300  LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
301endif
302LEGAL_SUBDIRS += share/legal
303
304# Find all legal dirs for a particular module
305# $1 - Module to find legal dirs for
306FindModuleLegalDirs = \
307    $(strip $(wildcard \
308        $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
309        $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
310
311################################################################################
312
313# Param 1 - Name of module
314define ReadSingleImportMetaData
315    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
316      classloader :=
317      include_in_jre :=
318      include_in_jdk :=
319      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
320      ifeq ($$(include_in_jre), true)
321        JRE_MODULES += $1
322      endif
323      ifeq ($$(include_in_jdk), true)
324        JDK_MODULES += $1
325      endif
326      ifeq ($$(classloader), boot)
327        BOOT_MODULES += $1
328      else ifeq ($$(classloader), ext)
329        PLATFORM_MODULES += $1
330      endif
331    else
332      # Default to include in all
333      JRE_MODULES += $1
334      JDK_MODULES += $1
335    endif
336endef
337
338# Reading the imported modules metadata has a cost, so to make it available,
339# a makefile needs to eval-call this macro first. After calling this, the
340# following variables are populated with data from the imported modules:
341# * JRE_MODULES
342# * JDK_MODULES
343# * BOOT_MODULES
344# * PLATFORM_MODULES
345# * JRE_TOOL_MODULES
346define ReadImportMetaData
347    IMPORTED_MODULES := $$(call FindImportedModules)
348    $$(foreach m, $$(IMPORTED_MODULES), \
349      $$(eval $$(call ReadSingleImportMetaData, $$m)))
350endef
351
352################################################################################
353
354endif # _MODULES_GMK
355