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