Modules.gmk revision 2479:783ec7542cf7
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.desktop \ 111 jdk.dynalink \ 112 jdk.jsobject \ 113 jdk.localedata \ 114 jdk.naming.dns \ 115 jdk.scripting.nashorn \ 116 jdk.security.auth \ 117 jdk.security.jgss \ 118 jdk.xml.dom \ 119 jdk.zipfs \ 120 # 121 122JRE_TOOL_MODULES += \ 123 jdk.jdwp.agent \ 124 jdk.pack \ 125 jdk.scripting.nashorn.shell \ 126 # 127 128ifeq ($(OPENJDK_TARGET_OS), windows) 129 PLATFORM_MODULES += jdk.crypto.mscapi 130endif 131ifeq ($(OPENJDK_TARGET_OS), solaris) 132 PLATFORM_MODULES += jdk.crypto.ucrypto 133endif 134 135# These modules are included in the interim image which is used to run profiling 136# before building the real images. 137INTERIM_IMAGE_MODULES := java.base java.logging 138 139################################################################################ 140# Some platforms don't have the serviceability agent 141 142ifeq ($(INCLUDE_SA), false) 143 MODULES_FILTER += jdk.hotspot.agent 144endif 145 146################################################################################ 147# Filter out Graal specific modules if Graal build is disabled 148 149ifeq ($(INCLUDE_GRAAL), false) 150 MODULES_FILTER += jdk.vm.compiler 151endif 152 153################################################################################ 154# Filter out aot specific modules if aot is disabled 155 156ifeq ($(ENABLE_AOT), false) 157 MODULES_FILTER += jdk.aot 158endif 159 160################################################################################ 161# Module list macros 162 163# Use append so that the custom extension may add to these variables 164 165GENERATED_SRC_DIRS += \ 166 $(SUPPORT_OUTPUTDIR)/gensrc \ 167 # 168 169TOP_SRC_DIRS += \ 170 $(CORBA_TOPDIR)/src \ 171 $(HOTSPOT_TOPDIR)/src \ 172 $(JDK_TOPDIR)/src \ 173 $(LANGTOOLS_TOPDIR)/src \ 174 $(JAXP_TOPDIR)/src \ 175 $(JAXWS_TOPDIR)/src \ 176 $(NASHORN_TOPDIR)/src \ 177 # 178 179SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 180ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 181 SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 182endif 183SRC_SUBDIRS += share/classes 184 185# Find all module-info.java files for the current build target platform and 186# configuration. 187# Param 1 - Module to find for, set to * for finding all 188FindAllModuleInfos = \ 189 $(wildcard \ 190 $(foreach sub, $(SRC_SUBDIRS), \ 191 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 192 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) 193 194# Find module-info.java files in the specific source dir 195# Param 1 - Src dir to find module-info.java files in 196FindModuleInfosForSrcDir = \ 197 $(wildcard \ 198 $(foreach sub, $(SRC_SUBDIRS), \ 199 $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \ 200 ) \ 201 $(patsubst %,%/*/module-info.java, $(strip $1)) \ 202 ) 203 204# Extract the module names from the paths of module-info.java files. The 205# position of the module directory differs depending on if this is an imported 206# src dir or not. 207GetModuleNameFromModuleInfo = \ 208 $(strip $(foreach mi, $1, \ 209 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 210 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 211 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 212 213# Find all modules by looking for module-info.java files and looking at parent 214# directories. 215FindAllModules = \ 216 $(sort $(filter-out $(MODULES_FILTER), \ 217 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 218 219# Find all modules in a specific src dir 220# Param 1 - Src dir to find modules in 221FindModulesForSrcDir = \ 222 $(sort $(filter-out $(MODULES_FILTER), \ 223 $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \ 224 )) 225 226FindImportedModules = \ 227 $(filter-out $(MODULES_FILTER), \ 228 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 229 230# Find all source dirs for a particular module 231# $1 - Module to find source dirs for 232FindModuleSrcDirs = \ 233 $(strip $(wildcard \ 234 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 235 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 236 237# Construct the complete module source path 238GetModuleSrcPath = \ 239 $(call PathList, \ 240 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 241 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 242 243################################################################################ 244# Extract module dependencies from module-info.java files. 245 246MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 247 248MODULE_INFOS := $(call FindAllModuleInfos, *) 249 250$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 251 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 252 $(MKDIR) -p $(@D) 253 $(RM) $@ 254 $(foreach m, $(MODULE_INFOS), \ 255 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 256 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 257 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 258 /requires/ { sub(/;/, ""); \ 259 sub(/requires/, ""); \ 260 sub(/transitive/, ""); \ 261 sub(/\/\/.*/, ""); \ 262 sub(/\/\*.*\*\//, ""); \ 263 gsub(/^ +\*.*/, ""); \ 264 gsub(/ /, ""); \ 265 printf(" %s", $$0) } \ 266 END { printf("\n") }' $m \ 267 ) >> $@ $(NEWLINE)) 268 269-include $(MODULE_DEPS_MAKEFILE) 270 271# Param 1: Module to find deps for 272FindDepsForModule = \ 273 $(DEPS_$(strip $1)) 274 275# Finds transitive dependencies in 3 levels. 276# Param 1: Module to find transitive deps for 277FindTransitiveDepsForModule = \ 278 $(sort $(call FindDepsForModule, $1) \ 279 $(foreach m, $(call FindDepsForModule, $1), \ 280 $(call FindDepsForModule, $m) \ 281 $(foreach n, $(call FindDepsForModule, $m), \ 282 $(call FindDepsForModule, $n)))) 283 284# Upgradeable modules are those that are either defined as upgradeable or that 285# require an upradeable module. 286FindAllUpgradeableModules = \ 287 $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \ 288 $(sort $(UPGRADEABLE_MODULES) $(foreach m, \ 289 $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \ 290 $(if $(filter $(UPGRADEABLE_MODULES), \ 291 $(call FindTransitiveDepsForModule, $m)), \ 292 $m \ 293 ) \ 294 )) \ 295 ) 296 297################################################################################ 298 299LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal 300ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 301 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal 302endif 303LEGAL_SUBDIRS += share/legal 304 305# Find all legal dirs for a particular module 306# $1 - Module to find legal dirs for 307FindModuleLegalDirs = \ 308 $(strip $(wildcard \ 309 $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ 310 $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 311 312################################################################################ 313 314# Param 1 - Name of module 315define ReadSingleImportMetaData 316 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 317 classloader := 318 include_in_jre := 319 include_in_jdk := 320 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 321 ifeq ($$(include_in_jre), true) 322 JRE_MODULES += $1 323 endif 324 ifeq ($$(include_in_jdk), true) 325 JDK_MODULES += $1 326 endif 327 ifeq ($$(classloader), boot) 328 BOOT_MODULES += $1 329 else ifeq ($$(classloader), ext) 330 PLATFORM_MODULES += $1 331 endif 332 else 333 # Default to include in all 334 JRE_MODULES += $1 335 JDK_MODULES += $1 336 endif 337endef 338 339# Reading the imported modules metadata has a cost, so to make it available, 340# a makefile needs to eval-call this macro first. After calling this, the 341# following variables are populated with data from the imported modules: 342# * JRE_MODULES 343# * JDK_MODULES 344# * BOOT_MODULES 345# * PLATFORM_MODULES 346# * JRE_TOOL_MODULES 347define ReadImportMetaData 348 IMPORTED_MODULES := $$(call FindImportedModules) 349 $$(foreach m, $$(IMPORTED_MODULES), \ 350 $$(eval $$(call ReadSingleImportMetaData, $$m))) 351endef 352 353################################################################################ 354 355endif # _MODULES_GMK 356