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