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