Modules.gmk revision 2052:f70030d86af1
1#
2# Copyright (c) 2014, 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.httpclient \
52    java.instrument \
53    java.logging \
54    java.management \
55    java.naming \
56    java.prefs \
57    java.rmi \
58    java.security.jgss \
59    java.security.sasl \
60    java.sql \
61    java.xml \
62    java.xml.crypto \
63    jdk.httpserver \
64    jdk.management \
65    jdk.net \
66    jdk.sctp \
67    jdk.security.auth \
68    jdk.security.jgss \
69    jdk.unsupported \
70    jdk.vm.ci \
71    #
72
73# to be deprivileged
74BOOT_MODULES += \
75    java.scripting \
76    java.sql.rowset \
77    java.smartcardio \
78    jdk.naming.rmi \
79    #
80
81UPGRADEABLE_MODULES += \
82    java.activation \
83    java.annotations.common \
84    java.corba \
85    java.transaction \
86    java.xml.bind \
87    java.xml.ws \
88    #
89
90AGGREGATOR_MODULES += \
91    java.compact1 \
92    java.compact2 \
93    java.compact3 \
94    java.se \
95    java.se.ee \
96    #
97
98PLATFORM_MODULES += \
99    $(UPGRADEABLE_MODULES) \
100    $(AGGREGATOR_MODULES)
101    #
102
103PLATFORM_MODULES += \
104    java.compiler \
105    jdk.accessibility \
106    jdk.charsets \
107    jdk.crypto.ec \
108    jdk.crypto.pkcs11 \
109    jdk.dynalink \
110    jdk.jsobject \
111    jdk.xml.dom \
112    jdk.localedata \
113    jdk.naming.dns \
114    jdk.scripting.nashorn \
115    jdk.zipfs \
116    #
117
118JRE_TOOL_MODULES += \
119    jdk.jdwp.agent \
120    jdk.pack200 \
121    jdk.scripting.nashorn.shell \
122    #
123
124ifeq ($(OPENJDK_TARGET_OS), windows)
125  PLATFORM_MODULES += jdk.crypto.mscapi
126endif
127ifeq ($(OPENJDK_TARGET_OS), solaris)
128  PLATFORM_MODULES += jdk.crypto.ucrypto
129endif
130
131# These modules are included in the interim image which is used to run profiling
132# before building the real images.
133INTERIM_IMAGE_MODULES := java.base java.logging
134
135################################################################################
136# Some platforms don't have the serviceability agent
137
138ifeq ($(INCLUDE_SA), false)
139  MODULES_FILTER += jdk.hotspot.agent
140endif
141
142################################################################################
143# Module list macros
144
145# Use append so that the custom extension may add to these variables
146
147GENERATED_SRC_DIRS += \
148    $(SUPPORT_OUTPUTDIR)/gensrc \
149    #
150
151TOP_SRC_DIRS += \
152    $(CORBA_TOPDIR)/src \
153    $(HOTSPOT_TOPDIR)/src \
154    $(JDK_TOPDIR)/src \
155    $(LANGTOOLS_TOPDIR)/src \
156    $(JAXP_TOPDIR)/src \
157    $(JAXWS_TOPDIR)/src \
158    $(NASHORN_TOPDIR)/src \
159    #
160
161SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
162ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
163  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
164endif
165SRC_SUBDIRS += share/classes
166
167# Find all module-info.java files for the current build target platform and
168# configuration.
169# Param 1 - Module to find for, set to * for finding all
170FindAllModuleInfos = \
171    $(wildcard \
172        $(foreach sub, $(SRC_SUBDIRS), \
173          $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
174        $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
175
176# Extract the module names from the paths of module-info.java files. The
177# position of the module directory differs depending on if this is an imported
178# src dir or not.
179GetModuleNameFromModuleInfo = \
180    $(strip $(foreach mi, $1, \
181      $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
182        $(notdir $(patsubst %/,%, $(dir $(mi)))), \
183        $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
184
185# Find all modules by looking for module-info.java files and looking at parent
186# directories.
187FindAllModules = \
188    $(sort $(filter-out $(MODULES_FILTER), \
189    $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
190
191FindImportedModules = \
192    $(filter-out $(MODULES_FILTER), \
193    $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
194
195# Find all source dirs for a particular module
196# $1 - Module to find source dirs for
197FindModuleSrcDirs = \
198    $(strip $(wildcard \
199        $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
200        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
201
202# Construct the complete module source path
203GetModuleSrcPath = \
204    $(call PathList, \
205        $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
206        $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
207
208################################################################################
209# Extract module dependencies from module-info.java files.
210
211MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
212
213MODULE_INFOS := $(call FindAllModuleInfos, *)
214
215$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
216    $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
217	$(MKDIR) -p $(@D)
218	$(RM) $@
219	$(foreach m, $(MODULE_INFOS), \
220	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
221	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
222	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
223	          /requires/ { sub(/;/, ""); \
224	                       sub(/requires/, ""); \
225	                       sub(/public/, ""); \
226	                       sub(/\/\/.*/, ""); \
227	                       sub(/\/\*.*\*\//, ""); \
228	                       gsub(/ /, ""); \
229	                       printf(" %s", $$0) } \
230	          END        { printf("\n") }' $m \
231	    ) >> $@ $(NEWLINE))
232
233-include $(MODULE_DEPS_MAKEFILE)
234
235# Param 1: Module to find deps for
236FindDepsForModule = \
237  $(DEPS_$(strip $1))
238
239# Finds transitive dependencies in 3 levels.
240# Param 1: Module to find transitive deps for
241FindTransitiveDepsForModule = \
242    $(sort $(call FindDepsForModule, $1) \
243        $(foreach m, $(call FindDepsForModule, $1), \
244            $(call FindDepsForModule, $m) \
245            $(foreach n, $(call FindDepsForModule, $m), \
246                 $(call FindDepsForModule, $n))))
247
248################################################################################
249
250# Param 1 - Name of module
251define ReadSingleImportMetaData
252    ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
253      classloader :=
254      include_in_jre :=
255      include_in_jdk :=
256      include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
257      ifeq ($$(include_in_jre), true)
258        JRE_MODULES += $1
259      endif
260      ifeq ($$(include_in_jdk), true)
261        JDK_MODULES += $1
262      endif
263      ifeq ($$(classloader), boot)
264        BOOT_MODULES += $1
265      else ifeq ($$(classloader), ext)
266        PLATFORM_MODULES += $1
267      endif
268    else
269      # Default to include in all
270      JRE_MODULES += $1
271      JDK_MODULES += $1
272    endif
273endef
274
275# Reading the imported modules metadata has a cost, so to make it available,
276# a makefile needs to eval-call this macro first. After calling this, the
277# following variables are populated with data from the imported modules:
278# * JRE_MODULES
279# * JDK_MODULES
280# * BOOT_MODULES
281# * PLATFORM_MODULES
282# * JRE_TOOL_MODULES
283define ReadImportMetaData
284    IMPORTED_MODULES := $$(call FindImportedModules)
285    $$(foreach m, $$(IMPORTED_MODULES), \
286      $$(eval $$(call ReadSingleImportMetaData, $$m)))
287endef
288
289################################################################################
290
291endif # _MODULES_GMK
292