Modules.gmk revision 2456:8d26916eaa21
1116743Ssam# 2186904Ssam# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 3116743Ssam# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4116743Ssam# 5116743Ssam# This code is free software; you can redistribute it and/or modify it 6116743Ssam# under the terms of the GNU General Public License version 2 only, as 7116743Ssam# published by the Free Software Foundation. Oracle designates this 8116743Ssam# particular file as subject to the "Classpath" exception as provided 9116743Ssam# by Oracle in the LICENSE file that accompanied this code. 10116743Ssam# 11116743Ssam# This code is distributed in the hope that it will be useful, but WITHOUT 12116743Ssam# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13116743Ssam# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14116743Ssam# version 2 for more details (a copy is included in the LICENSE file that 15116743Ssam# accompanied this code). 16116743Ssam# 17116743Ssam# You should have received a copy of the GNU General Public License version 18116743Ssam# 2 along with this work; if not, write to the Free Software Foundation, 19116743Ssam# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20116743Ssam# 21116743Ssam# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22116743Ssam# or visit www.oracle.com if you need additional information or have any 23116743Ssam# questions. 24116743Ssam# 25116743Ssam 26116743Ssamifndef _MODULES_GMK 27116743Ssam_MODULES_GMK := 1 28116743Ssam 29116743Ssam################################################################################ 30116743Ssam# 31116743Ssam# BOOT_MODULES are modules defined by the boot loader 32116743Ssam# PLATFORM_MODULES are modules defined by the platform loader 33116743Ssam# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader 34116743Ssam# 35116743Ssam# All other modules not declared below are defined by the application loader 36116743Ssam# and are not included in JRE. 37116743Ssam 38116743SsamBOOT_MODULES := 39116743SsamPLATFORM_MODULES := 40116743SsamJRE_TOOL_MODULES := 41116743SsamUPGRADEABLE_MODULES := 42155492SsamAGGREGATOR_MODULES := 43138570Ssam 44116743Ssam# Hook to include the corresponding custom file, if present. 45116743Ssam$(eval $(call IncludeCustomExtension, , common/Modules.gmk)) 46116743Ssam 47138570SsamBOOT_MODULES += \ 48116743Ssam java.base \ 49138570Ssam java.datatransfer \ 50116743Ssam java.desktop \ 51116743Ssam java.instrument \ 52116743Ssam java.logging \ 53116743Ssam java.management \ 54116743Ssam java.naming \ 55116743Ssam java.prefs \ 56116743Ssam java.rmi \ 57116743Ssam java.security.sasl \ 58116743Ssam java.xml \ 59116743Ssam jdk.httpserver \ 60116743Ssam jdk.management \ 61116743Ssam jdk.net \ 62116743Ssam jdk.sctp \ 63116743Ssam jdk.unsupported \ 64116743Ssam jdk.vm.ci \ 65116743Ssam # 66116743Ssam 67116743Ssam# to be deprivileged 68116743SsamBOOT_MODULES += \ 69116743Ssam jdk.naming.rmi \ 70127779Ssam # 71127779Ssam 72170530SsamUPGRADEABLE_MODULES += \ 73170530Ssam java.activation \ 74116743Ssam java.annotations.common \ 75116743Ssam java.corba \ 76116743Ssam java.transaction \ 77116743Ssam java.xml.bind \ 78116743Ssam java.xml.ws \ 79116743Ssam # 80138570Ssam 81116743Ssam# Modules explicitly declared as not being upgradeable even though they require 82116743Ssam# an upgradeable module. 83119147SsamNON_UPGRADEABLE_MODULES += 84127779Ssam 85138570SsamAGGREGATOR_MODULES += \ 86138570Ssam java.se \ 87119147Ssam java.se.ee \ 88138570Ssam # 89138570Ssam 90161187SsamPLATFORM_MODULES += \ 91138570Ssam $(UPGRADEABLE_MODULES) \ 92116743Ssam $(AGGREGATOR_MODULES) 93116743Ssam # 94116743Ssam 95116743SsamPLATFORM_MODULES += \ 96116743Ssam java.compiler \ 97116743Ssam jdk.incubator.httpclient \ 98116743Ssam java.scripting \ 99138570Ssam java.security.jgss \ 100138570Ssam java.smartcardio \ 101138570Ssam java.sql \ 102138570Ssam java.sql.rowset \ 103159894Ssam java.xml.crypto \ 104159894Ssam jdk.accessibility \ 105160992Ssam jdk.charsets \ 106170530Ssam jdk.crypto.ec \ 107170530Ssam jdk.crypto.cryptoki \ 108170530Ssam jdk.desktop \ 109170530Ssam jdk.dynalink \ 110170530Ssam jdk.jsobject \ 111170530Ssam jdk.localedata \ 112186904Ssam jdk.naming.dns \ 113186904Ssam jdk.scripting.nashorn \ 114186904Ssam jdk.security.auth \ 115186904Ssam jdk.security.jgss \ 116186904Ssam jdk.xml.dom \ 117186904Ssam jdk.zipfs \ 118188195Ssam # 119188195Ssam 120188555SsamJRE_TOOL_MODULES += \ 121211299Sadrian jdk.jdwp.agent \ 122217684Sadrian jdk.pack \ 123217684Sadrian jdk.scripting.nashorn.shell \ 124116743Ssam # 125116743Ssam 126116743Ssamifeq ($(OPENJDK_TARGET_OS), windows) 127188557Ssam PLATFORM_MODULES += jdk.crypto.mscapi 128116743Ssamendif 129123044Ssamifeq ($(OPENJDK_TARGET_OS), solaris) 130138570Ssam PLATFORM_MODULES += jdk.crypto.ucrypto 131138570Ssamendif 132138570Ssam 133138570Ssam# These modules are included in the interim image which is used to run profiling 134138570Ssam# before building the real images. 135138570SsamINTERIM_IMAGE_MODULES := java.base java.logging 136138570Ssam 137138570Ssam################################################################################ 138138570Ssam# Some platforms don't have the serviceability agent 139138570Ssam 140123044Ssamifeq ($(INCLUDE_SA), false) 141123044Ssam MODULES_FILTER += jdk.hotspot.agent 142123044Ssamendif 143123044Ssam 144119783Ssam################################################################################ 145119783Ssam# Filter out Graal specific modules if Graal build is disabled 146119783Ssam 147119783Ssamifeq ($(INCLUDE_GRAAL), false) 148154140Ssam MODULES_FILTER += jdk.vm.compiler 149119783Ssamendif 150119783Ssam 151123928Ssam################################################################################ 152154140Ssam# Filter out aot specific modules if aot is disabled 153154140Ssam 154170530Ssamifeq ($(ENABLE_AOT), false) 155119783Ssam MODULES_FILTER += jdk.aot 156119783Ssamendif 157119783Ssam 158119783Ssam################################################################################ 159154140Ssam# Module list macros 160154140Ssam 161119783Ssam# Use append so that the custom extension may add to these variables 162170530Ssam 163170530SsamGENERATED_SRC_DIRS += \ 164170530Ssam $(SUPPORT_OUTPUTDIR)/gensrc \ 165170530Ssam # 166170530Ssam 167119783SsamTOP_SRC_DIRS += \ 168170530Ssam $(CORBA_TOPDIR)/src \ 169170530Ssam $(HOTSPOT_TOPDIR)/src \ 170170530Ssam $(JDK_TOPDIR)/src \ 171119783Ssam $(LANGTOOLS_TOPDIR)/src \ 172119783Ssam $(JAXP_TOPDIR)/src \ 173154140Ssam $(JAXWS_TOPDIR)/src \ 174119783Ssam $(NASHORN_TOPDIR)/src \ 175119783Ssam # 176123928Ssam 177123928SsamSRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 178170530Ssamifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 179119783Ssam SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 180119783Ssamendif 181119783SsamSRC_SUBDIRS += share/classes 182119783Ssam 183154140Ssam# Find all module-info.java files for the current build target platform and 184154140Ssam# configuration. 185119783Ssam# TODO: The $(firstword call is part of a workaround for using different 186123928Ssam# imported module-info.java in Jake due to a change in format. Remove once 187123928Ssam# new format is standard in JDK 9 and javafx delivers just that. 188170530Ssam# Param 1 - Module to find for, set to * for finding all 189170530SsamFindAllModuleInfos = \ 190170530Ssam $(wildcard \ 191170530Ssam $(foreach sub, $(SRC_SUBDIRS), \ 192170530Ssam $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 193119783Ssam $(patsubst %,%/$(strip $1)/module-info.java, $(firstword $(IMPORT_MODULES_SRC)))) 194116743Ssam 195# Find module-info.java files in the specific source dir 196# Param 1 - Src dir to find module-info.java files in 197FindModuleInfosForSrcDir = \ 198 $(wildcard \ 199 $(foreach sub, $(SRC_SUBDIRS), \ 200 $(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \ 201 ) \ 202 $(patsubst %,%/*/module-info.java, $(strip $1)) \ 203 ) 204 205# Extract the module names from the paths of module-info.java files. The 206# position of the module directory differs depending on if this is an imported 207# src dir or not. 208GetModuleNameFromModuleInfo = \ 209 $(strip $(foreach mi, $1, \ 210 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 211 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 212 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 213 214# Find all modules by looking for module-info.java files and looking at parent 215# directories. 216FindAllModules = \ 217 $(sort $(filter-out $(MODULES_FILTER), \ 218 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 219 220# Find all modules in a specific src dir 221# Param 1 - Src dir to find modules in 222FindModulesForSrcDir = \ 223 $(sort $(filter-out $(MODULES_FILTER), \ 224 $(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \ 225 )) 226 227FindImportedModules = \ 228 $(filter-out $(MODULES_FILTER), \ 229 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 230 231# Find all source dirs for a particular module 232# $1 - Module to find source dirs for 233FindModuleSrcDirs = \ 234 $(strip $(wildcard \ 235 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 236 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 237 238# Construct the complete module source path 239GetModuleSrcPath = \ 240 $(call PathList, \ 241 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 242 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 243 244################################################################################ 245# Extract module dependencies from module-info.java files. 246 247MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 248 249MODULE_INFOS := $(call FindAllModuleInfos, *) 250 251$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 252 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 253 $(MKDIR) -p $(@D) 254 $(RM) $@ 255 $(foreach m, $(MODULE_INFOS), \ 256 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 257 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 258 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 259 /requires/ { sub(/;/, ""); \ 260 sub(/requires/, ""); \ 261 sub(/transitive/, ""); \ 262 sub(/\/\/.*/, ""); \ 263 sub(/\/\*.*\*\//, ""); \ 264 gsub(/^ +\*.*/, ""); \ 265 gsub(/ /, ""); \ 266 printf(" %s", $$0) } \ 267 END { printf("\n") }' $m \ 268 ) >> $@ $(NEWLINE)) 269 270-include $(MODULE_DEPS_MAKEFILE) 271 272# Param 1: Module to find deps for 273FindDepsForModule = \ 274 $(DEPS_$(strip $1)) 275 276# Finds transitive dependencies in 3 levels. 277# Param 1: Module to find transitive deps for 278FindTransitiveDepsForModule = \ 279 $(sort $(call FindDepsForModule, $1) \ 280 $(foreach m, $(call FindDepsForModule, $1), \ 281 $(call FindDepsForModule, $m) \ 282 $(foreach n, $(call FindDepsForModule, $m), \ 283 $(call FindDepsForModule, $n)))) 284 285# Upgradeable modules are those that are either defined as upgradeable or that 286# require an upradeable module. 287FindAllUpgradeableModules = \ 288 $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \ 289 $(sort $(UPGRADEABLE_MODULES) $(foreach m, \ 290 $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \ 291 $(if $(filter $(UPGRADEABLE_MODULES), \ 292 $(call FindTransitiveDepsForModule, $m)), \ 293 $m \ 294 ) \ 295 )) \ 296 ) 297 298################################################################################ 299 300LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS)/legal 301ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 302 LEGAL_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/legal 303endif 304LEGAL_SUBDIRS += share/legal 305 306# Find all legal dirs for a particular module 307# $1 - Module to find legal dirs for 308FindModuleLegalDirs = \ 309 $(strip $(wildcard \ 310 $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \ 311 $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 312 313################################################################################ 314 315# Param 1 - Name of module 316define ReadSingleImportMetaData 317 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 318 classloader := 319 include_in_jre := 320 include_in_jdk := 321 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 322 ifeq ($$(include_in_jre), true) 323 JRE_MODULES += $1 324 endif 325 ifeq ($$(include_in_jdk), true) 326 JDK_MODULES += $1 327 endif 328 ifeq ($$(classloader), boot) 329 BOOT_MODULES += $1 330 else ifeq ($$(classloader), ext) 331 PLATFORM_MODULES += $1 332 endif 333 else 334 # Default to include in all 335 JRE_MODULES += $1 336 JDK_MODULES += $1 337 endif 338endef 339 340# Reading the imported modules metadata has a cost, so to make it available, 341# a makefile needs to eval-call this macro first. After calling this, the 342# following variables are populated with data from the imported modules: 343# * JRE_MODULES 344# * JDK_MODULES 345# * BOOT_MODULES 346# * PLATFORM_MODULES 347# * JRE_TOOL_MODULES 348define ReadImportMetaData 349 IMPORTED_MODULES := $$(call FindImportedModules) 350 $$(foreach m, $$(IMPORTED_MODULES), \ 351 $$(eval $$(call ReadSingleImportMetaData, $$m))) 352endef 353 354################################################################################ 355 356endif # _MODULES_GMK 357