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