Modules.gmk revision 1961:f900d5afd9c8
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# Hook to include the corresponding custom file, if present. 30$(eval $(call IncludeCustomExtension, , common/Modules.gmk)) 31 32################################################################################ 33# Some platforms don't have the serviceability agent 34ifeq ($(INCLUDE_SA), false) 35 MODULES_FILTER += jdk.hotspot.agent 36endif 37 38################################################################################ 39# Module list macros 40 41# Use append so that the custom extension may add to this variable 42 43ALL_TOP_SRC_DIRS += \ 44 $(HOTSPOT_TOPDIR)/src \ 45 $(JDK_TOPDIR)/src \ 46 $(LANGTOOLS_TOPDIR)/src \ 47 $(CORBA_TOPDIR)/src \ 48 $(JAXP_TOPDIR)/src \ 49 $(JAXWS_TOPDIR)/src \ 50 $(NASHORN_TOPDIR)/src \ 51 # 52 53# Find all module-info.java files for the current build target platform and 54# configuration. 55# Param 1 - Module to find for, set to * for finding all 56FindAllModuleInfos = \ 57 $(wildcard \ 58 $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \ 59 $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \ 60 $(patsubst %,%/$(strip $1)/share/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \ 61 $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) 62 63# Extract the module names from the paths of module-info.java files. The 64# position of the module directory differs depending on if this is an imported 65# src dir or not. 66GetModuleNameFromModuleInfo = \ 67 $(strip $(foreach mi, $1, \ 68 $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \ 69 $(notdir $(patsubst %/,%, $(dir $(mi)))), \ 70 $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi))))))))))) 71 72# Find all modules by looking for module-info.java files and looking at parent 73# directories. 74FindAllModules = \ 75 $(sort $(filter-out $(MODULES_FILTER), \ 76 $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) 77 78FindImportedModules = \ 79 $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))) 80 81################################################################################ 82# Extract module dependencies from module-info.java files. 83 84MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk 85 86MODULE_INFOS := $(call FindAllModuleInfos, *) 87 88$(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ 89 $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps) 90 $(MKDIR) -p $(@D) 91 $(RM) $@ 92 $(foreach m, $(MODULE_INFOS), \ 93 ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \ 94 $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\ 95 BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ 96 /requires/ { sub(/;/, ""); \ 97 sub(/requires/, ""); \ 98 sub(/public/, ""); \ 99 sub(/\/\/.*/, ""); \ 100 sub(/\/\*.*\*\//, ""); \ 101 gsub(/ /, ""); \ 102 printf(" %s", $$0) } \ 103 END { printf("\n") }' $m \ 104 ) >> $@ $(NEWLINE)) 105 106-include $(MODULE_DEPS_MAKEFILE) 107 108# Param 1: Module to find deps for 109FindDepsForModule = \ 110 $(DEPS_$(strip $1)) 111 112# Finds transitive dependencies in 3 levels. 113# Param 1: Module to find transitive deps for 114FindTransitiveDepsForModule = \ 115 $(sort $(call FindDepsForModule, $1) \ 116 $(foreach m, $(call FindDepsForModule, $1), \ 117 $(call FindDepsForModule, $m) \ 118 $(foreach n, $(call FindDepsForModule, $m), \ 119 $(call FindDepsForModule, $n)))) 120 121################################################################################ 122 123endif # _MODULES_GMK 124