Modules.gmk revision 2592:a09f8a1f40ef
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 :=
43DOCS_MODULES :=
44
45# Hook to include the corresponding custom file, if present.
46$(eval $(call IncludeCustomExtension, , common/Modules.gmk))
47
48BOOT_MODULES += \
49    java.base \
50    java.datatransfer \
51    java.desktop \
52    java.instrument \
53    java.logging \
54    java.management \
55    java.management.rmi \
56    java.naming \
57    java.prefs \
58    java.rmi \
59    java.security.sasl \
60    java.xml \
61    jdk.httpserver \
62    jdk.internal.vm.ci \
63    jdk.management \
64    jdk.management.agent \
65    jdk.net \
66    jdk.sctp \
67    jdk.unsupported \
68    #
69
70# to be deprivileged
71BOOT_MODULES += \
72    jdk.naming.rmi \
73    #
74
75UPGRADEABLE_MODULES += \
76    java.activation \
77    java.corba \
78    java.transaction \
79    java.xml.bind \
80    java.xml.ws \
81    java.xml.ws.annotation \
82    jdk.internal.vm.compiler \
83    #
84
85# Modules explicitly declared as not being upgradeable even though they require
86# an upgradeable module.
87NON_UPGRADEABLE_MODULES += \
88    jdk.aot \
89    #
90
91AGGREGATOR_MODULES += \
92    java.se \
93    java.se.ee \
94    #
95
96PLATFORM_MODULES += \
97    $(UPGRADEABLE_MODULES) \
98    $(AGGREGATOR_MODULES)
99    #
100
101PLATFORM_MODULES += \
102    java.compiler \
103    java.scripting \
104    java.security.jgss \
105    java.smartcardio \
106    java.sql \
107    java.sql.rowset \
108    java.xml.crypto \
109    jdk.accessibility \
110    jdk.charsets \
111    jdk.crypto.cryptoki \
112    jdk.crypto.ec \
113    jdk.dynalink \
114    jdk.incubator.httpclient \
115    jdk.jsobject \
116    jdk.localedata \
117    jdk.naming.dns \
118    jdk.scripting.nashorn \
119    jdk.security.auth \
120    jdk.security.jgss \
121    jdk.xml.dom \
122    jdk.zipfs \
123    #
124
125ifeq ($(OPENJDK_TARGET_OS), windows)
126  PLATFORM_MODULES += jdk.crypto.mscapi
127endif
128
129ifeq ($(OPENJDK_TARGET_OS), solaris)
130  PLATFORM_MODULES += jdk.crypto.ucrypto
131endif
132
133JRE_TOOL_MODULES += \
134    jdk.jdwp.agent \
135    jdk.pack \
136    jdk.scripting.nashorn.shell \
137    #
138
139################################################################################
140
141# DOCS_MODULES defines the root modules for javadoc generation.
142# All of their `require transitive` modules directly and indirectly will be included.
143DOCS_MODULES += \
144    java.se.ee \
145    java.smartcardio \
146    jdk.accessibility \
147    jdk.attach \
148    jdk.charsets \
149    jdk.compiler \
150    jdk.crypto.cryptoki \
151    jdk.crypto.ec \
152    jdk.dynalink \
153    jdk.editpad \
154    jdk.httpserver \
155    jdk.incubator.httpclient \
156    jdk.jartool \
157    jdk.javadoc \
158    jdk.jcmd \
159    jdk.jconsole \
160    jdk.jdeps \
161    jdk.jdi \
162    jdk.jdwp.agent \
163    jdk.jlink \
164    jdk.jsobject \
165    jdk.jshell \
166    jdk.jstatd \
167    jdk.localedata \
168    jdk.management \
169    jdk.management.agent \
170    jdk.naming.dns \
171    jdk.naming.rmi \
172    jdk.net \
173    jdk.pack \
174    jdk.policytool \
175    jdk.rmic \
176    jdk.scripting.nashorn \
177    jdk.sctp \
178    jdk.security.auth \
179    jdk.security.jgss \
180    jdk.xml.dom \
181    jdk.zipfs \
182    #
183
184# These modules are included in the interim image which is used to run profiling
185# before building the real images.
186INTERIM_IMAGE_MODULES := java.base java.logging
187
188################################################################################
189# Some platforms don't have the serviceability agent
190
191ifeq ($(INCLUDE_SA), false)
192  MODULES_FILTER += jdk.hotspot.agent
193endif
194
195################################################################################
196# Filter out Graal specific modules if Graal build is disabled
197
198ifeq ($(INCLUDE_GRAAL), false)
199  MODULES_FILTER += jdk.internal.vm.compiler
200endif
201
202################################################################################
203# Filter out aot specific modules if aot is disabled
204
205ifeq ($(ENABLE_AOT), false)
206  MODULES_FILTER += jdk.aot
207endif
208
209################################################################################
210# Module list macros
211
212# Use append so that the custom extension may add to these variables
213
214GENERATED_SRC_DIRS += \
215    $(SUPPORT_OUTPUTDIR)/gensrc \
216    #
217
218TOP_SRC_DIRS += \
219    $(CORBA_TOPDIR)/src \
220    $(HOTSPOT_TOPDIR)/src \
221    $(JDK_TOPDIR)/src \
222    $(LANGTOOLS_TOPDIR)/src \
223    $(JAXP_TOPDIR)/src \
224    $(JAXWS_TOPDIR)/src \
225    $(NASHORN_TOPDIR)/src \
226    #
227
228SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
229ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
230  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
231endif
232SRC_SUBDIRS += share/classes
233
234SPEC_SUBDIRS += share/specs
235
236# Find all module-info.java files for the current build target platform and
237# configuration.
238# Param 1 - Module to find for, set to * for finding all
239FindAllModuleInfos = \
240    $(wildcard \
241        $(foreach sub, $(SRC_SUBDIRS), \
242          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
243        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
244
245# Find module-info.java files in the specific source dir
246# Param 1 - Src dir to find module-info.java files in
247FindModuleInfosForSrcDir = \
248    $(wildcard \
249        $(foreach sub, $(SRC_SUBDIRS), \
250          $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
251        ) \
252        $(patsubst %,%/*/module-info.java, $(strip $1)) \
253    )
254
255# Extract the module names from the paths of module-info.java files. The
256# position of the module directory differs depending on if this is an imported
257# src dir or not.
258GetModuleNameFromModuleInfo = \
259    $(strip $(foreach mi, $1, \
260      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
261        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
262        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
263
264# Find all modules by looking for module-info.java files and looking at parent
265# directories.
266FindAllModules = \
267    $(sort $(filter-out $(MODULES_FILTER), \
268    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
269
270# Find all modules in a specific src dir
271# Param 1 - Src dir to find modules in
272FindModulesForSrcDir = \
273    $(sort $(filter-out $(MODULES_FILTER), \
274        $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
275    ))
276
277FindImportedModules = \
278    $(filter-out $(MODULES_FILTER), \
279    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
280
281# Find all source dirs for a particular module
282# $1 - Module to find source dirs for
283FindModuleSrcDirs = \
284    $(strip $(wildcard \
285        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
286        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
287
288# Find all specs dirs for a particular module
289# $1 - Module to find specs dirs for
290FindModuleSpecsDirs = \
291    $(strip $(wildcard \
292        $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
293
294# Construct the complete module source path
295GetModuleSrcPath = \
296    $(call PathList, \
297        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
298        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
299
300################################################################################
301# Extract module dependencies from module-info.java files.
302
303MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
304
305MODULE_INFOS := $(call FindAllModuleInfos, *)
306
307$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
308    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
309	$(MKDIR) -p $(@D)
310	$(RM) $@
311	$(foreach m, $(MODULE_INFOS), \
312	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
313	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
314	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
315	          /^ *requires/ { sub(/;/, ""); \
316	                          sub(/requires/, ""); \
317	                          sub(/transitive/, ""); \
318	                          sub(/\/\/.*/, ""); \
319	                          sub(/\/\*.*\*\//, ""); \
320	                          gsub(/^ +\*.*/, ""); \
321	                          gsub(/ /, ""); \
322	                          printf(" %s", $$0) } \
323	          END           { printf("\n") }' $m \
324	    ) >> $@ $(NEWLINE))
325
326-include $(MODULE_DEPS_MAKEFILE)
327
328# Param 1: Module to find deps for
329FindDepsForModule = \
330  $(DEPS_$(strip $1))
331
332# Finds transitive dependencies in 3 levels.
333# Param 1: Module to find transitive deps for
334FindTransitiveDepsForModule = \
335    $(sort $(call FindDepsForModule, $1) \
336        $(foreach m, $(call FindDepsForModule, $1), \
337            $(call FindDepsForModule, $m) \
338            $(foreach n, $(call FindDepsForModule, $m), \
339                 $(call FindDepsForModule, $n))))
340
341# Finds transitive dependencies in 3 levels for a set of modules.
342# Param 1: List of modules to find transitive deps for
343FindTransitiveDepsForModules = \
344    $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
345
346# Upgradeable modules are those that are either defined as upgradeable or that
347# require an upradeable module.
348FindAllUpgradeableModules = \
349    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
350        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
351            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
352          $(if $(filter $(UPGRADEABLE_MODULES), \
353              $(call FindTransitiveDepsForModule, $m)), \
354            $m \
355          ) \
356        )) \
357    )
358
359################################################################################
360
361LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal
362ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
363  LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal
364endif
365LEGAL_SUBDIRS += share/legal
366
367# Find all legal dirs for a particular module
368# $1 - Module to find legal dirs for
369FindModuleLegalDirs = \
370    $(strip $(wildcard \
371        $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
372        $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
373
374################################################################################
375
376# Param 1 - Name of module
377define ReadSingleImportMetaData
378    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
379      classloader :=
380      include_in_jre :=
381      include_in_jdk :=
382      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
383      ifeq ($$(include_in_jre), true)
384        JRE_MODULES += $1
385      endif
386      ifeq ($$(include_in_jdk), true)
387        JDK_MODULES += $1
388      endif
389      ifeq ($$(classloader), boot)
390        BOOT_MODULES += $1
391      else ifeq ($$(classloader), ext)
392        PLATFORM_MODULES += $1
393      endif
394      DOCS_MODULES += $1
395    else
396      # Default to include in all
397      JRE_MODULES += $1
398      JDK_MODULES += $1
399    endif
400endef
401
402# Reading the imported modules metadata has a cost, so to make it available,
403# a makefile needs to eval-call this macro first. After calling this, the
404# following variables are populated with data from the imported modules:
405# * JRE_MODULES
406# * JDK_MODULES
407# * BOOT_MODULES
408# * PLATFORM_MODULES
409# * JRE_TOOL_MODULES
410define ReadImportMetaData
411    IMPORTED_MODULES := $$(call FindImportedModules)
412    $$(foreach m, $$(IMPORTED_MODULES), \
413      $$(eval $$(call ReadSingleImportMetaData, $$m)))
414endef
415
416################################################################################
417
418endif # _MODULES_GMK
419