Modules.gmk revision 2037:5a2fe64cd60c
1# 2# Copyright (c) 2014, 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 := 41 42# Hook to include the corresponding custom file, if present. 43$(eval $(call IncludeCustomExtension, , common/Modules.gmk)) 44 45UPGRADEABLE_MDOULES := 46AGGREGATOR_MDOULES := 47 48BOOT_MODULES += \ 49 java.base \ 50 java.datatransfer \ 51 java.desktop \ 52 java.httpclient \ 53 java.instrument \ 54 java.logging \ 55 java.management \ 56 java.naming \ 57 java.prefs \ 58 java.rmi \ 59 java.security.jgss \ 60 java.security.sasl \ 61 java.sql \ 62 java.xml \ 63 java.xml.crypto \ 64 jdk.httpserver \ 65 jdk.management \ 66 jdk.net \ 67 jdk.sctp \ 68 jdk.security.auth \ 69 jdk.security.jgss \ 70 jdk.unsupported \ 71 jdk.vm.ci \ 72 # 73 74# to be deprivileged 75BOOT_MODULES += \ 76 java.compiler \ 77 java.scripting \ 78 java.sql.rowset \ 79 java.smartcardio \ 80 jdk.charsets \ 81 jdk.naming.rmi \ 82 # 83 84UPGRADEABLE_MODULES += \ 85 java.activation \ 86 java.annotations.common \ 87 java.corba \ 88 java.transaction \ 89 java.xml.bind \ 90 java.xml.ws \ 91 # 92 93AGGREGATOR_MODULES += \ 94 java.compact1 \ 95 java.compact2 \ 96 java.compact3 \ 97 java.se \ 98 java.se.ee \ 99 # 100 101PLATFORM_MODULES += \ 102 $(UPGRADEABLE_MODULES) \ 103 $(AGGREGATOR_MODULES) 104 # 105 106PLATFORM_MODULES += \ 107 jdk.accessibility \ 108 jdk.crypto.ec \ 109 jdk.crypto.pkcs11 \ 110 jdk.dynalink \ 111 jdk.jsobject \ 112 jdk.xml.dom \ 113 jdk.localedata \ 114 jdk.naming.dns \ 115 jdk.scripting.nashorn \ 116 jdk.zipfs \ 117 # 118 119JRE_TOOL_MODULES += \ 120 jdk.jdwp.agent \ 121 jdk.pack200 \ 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################################################################################ 133# Some platforms don't have the serviceability agent 134 135ifeq ($(INCLUDE_SA), false) 136 MODULES_FILTER += jdk.hotspot.agent 137endif 138 139################################################################################ 140# Module list macros 141 142# Use append so that the custom extension may add to these variables 143 144GENERATED_SRC_DIRS += \ 145 $(SUPPORT_OUTPUTDIR)/gensrc \ 146 # 147 148TOP_SRC_DIRS += \ 149 $(CORBA_TOPDIR)/src \ 150 $(HOTSPOT_TOPDIR)/src \ 151 $(JDK_TOPDIR)/src \ 152 $(LANGTOOLS_TOPDIR)/src \ 153 $(JAXP_TOPDIR)/src \ 154 $(JAXWS_TOPDIR)/src \ 155 $(NASHORN_TOPDIR)/src \ 156 # 157 158SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 159ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 160 SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes 161endif 162SRC_SUBDIRS += share/classes 163 164# Find all module-info.java files for the current build target platform and 165# configuration. 166# Param 1 - Module to find for, set to * for finding all 167FindAllModuleInfos = \ 168 $(wildcard \ 169 $(foreach sub, $(SRC_SUBDIRS), \ 170 $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ 171 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) 172 173# Extract the module names from the paths of module-info.java files. The 174# position of the module directory differs depending on if this is an imported 175# src dir or not. 176GetModuleNameFromModuleInfo = \ 177 $(strip $(foreach mi, $1, \ 178 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 179 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 180 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 181 182# Find all modules by looking for module-info.java files and looking at parent 183# directories. 184FindAllModules = \ 185 $(sort $(filter-out $(MODULES_FILTER), \ 186 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 187 188FindImportedModules = \ 189 $(filter-out $(MODULES_FILTER), \ 190 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) 191 192# Find all source dirs for a particular module 193# $1 - Module to find source dirs for 194FindModuleSrcDirs = \ 195 $(strip $(wildcard \ 196 $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 197 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) 198 199# Construct the complete module source path 200GetModuleSrcPath = \ 201 $(call PathList, \ 202 $(addsuffix /*, $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ 203 $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS)))) 204 205################################################################################ 206# Extract module dependencies from module-info.java files. 207 208MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 209 210MODULE_INFOS := $(call FindAllModuleInfos, *) 211 212$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 213 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 214 $(MKDIR) -p $(@D) 215 $(RM) $@ 216 $(foreach m, $(MODULE_INFOS), \ 217 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 218 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 219 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 220 /requires/ { sub(/;/, ""); \ 221 sub(/requires/, ""); \ 222 sub(/public/, ""); \ 223 sub(/\/\/.*/, ""); \ 224 sub(/\/\*.*\*\//, ""); \ 225 gsub(/ /, ""); \ 226 printf(" %s", $$0) } \ 227 END { printf("\n") }' $m \ 228 ) >> $@ $(NEWLINE)) 229 230-include $(MODULE_DEPS_MAKEFILE) 231 232# Param 1: Module to find deps for 233FindDepsForModule = \ 234 $(DEPS_$(strip $1)) 235 236# Finds transitive dependencies in 3 levels. 237# Param 1: Module to find transitive deps for 238FindTransitiveDepsForModule = \ 239 $(sort $(call FindDepsForModule, $1) \ 240 $(foreach m, $(call FindDepsForModule, $1), \ 241 $(call FindDepsForModule, $m) \ 242 $(foreach n, $(call FindDepsForModule, $m), \ 243 $(call FindDepsForModule, $n)))) 244 245################################################################################ 246 247# Param 1 - Name of module 248define ReadSingleImportMetaData 249 ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), ) 250 classloader := 251 include_in_jre := 252 include_in_jdk := 253 include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties 254 ifeq ($$(include_in_jre), true) 255 JRE_MODULES += $1 256 endif 257 ifeq ($$(include_in_jdk), true) 258 JDK_MODULES += $1 259 endif 260 ifeq ($$(classloader), boot) 261 BOOT_MODULES += $1 262 else ifeq ($$(classloader), ext) 263 PLATFORM_MODULES += $1 264 endif 265 else 266 # Default to include in all 267 JRE_MODULES += $1 268 JDK_MODULES += $1 269 endif 270endef 271 272# Reading the imported modules metadata has a cost, so to make it available, 273# a makefile needs to eval-call this macro first. After calling this, the 274# following variables are populated with data from the imported modules: 275# * JRE_MODULES 276# * JDK_MODULES 277# * BOOT_MODULES 278# * PLATFORM_MODULES 279# * JRE_TOOL_MODULES 280define ReadImportMetaData 281 IMPORTED_MODULES := $$(call FindImportedModules) 282 $$(foreach m, $$(IMPORTED_MODULES), \ 283 $$(eval $$(call ReadSingleImportMetaData, $$m))) 284endef 285 286################################################################################ 287 288endif # _MODULES_GMK 289