8329289: Unify SetupJdkExecutable and SetupJdkLibrary
Reviewed-by: erikj
This commit is contained in:
parent
5ae849d66f
commit
5ac067f6d6
@ -35,12 +35,6 @@ include NativeCompilation.gmk
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
$(eval $(call IncludeCustomExtension, common/JdkNativeCompilation.gmk))
|
||||
|
||||
FindSrcDirsForLib += \
|
||||
$(call uniq, $(wildcard \
|
||||
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \
|
||||
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \
|
||||
$(TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2)))
|
||||
|
||||
FindSrcDirsForComponent += \
|
||||
$(call uniq, $(wildcard \
|
||||
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/$(strip $2) \
|
||||
@ -104,14 +98,17 @@ JDK_RCFLAGS=$(RCFLAGS) \
|
||||
-D"JDK_NAME=$(JDK_RC_NAME) $(VERSION_SHORT)" \
|
||||
-D"JDK_FVER=$(subst .,$(COMMA),$(VERSION_NUMBER_FOUR_POSITIONS))"
|
||||
|
||||
# Setup make rules for creating a native shared library with suitable defaults
|
||||
# for the OpenJDK project.
|
||||
# Setup make rules for creating a native binary with suitable defaults
|
||||
# for the OpenJDK project. This macro is mostly considered to be an internal
|
||||
# support version. Please use SetupJdkLibrary or SetupJdkExecutable instead.
|
||||
#
|
||||
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
||||
# and the targets generated are listed in a variable by that name.
|
||||
#
|
||||
# Remaining parameters are named arguments. These are all passed on to
|
||||
# SetupNativeCompilation, except for
|
||||
# SetupNativeCompilation. This macro also adds the following additional
|
||||
# arguments:
|
||||
#
|
||||
# EXTRA_RCFLAGS -- additional RCFLAGS to append.
|
||||
# EXTRA_HEADER_DIRS -- additional directories to look for headers in
|
||||
# EXTRA_SRC -- additional directories to look for source in
|
||||
@ -122,14 +119,37 @@ JDK_RCFLAGS=$(RCFLAGS) \
|
||||
# SRC -- this is passed on, but preprocessed to accept source dir designations
|
||||
# RC_FILEDESC -- override the default FILEDESC for Windows version.rc
|
||||
# such as "java.base:headers".
|
||||
SetupJdkLibrary = $(NamedParamsMacroTemplate)
|
||||
define SetupJdkLibraryBody
|
||||
# JDK_LIBS -- libraries generated by the JDK build system to link against
|
||||
# JDK_LIBS_<os> or JDK_LIBS_<osType> -- additional JDK_LIBS for the given OS
|
||||
# or OS type only
|
||||
# DEFAULT_CFLAGS -- if false, do not add default CFLAGS and CXXFLAGS
|
||||
# CFLAGS_FILTER_OUT -- flags to filter out from default CFLAGS
|
||||
# CXXFLAGS_FILTER_OUT -- flags to filter out from default CXXFLAGS
|
||||
# LDFLAGS_FILTER_OUT -- flags to filter out from default LDFLAGS
|
||||
# LD_SET_ORIGIN -- if false, do not add SET_*_ORIGIN flags to LDFLAGS
|
||||
# APPEND_LDFLAGS -- a quirk to have additional LDFLAGS that will be set after
|
||||
# the origin flags
|
||||
#
|
||||
SetupJdkNativeCompilation = $(NamedParamsMacroTemplate)
|
||||
define SetupJdkNativeCompilationBody
|
||||
ifeq ($$($1_TYPE), EXECUTABLE)
|
||||
$1_NATIVE_DIR_PREFIX :=
|
||||
$1_MODULES_PATH := modules_cmds
|
||||
$1_RC_EXT := exe
|
||||
$1_RC_FTYPE := 0x1L
|
||||
else
|
||||
$1_NATIVE_DIR_PREFIX := lib
|
||||
$1_MODULES_PATH := modules_libs
|
||||
$1_RC_EXT := dll
|
||||
$1_RC_FTYPE := 0x2L
|
||||
endif
|
||||
|
||||
ifeq ($$($1_OUTPUT_DIR), )
|
||||
ifneq ($$(MODULE), )
|
||||
ifeq ($$($1_TYPE), STATIC_LIBRARY)
|
||||
$1_OUTPUT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)
|
||||
else
|
||||
$1_OUTPUT_DIR := $$(call FindLibDirForModule, $$(MODULE))
|
||||
$1_OUTPUT_DIR := $$(SUPPORT_OUTPUTDIR)/$$($1_MODULES_PATH)/$$(strip $$(MODULE))
|
||||
endif
|
||||
else
|
||||
$$(error Must specify OUTPUT_DIR in a MODULE free context)
|
||||
@ -138,7 +158,7 @@ define SetupJdkLibraryBody
|
||||
|
||||
ifeq ($$($1_OBJECT_DIR), )
|
||||
ifneq ($$(MODULE), )
|
||||
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/lib$$($1_NAME)
|
||||
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NATIVE_DIR_PREFIX)$$($1_NAME)
|
||||
else
|
||||
$$(error Must specify OBJECT_DIR in a MODULE free context)
|
||||
endif
|
||||
@ -150,7 +170,7 @@ define SetupJdkLibraryBody
|
||||
|
||||
ifeq ($$($1_SRC), )
|
||||
ifneq ($$(MODULE), )
|
||||
$1_SRC := $$(call FindSrcDirsForLib, $$(MODULE), $$($1_NAME))
|
||||
$1_SRC := $$(call FindSrcDirsForComponent, $$(MODULE), $$($1_NATIVE_DIR_PREFIX)$$($1_NAME))
|
||||
else
|
||||
$$(error Must specify SRC in a MODULE free context)
|
||||
endif
|
||||
@ -175,12 +195,11 @@ define SetupJdkLibraryBody
|
||||
ifeq ($$($1_RC_FILEDESC), )
|
||||
$1_RC_FILEDESC := $(JDK_RC_NAME) binary
|
||||
endif
|
||||
|
||||
$1_RCFLAGS := $(JDK_RCFLAGS) \
|
||||
-D"JDK_FILEDESC=$$(strip $$($1_RC_FILEDESC))" \
|
||||
-D"JDK_FNAME=$$($1_NAME).dll" \
|
||||
-D"JDK_FILEDESC=$$($1_RC_FILEDESC)" \
|
||||
-D"JDK_FNAME=$$($1_NAME).$$($1_RC_EXT)" \
|
||||
-D"JDK_INTERNAL_NAME=$$($1_NAME)" \
|
||||
-D"JDK_FTYPE=0x2L" \
|
||||
-D"JDK_FTYPE=$$($1_RC_FTYPE)" \
|
||||
-I$(TOPDIR)/src/java.base/windows/native/common \
|
||||
$$($1_EXTRA_RCFLAGS)
|
||||
|
||||
@ -203,11 +222,19 @@ define SetupJdkLibraryBody
|
||||
endif
|
||||
|
||||
ifneq ($$($1_DEFAULT_CFLAGS), false)
|
||||
# Set the default flags first to be able to override
|
||||
$1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKLIB)) $$($1_CFLAGS)
|
||||
ifeq ($$($1_TYPE), EXECUTABLE)
|
||||
# Set the default flags first to be able to override
|
||||
$1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKEXE)) $$($1_CFLAGS)
|
||||
|
||||
# Set the default flags first to be able to override
|
||||
$1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKLIB)) $$($1_CXXFLAGS)
|
||||
# Set the default flags first to be able to override
|
||||
$1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKEXE)) $$($1_CXXFLAGS)
|
||||
else
|
||||
# Set the default flags first to be able to override
|
||||
$1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKLIB)) $$($1_CFLAGS)
|
||||
|
||||
# Set the default flags first to be able to override
|
||||
$1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKLIB)) $$($1_CXXFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($$($1_CFLAGS), )
|
||||
@ -221,12 +248,21 @@ define SetupJdkLibraryBody
|
||||
endif
|
||||
|
||||
ifneq ($$($1_DEFAULT_LDFLAGS), false)
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB)) $$($1_LDFLAGS)
|
||||
ifeq ($$($1_TYPE), EXECUTABLE)
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE)) $$($1_LDFLAGS)
|
||||
else
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB)) $$($1_LDFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($$($1_LD_SET_ORIGIN), false)
|
||||
$1_LDFLAGS += $$(call SET_SHARED_LIBRARY_ORIGIN)
|
||||
ifeq ($$($1_TYPE), EXECUTABLE)
|
||||
$1_LDFLAGS += $$(call SET_EXECUTABLE_ORIGIN)
|
||||
else
|
||||
$1_LDFLAGS += $$(call SET_SHARED_LIBRARY_ORIGIN)
|
||||
endif
|
||||
endif
|
||||
# APPEND_LDFLAGS, if it exists, must be set after the origin flags
|
||||
# This is a workaround to keep existing behavior
|
||||
@ -234,112 +270,45 @@ define SetupJdkLibraryBody
|
||||
|
||||
# Since we reuse the rule name ($1), all our arguments will pass through.
|
||||
# We lose in transparency, but gain in brevity in this call...
|
||||
$$(eval $$(call SetupNativeCompilation, $1, ))
|
||||
$$(eval $$(call SetupNativeCompilation, $1))
|
||||
endef
|
||||
|
||||
# Setup make rules for creating a native executable with suitable defaults for
|
||||
# the OpenJDK project.
|
||||
# Setup make rules for creating a native library with suitable defaults
|
||||
# for the OpenJDK project. The default is to create a shared library,
|
||||
# but by passing TYPE := STATIC_LIBARY, a static library can be created.
|
||||
#
|
||||
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
||||
# and the targets generated are listed in a variable by that name.
|
||||
#
|
||||
# Remaining parameters are named arguments. These are all passed on to
|
||||
# SetupNativeCompilation, except for
|
||||
# EXTRA_RCFLAGS -- additional RCFLAGS to append.
|
||||
SetupJdkExecutable = $(NamedParamsMacroTemplate)
|
||||
define SetupJdkExecutableBody
|
||||
$1_TYPE := EXECUTABLE
|
||||
|
||||
ifeq ($$($1_OUTPUT_DIR), )
|
||||
ifneq ($$(MODULE), )
|
||||
$1_OUTPUT_DIR := $$(call FindExecutableDirForModule, $$(MODULE))
|
||||
else
|
||||
$$(error Must specify OUTPUT_DIR in a MODULE free context)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$($1_OBJECT_DIR), )
|
||||
ifneq ($$(MODULE), )
|
||||
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NAME)
|
||||
else
|
||||
$$(error Must specify OBJECT_DIR in a MODULE free context)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$($1_LINK_TYPE), C++)
|
||||
$1_LIBS += $(LIBCXX)
|
||||
endif
|
||||
|
||||
ifeq ($$($1_SRC), )
|
||||
ifneq ($$(MODULE), )
|
||||
$1_SRC := $$(call FindSrcDirsForComponent, $$(MODULE), $$($1_NAME))
|
||||
else
|
||||
$$(error Must specify SRC in a MODULE free context)
|
||||
endif
|
||||
else
|
||||
$1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessDir, $$(dir)))
|
||||
endif
|
||||
ifneq ($$($1_EXTRA_SRC), )
|
||||
$1_SRC += $$(foreach dir, $$($1_EXTRA_SRC), $$(call ProcessDir, $$(dir)))
|
||||
endif
|
||||
|
||||
ifeq ($$($1_VERSIONINFO_RESOURCE), )
|
||||
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
|
||||
endif
|
||||
|
||||
$1_RCFLAGS := $(JDK_RCFLAGS) \
|
||||
-D"JDK_FILEDESC=$(JDK_RC_NAME) binary" \
|
||||
-D"JDK_FNAME=$$($1_NAME).exe" \
|
||||
-D"JDK_INTERNAL_NAME=$$($1_NAME)" \
|
||||
-D"JDK_FTYPE=0x1L" \
|
||||
-I$(TOPDIR)/src/java.base/windows/native/common \
|
||||
$$($1_EXTRA_RCFLAGS)
|
||||
|
||||
ifneq ($$($1_HEADERS_FROM_SRC), false)
|
||||
$1_SRC_HEADER_FLAGS := $$(addprefix -I, $$(wildcard $$($1_SRC)))
|
||||
endif
|
||||
|
||||
$1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS))
|
||||
$1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS_TYPE))
|
||||
# Prepend JDK libs before external libs
|
||||
$1_LIBS := $$($1_JDK_LIBS) $$($1_LIBS)
|
||||
|
||||
ifneq ($$($1_EXTRA_HEADER_DIRS), )
|
||||
$1_PROCESSED_EXTRA_HEADER_DIRS := $$(foreach dir, $$($1_EXTRA_HEADER_DIRS), \
|
||||
$$(call ProcessDir, $$(dir)))
|
||||
$1_EXTRA_HEADER_FLAGS := $$(addprefix -I, $$($1_PROCESSED_EXTRA_HEADER_DIRS))
|
||||
endif
|
||||
|
||||
ifneq ($$($1_DEFAULT_CFLAGS), false)
|
||||
# Set the default flags first to be able to override
|
||||
$1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKEXE)) $$($1_CFLAGS)
|
||||
|
||||
# Set the default flags first to be able to override
|
||||
$1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKEXE)) $$($1_CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifneq ($$($1_CFLAGS), )
|
||||
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
|
||||
endif
|
||||
ifneq ($$($1_CXXFLAGS), )
|
||||
$1_CXXFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
|
||||
endif
|
||||
ifeq ($$($1_CFLAGS)$$($1_CXXFLAGS), )
|
||||
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
|
||||
endif
|
||||
|
||||
ifneq ($$($1_DEFAULT_LDFLAGS), false)
|
||||
# Set the default flags first to be able to override
|
||||
$1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE)) $$($1_LDFLAGS)
|
||||
endif
|
||||
|
||||
ifneq ($$($1_LD_SET_ORIGIN), false)
|
||||
$1_LDFLAGS += $$(call SET_EXECUTABLE_ORIGIN)
|
||||
# SetupJdkNativeCompilation. Please see that macro for details.
|
||||
SetupJdkLibrary = $(NamedParamsMacroTemplate)
|
||||
define SetupJdkLibraryBody
|
||||
# If type is unspecified, default to LIBRARY
|
||||
ifeq ($$($1_TYPE), )
|
||||
$1_TYPE := LIBRARY
|
||||
endif
|
||||
|
||||
# Since we reuse the rule name ($1), all our arguments will pass through.
|
||||
# We lose in transparency, but gain in brevity in this call...
|
||||
$$(eval $$(call SetupNativeCompilation, $1))
|
||||
$$(eval $$(call SetupJdkNativeCompilation, $1))
|
||||
endef
|
||||
|
||||
# Setup make rules for creating a native executable with suitable defaults
|
||||
# for the OpenJDK project.
|
||||
#
|
||||
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
||||
# and the targets generated are listed in a variable by that name.
|
||||
#
|
||||
# Remaining parameters are named arguments. These are all passed on to
|
||||
# SetupJdkNativeCompilation. Please see that macro for details.
|
||||
SetupJdkExecutable = $(NamedParamsMacroTemplate)
|
||||
define SetupJdkExecutableBody
|
||||
$1_TYPE := EXECUTABLE
|
||||
|
||||
# Since we reuse the rule name ($1), all our arguments will pass through.
|
||||
# We lose in transparency, but gain in brevity in this call...
|
||||
$$(eval $$(call SetupJdkNativeCompilation, $1))
|
||||
endef
|
||||
|
||||
endif # _JDK_NATIVE_COMPILATION_GMK
|
||||
|
Loading…
Reference in New Issue
Block a user