Modules.gmk revision 2491:7e2e1deb2314
1#
2# Copyright (c) 2014, 2017, 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
26ifndef _MODULES_GMK
27_MODULES_GMK := 1
28
29################################################################################
30#
31# BOOT_MODULES are modules defined by the boot loader
32# PLATFORM_MODULES are modules defined by the platform loader
33# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
34#
35# All other modules not declared below are defined by the application loader
36# and are not included in JRE.
37
38BOOT_MODULES :=
39PLATFORM_MODULES :=
40JRE_TOOL_MODULES :=
41UPGRADEABLE_MODULES :=
42AGGREGATOR_MODULES :=
43
44# Hook to include the corresponding custom file, if present.
45$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
46
47BOOT_MODULES += \
48    java.base \
49    java.datatransfer \
50    java.desktop \
51    java.instrument \
52    java.logging \
53    java.management \
54    java.management.rmi \
55    java.naming \
56    java.prefs \
57    java.rmi \
58    java.security.sasl \
59    java.xml \
60    jdk.httpserver \
61    jdk.management \
62    jdk.management.agent \
63    jdk.net \
64    jdk.sctp \
65    jdk.unsupported \
66    jdk.vm.ci \
67    #
68
69# to be deprivileged
70BOOT_MODULES += \
71    jdk.naming.rmi \
72    #
73
74UPGRADEABLE_MODULES += \
75    java.activation \
76    java.corba \
77    java.transaction \
78    java.xml.bind \
79    java.xml.ws \
80    java.xml.ws.annotation \
81    #
82
83# Modules explicitly declared as not being upgradeable even though they require
84# an upgradeable module.
85NON_UPGRADEABLE_MODULES +=
86
87AGGREGATOR_MODULES += \
88    java.se \
89    java.se.ee \
90    #
91
92PLATFORM_MODULES += \
93    $(UPGRADEABLE_MODULES) \
94    $(AGGREGATOR_MODULES)
95    #
96
97PLATFORM_MODULES += \
98    java.compiler \
99    jdk.incubator.httpclient \
100    java.scripting \
101    java.security.jgss \
102    java.smartcardio \
103    java.sql \
104    java.sql.rowset \
105    java.xml.crypto \
106    jdk.accessibility \
107    jdk.charsets \
108    jdk.crypto.ec \
109    jdk.crypto.cryptoki \
110    jdk.dynalink \
111    jdk.jsobject \
112    jdk.localedata \
113    jdk.naming.dns \
114    jdk.scripting.nashorn \
115    jdk.security.auth \
116    jdk.security.jgss \
117    jdk.xml.dom \
118    jdk.zipfs \
119    #
120
121JRE_TOOL_MODULES += \
122    jdk.jdwp.agent \
123    jdk.pack \
124    jdk.scripting.nashorn.shell \
125    #
126
127ifeq ($(OPENJDK_TARGET_OS), windows)
128  PLATFORM_MODULES += jdk.crypto.mscapi
129endif
130ifeq ($(OPENJDK_TARGET_OS), solaris)
131  PLATFORM_MODULES += jdk.crypto.ucrypto
132endif
133
134# These modules are included in the interim image which is used to run profiling
135# before building the real images.
136INTERIM_IMAGE_MODULES := java.base java.logging
137
138################################################################################
139# Some platforms don't have the serviceability agent
140
141ifeq ($(INCLUDE_SA), false)
142  MODULES_FILTER += jdk.hotspot.agent
143endif
144
145################################################################################
146# Filter out Graal specific modules if Graal build is disabled
147
148ifeq ($(INCLUDE_GRAAL), false)
149  MODULES_FILTER += jdk.vm.compiler
150endif
151
152################################################################################
153# Filter out aot specific modules if aot is disabled
154
155ifeq ($(ENABLE_AOT), false)
156  MODULES_FILTER += jdk.aot
157endif
158
159################################################################################
160# Module list macros
161
162# Use append so that the custom extension may add to these variables
163
164GENERATED_SRC_DIRS += \
165    $(SUPPORT_OUTPUTDIR)/gensrc \
166    #
167
168TOP_SRC_DIRS += \
169    $(CORBA_TOPDIR)/src \
170    $(HOTSPOT_TOPDIR)/src \
171    $(JDK_TOPDIR)/src \
172    $(LANGTOOLS_TOPDIR)/src \
173    $(JAXP_TOPDIR)/src \
174    $(JAXWS_TOPDIR)/src \
175    $(NASHORN_TOPDIR)/src \
176    #
177
178SRC_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