make/common/Modules.gmk
changeset 36506 17612cee3530
parent 35030 916c91ff2589
child 36543 a8ce27ddc757
equal deleted inserted replaced
36505:17460b0304f4 36506:17612cee3530
    24 #
    24 #
    25 
    25 
    26 ifndef _MODULES_GMK
    26 ifndef _MODULES_GMK
    27 _MODULES_GMK := 1
    27 _MODULES_GMK := 1
    28 
    28 
       
    29 # Hook to include the corresponding custom file, if present.
       
    30 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
       
    31 
    29 ################################################################################
    32 ################################################################################
    30 # Some platforms don't have the serviceability agent
    33 # Some platforms don't have the serviceability agent
    31 ifeq ($(INCLUDE_SA), false)
    34 ifeq ($(INCLUDE_SA), false)
    32   MODULES_FILTER += jdk.hotspot.agent
    35   MODULES_FILTER += jdk.hotspot.agent
    33 endif
    36 endif
    34 
    37 
    35 ################################################################################
    38 ################################################################################
    36 # Module list macros
    39 # Module list macros
    37 
    40 
    38 ALL_TOP_SRC_DIRS := \
    41 # Use append so that the custom extension may add to this variable
       
    42 
       
    43 ALL_TOP_SRC_DIRS += \
    39     $(HOTSPOT_TOPDIR)/src \
    44     $(HOTSPOT_TOPDIR)/src \
    40     $(JDK_TOPDIR)/src \
    45     $(JDK_TOPDIR)/src \
    41     $(LANGTOOLS_TOPDIR)/src \
    46     $(LANGTOOLS_TOPDIR)/src \
    42     $(CORBA_TOPDIR)/src \
    47     $(CORBA_TOPDIR)/src \
    43     $(JAXP_TOPDIR)/src \
    48     $(JAXP_TOPDIR)/src \
    44     $(JAXWS_TOPDIR)/src \
    49     $(JAXWS_TOPDIR)/src \
    45     $(NASHORN_TOPDIR)/src \
    50     $(NASHORN_TOPDIR)/src \
    46     #
    51     #
    47 
    52 
    48 # Find all modules with java sources by looking in the source dirs
    53 # Find all module-info.java files for the current build target platform and
    49 define FindJavaModules
    54 # configuration.
    50   $(filter-out $(MODULES_FILTER), $(sort $(notdir \
    55 # Param 1 - Module to find for, set to * for finding all
    51       $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir \
    56 FindAllModuleInfos = \
    52       $(wildcard $(patsubst %,%/*/share/classes/*, $(ALL_TOP_SRC_DIRS)) \
    57     $(wildcard \
    53           $(patsubst %,%/*/$(OPENJDK_TARGET_OS)/classes/*, $(ALL_TOP_SRC_DIRS)) \
    58         $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
    54           $(patsubst %,%/*/$(OPENJDK_TARGET_OS_TYPE)/classes/*, $(ALL_TOP_SRC_DIRS))))))))))))
    59         $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
    55 endef
    60         $(patsubst %,%/$(strip $1)/share/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
       
    61         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
    56 
    62 
    57 # Find all modules with source for the target platform.
    63 # Extract the module names from the paths of module-info.java files. The
    58 define FindAllModules
    64 # position of the module directory differs depending on if this is an imported
    59   $(sort $(filter-out $(MODULES_FILTER) closed demo sample, \
    65 # src dir or not.
    60       $(notdir $(patsubst %/,%, $(dir \
    66 GetModuleNameFromModuleInfo = \
    61       $(wildcard $(patsubst %, %/*/share, $(ALL_TOP_SRC_DIRS)) \
    67     $(strip $(foreach mi, $1, \
    62       $(patsubst %, %/*/$(OPENJDK_TARGET_OS), $(ALL_TOP_SRC_DIRS)) \
    68       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
    63       $(patsubst %, %/*/$(OPENJDK_TARGET_OS_TYPE), $(ALL_TOP_SRC_DIRS))))))))
    69         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
    64 endef
    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.
       
    74 FindAllModules = \
       
    75     $(sort $(filter-out $(MODULES_FILTER), \
       
    76     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
       
    77 
       
    78 FindImportedModules = \
       
    79     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))
    65 
    80 
    66 ################################################################################
    81 ################################################################################
    67 # The module deps makefile is generated in make/GenerateModuleDeps.gmk
    82 # Extract module dependencies from module-info.java files.
       
    83 
    68 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
    84 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
       
    85 
       
    86 MODULE_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 
    69 -include $(MODULE_DEPS_MAKEFILE)
   106 -include $(MODULE_DEPS_MAKEFILE)
    70 
   107 
    71 # Param 1: Module to find deps for
   108 # Param 1: Module to find deps for
    72 define FindDepsForModule
   109 FindDepsForModule = \
    73   $(DEPS_$(strip $1))
   110   $(DEPS_$(strip $1))
    74 endef
   111 
       
   112 # Finds transitive dependencies in 3 levels.
       
   113 # Param 1: Module to find transitive deps for
       
   114 FindTransitiveDepsForModule = \
       
   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))))
    75 
   120 
    76 ################################################################################
   121 ################################################################################
    77 
   122 
    78 # Hook to include the corresponding custom file, if present.
       
    79 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
       
    80 
       
    81 endif # _MODULES_GMK
   123 endif # _MODULES_GMK