Modules.gmk revision 2488:5c4f6b099621
148391Speter# 248391Speter# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 348391Speter# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 448391Speter# 548391Speter# This code is free software; you can redistribute it and/or modify it 648391Speter# under the terms of the GNU General Public License version 2 only, as 748391Speter# published by the Free Software Foundation. Oracle designates this 848391Speter# particular file as subject to the "Classpath" exception as provided 948391Speter# by Oracle in the LICENSE file that accompanied this code. 1048391Speter# 1148391Speter# This code is distributed in the hope that it will be useful, but WITHOUT 1248391Speter# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1348391Speter# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1448391Speter# version 2 for more details (a copy is included in the LICENSE file that 1548391Speter# accompanied this code). 1648391Speter# 1748391Speter# You should have received a copy of the GNU General Public License version 1848391Speter# 2 along with this work; if not, write to the Free Software Foundation, 1948391Speter# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2048391Speter# 2148391Speter# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2248391Speter# or visit www.oracle.com if you need additional information or have any 2348391Speter# questions. 2448391Speter# 2548391Speter 2648391Speterifndef _MODULES_GMK 2748391Speter_MODULES_GMK := 1 2848391Speter 2948391Speter################################################################################ 3048391Speter# 3148391Speter# BOOT_MODULES are modules defined by the boot loader 3270317Sjake# PLATFORM_MODULES are modules defined by the platform loader 3374927Sjhb# JRE_TOOL_MODULES are tools included in JRE and defined by the application loader 3474927Sjhb# 3555722Simp# All other modules not declared below are defined by the application loader 3655539Sluoqi# and are not included in JRE. 3774927Sjhb 3848391SpeterBOOT_MODULES := 3948391SpeterPLATFORM_MODULES := 4048391SpeterJRE_TOOL_MODULES := 4148391SpeterUPGRADEABLE_MODULES := 4248391SpeterAGGREGATOR_MODULES := 4348391Speter 4448391Speter# Hook to include the corresponding custom file, if present. 4548391Speter$(eval $(call IncludeCustomExtension, , common/Modules.gmk)) 4648391Speter 4748391SpeterBOOT_MODULES += \ 4848391Speter java.base \ 4948391Speter java.datatransfer \ 5048391Speter java.desktop \ 5148391Speter java.instrument \ 5248391Speter java.logging \ 5348391Speter java.management \ 5448391Speter java.management.rmi \ 5548391Speter java.naming \ 5648391Speter java.prefs \ 5748391Speter java.rmi \ 58104354Sscottl java.security.sasl \ 5948391Speter java.xml \ 6048391Speter jdk.httpserver \ 6148391Speter jdk.management \ 6248391Speter jdk.management.agent \ 6348391Speter jdk.net \ 6465557Sjasone jdk.sctp \ 6548391Speter jdk.unsupported \ 6665557Sjasone jdk.vm.ci \ 6765557Sjasone # 6865557Sjasone 6965557Sjasone# to be deprivileged 7065557SjasoneBOOT_MODULES += \ 7165557Sjasone jdk.naming.rmi \ 7248391Speter # 7348391Speter 7448391SpeterUPGRADEABLE_MODULES += \ 75104354Sscottl java.activation \ 7648391Speter java.corba \ 7748391Speter java.transaction \ 7848391Speter java.xml.bind \ 79103216Sjulian java.xml.ws \ 8048391Speter java.xml.ws.annotation \ 8148391Speter # 82114434Sdes 8365557Sjasone# Modules explicitly declared as not being upgradeable even though they require 8465557Sjasone# an upgradeable module. 8590375SpeterNON_UPGRADEABLE_MODULES += 86104354Sscottl 8748391SpeterAGGREGATOR_MODULES += \ 8848391Speter java.se \ 8948391Speter java.se.ee \ 9048391Speter # 9148391Speter 9248391SpeterPLATFORM_MODULES += \ 9348391Speter $(UPGRADEABLE_MODULES) \ 9448391Speter $(AGGREGATOR_MODULES) 9571559Sjhb # 9671559Sjhb 97114983SjhbPLATFORM_MODULES += \ 98114983Sjhb java.compiler \ 99114983Sjhb jdk.incubator.httpclient \ 10073911Sjhb java.scripting \ 10171559Sjhb java.security.jgss \ 10248391Speter java.smartcardio \ 10348391Speter java.sql \ 10448391Speter java.sql.rowset \ 10548391Speter java.xml.crypto \ 10648391Speter jdk.accessibility \ 10748391Speter jdk.charsets \ 10848391Speter jdk.crypto.ec \ 109103216Sjulian jdk.crypto.cryptoki \ 110103216Sjulian jdk.desktop \ 111103216Sjulian jdk.dynalink \ 11248391Speter jdk.jsobject \ 11369657Sjhb jdk.localedata \ 11469657Sjhb jdk.naming.dns \ 115113631Sjhb jdk.scripting.nashorn \ 116103216Sjulian jdk.security.auth \ 117113631Sjhb jdk.security.jgss \ 11869657Sjhb jdk.vm.compiler \ 11969657Sjhb jdk.xml.dom \ 12048391Speter jdk.zipfs \ 12148391Speter # 12248391Speter 12348391SpeterJRE_TOOL_MODULES += \ 12448391Speter jdk.jdwp.agent \ 12548391Speter jdk.pack \ 12686293Speter jdk.scripting.nashorn.shell \ 12786293Speter # 12870317Sjake 12986293Speterifeq ($(OPENJDK_TARGET_OS), windows) 13086293Speter PLATFORM_MODULES += jdk.crypto.mscapi 13174927Sjhbendif 13286292Sdillonifeq ($(OPENJDK_TARGET_OS), solaris) 13386292Sdillon PLATFORM_MODULES += jdk.crypto.ucrypto 13486292Sdillonendif 13574927Sjhb 13686293Speter# These modules are included in the interim image which is used to run profiling 13748391Speter# before building the real images. 13848391SpeterINTERIM_IMAGE_MODULES := java.base java.logging 13955539Sluoqi 14055539Sluoqi################################################################################ 14155539Sluoqi# Some platforms don't have the serviceability agent 14255539Sluoqi 14355539Sluoqiifeq ($(INCLUDE_SA), false) 14470063Sjhb MODULES_FILTER += jdk.hotspot.agent 14555539Sluoqiendif 14655539Sluoqi 14755539Sluoqi################################################################################ 148104306Sjmallett# Filter out Graal specific modules if Graal build is disabled 14955539Sluoqi 15073911Sjhbifeq ($(INCLUDE_GRAAL), false) 15173911Sjhb MODULES_FILTER += jdk.vm.compiler 15273911Sjhbendif 15355539Sluoqi 15473911Sjhb################################################################################ 155104306Sjmallett# Filter out aot specific modules if aot is disabled 15688160Speter 157104306Sjmallettifeq ($(ENABLE_AOT), false) 15855539Sluoqi MODULES_FILTER += jdk.aot 15955539Sluoqiendif 16055539Sluoqi 16170063Sjhb################################################################################ 16255539Sluoqi# Module list macros 16355539Sluoqi 16455539Sluoqi# Use append so that the custom extension may add to these variables 16555539Sluoqi 16655539SluoqiGENERATED_SRC_DIRS += \ 16773911Sjhb $(SUPPORT_OUTPUTDIR)/gensrc \ 16873911Sjhb # 16973911Sjhb 17055539SluoqiTOP_SRC_DIRS += \ 17173911Sjhb $(CORBA_TOPDIR)/src \ 172104306Sjmallett $(HOTSPOT_TOPDIR)/src \ 17373911Sjhb $(JDK_TOPDIR)/src \ 174104306Sjmallett $(LANGTOOLS_TOPDIR)/src \ 17555539Sluoqi $(JAXP_TOPDIR)/src \ 17655539Sluoqi $(JAXWS_TOPDIR)/src \ 17755539Sluoqi $(NASHORN_TOPDIR)/src \ 17855539Sluoqi # 17970063Sjhb 18055539SluoqiSRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 18173911Sjhbifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 182104306Sjmallett SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 183104306Sjmallettendif 184104306SjmallettSRC_SUBDIRS += share/classes 18555539Sluoqi 18673911Sjhb# Find all module-info.java files for the current build target platform and 18755539Sluoqi# configuration. 188# Param 1 - Module to find for, set to * for finding all 189FindAllModuleInfos = \ 190 $(wildcard \ 191 $(foreach sub, $(SRC_SUBDIRS), \ 192 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 193 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) 194 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