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