Skip to content

8361142: Improve custom hooks for makefiles #26060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/CompileJavaModules.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion make/CreateJmods.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions make/Images.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion make/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion make/MainSupport.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 11 additions & 6 deletions make/ModuleWrapper.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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

THIS_SNIPPET := $(call GetModuleSnippetName, $(MAKEFILE_PREFIX))

include MakeSnippetStart.gmk
ifneq ($(wildcard $(THIS_SNIPPET)), )
include MakeSnippetStart.gmk

# Include the file being wrapped.
include $(THIS_SNIPPET)
# Include the file being wrapped.
include $(THIS_SNIPPET)

include MakeSnippetEnd.gmk
include MakeSnippetEnd.gmk
endif

ifeq ($(MAKEFILE_PREFIX), Lib)
# We need to keep track of what libraries are generated/needed by this
Expand Down
6 changes: 5 additions & 1 deletion make/common/JavaCompilation.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions make/common/Modules.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)))

################################################################################

Expand Down Expand Up @@ -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
Expand Down