8361142: Improve custom hooks for makefiles

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2025-08-11 09:44:49 +00:00
parent 0c39228ec1
commit 1fc0b01601
8 changed files with 38 additions and 14 deletions

View file

@ -85,7 +85,7 @@ CreateHkTargets = \
################################################################################
# Include module specific build settings
THIS_SNIPPET := modules/$(MODULE)/Java.gmk
THIS_SNIPPET := $(call GetModuleSnippetName, Java)
ifneq ($(wildcard $(THIS_SNIPPET)), )
include MakeSnippetStart.gmk

View file

@ -184,7 +184,7 @@ endif
################################################################################
# Include module specific build settings
THIS_SNIPPET := modules/$(MODULE)/Jmod.gmk
THIS_SNIPPET := $(call GetModuleSnippetName, Jmod)
ifneq ($(wildcard $(THIS_SNIPPET)), )
include MakeSnippetStart.gmk

View file

@ -270,6 +270,7 @@ endif
# Since debug symbols are not included in the jmod files, they need to be copied
# in manually after generating the images.
# These variables are read by SetupCopyDebuginfo
ALL_JDK_MODULES := $(JDK_MODULES)
ALL_JRE_MODULES := $(sort $(JRE_MODULES), $(foreach m, $(JRE_MODULES), \
$(call FindTransitiveDepsForModule, $m)))

View file

@ -1407,7 +1407,7 @@ CLEAN_SUPPORT_DIRS += demos
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
CLEAN_PHASES := gensrc java native include
CLEAN_PHASES += gensrc java native include
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
# Construct targets of the form clean-$module-$phase

View file

@ -149,7 +149,7 @@ endef
################################################################################
PHASE_MAKEDIRS := $(TOPDIR)/make
PHASE_MAKEDIRS += $(TOPDIR)/make
# Helper macro for DeclareRecipesForPhase
# Declare a recipe for calling the module and phase specific makefile.

View file

@ -34,18 +34,23 @@ include MakeFileStart.gmk
################################################################################
include CopyFiles.gmk
include Modules.gmk
MODULE_SRC := $(TOPDIR)/src/$(MODULE)
# Define the snippet for MakeSnippetStart/End
THIS_SNIPPET := modules/$(MODULE)/$(MAKEFILE_PREFIX).gmk
################################################################################
# Include module specific build settings
include MakeSnippetStart.gmk
THIS_SNIPPET := $(call GetModuleSnippetName, $(MAKEFILE_PREFIX))
# Include the file being wrapped.
include $(THIS_SNIPPET)
ifneq ($(wildcard $(THIS_SNIPPET)), )
include MakeSnippetStart.gmk
include MakeSnippetEnd.gmk
# Include the file being wrapped.
include $(THIS_SNIPPET)
include MakeSnippetEnd.gmk
endif
ifeq ($(MAKEFILE_PREFIX), Lib)
# We need to keep track of what libraries are generated/needed by this

View file

@ -178,6 +178,10 @@ define SetupJavaCompilationBody
$1_SAFE_NAME := $$(strip $$(subst /,_, $1))
ifeq ($$($1_LOG_ACTION), )
$1_LOG_ACTION := Compiling
endif
ifeq ($$($1_SMALL_JAVA), )
# If unspecified, default to true
$1_SMALL_JAVA := true
@ -472,7 +476,7 @@ define SetupJavaCompilationBody
# list of files.
$$($1_FILELIST): $$($1_SRCS) $$($1_VARDEPS_FILE)
$$(call MakeDir, $$(@D))
$$(call LogWarn, Compiling up to $$(words $$($1_SRCS)) files for $1)
$$(call LogWarn, $$($1_LOG_ACTION) up to $$(words $$($1_SRCS)) files for $1)
$$(eval $$(call ListPathsSafely, $1_SRCS, $$($1_FILELIST)))
# Create a $$($1_MODFILELIST) file with significant modified dependencies

View file

@ -33,7 +33,7 @@ include $(TOPDIR)/make/conf/module-loader-map.conf
# Append platform-specific and upgradeable modules
PLATFORM_MODULES += $(PLATFORM_MODULES_$(OPENJDK_TARGET_OS)) \
$(UPGRADEABLE_PLATFORM_MODULES)
$(UPGRADEABLE_PLATFORM_MODULES) $(CUSTOM_UPGRADEABLE_PLATFORM_MODULES)
################################################################################
# Setup module sets for docs
@ -216,7 +216,7 @@ endif
# Find dependencies ("requires") for a given module.
# Param 1: Module to find dependencies for.
FindDepsForModule = \
$(DEPS_$(strip $1))
$(filter-out $(IMPORT_MODULES), $(DEPS_$(strip $1)))
# Find dependencies ("requires") transitively in 3 levels for a given module.
# Param 1: Module to find dependencies for.
@ -254,7 +254,8 @@ FindTransitiveIndirectDepsForModules = \
# Upgradeable modules are those that are either defined as upgradeable or that
# require an upradeable module.
FindAllUpgradeableModules = \
$(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_PLATFORM_MODULES)))
$(sort $(filter-out $(MODULES_FILTER), \
$(UPGRADEABLE_PLATFORM_MODULES) $(CUSTOM_UPGRADEABLE_PLATFORM_MODULES)))
################################################################################
@ -316,6 +317,19 @@ define ReadImportMetaData
$$(eval $$(call ReadSingleImportMetaData, $$m)))
endef
################################################################################
# Get a full snippet path for the current module and a given base name.
#
# Param 1 - The base name of the snippet file to include
GetModuleSnippetName = \
$(if $(CUSTOM_MODULE_MAKE_ROOT), \
$(if $(wildcard $(CUSTOM_MODULE_MAKE_ROOT)/$(MODULE)/$(strip $1).gmk), \
$(CUSTOM_MODULE_MAKE_ROOT)/$(MODULE)/$(strip $1).gmk, \
$(wildcard modules/$(MODULE)/$(strip $1).gmk) \
), \
$(wildcard modules/$(MODULE)/$(strip $1).gmk) \
)
################################################################################
endif # include guard