8326947: Minimize MakeBase.gmk
Reviewed-by: erikj
This commit is contained in:
Родитель
2e3682a7f2
Коммит
16061874ff
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -28,6 +28,9 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include MakeIO.gmk
|
||||
|
||||
PRODUCT_TARGETS :=
|
||||
LEGACY_TARGETS :=
|
||||
TEST_TARGETS :=
|
||||
|
|
|
@ -31,6 +31,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
include TextFileProcessing.gmk
|
||||
include ZipArchive.gmk
|
||||
|
|
|
@ -28,6 +28,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
include Modules.gmk
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
include TextFileProcessing.gmk
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
LIBS_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_LIBS)))
|
||||
CMDS_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CMDS)))
|
||||
CONF_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CONF)))
|
||||
|
|
|
@ -28,6 +28,8 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
##########################################################################################
|
||||
|
||||
### TZDB tool needs files from java.time.zone package
|
||||
|
|
|
@ -27,6 +27,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include Execute.gmk
|
||||
include Modules.gmk
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include Execute.gmk
|
||||
include Modules.gmk
|
||||
include ModuleTools.gmk
|
||||
|
|
|
@ -31,6 +31,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -31,6 +31,8 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
################################################################################
|
||||
|
||||
TARGETS :=
|
||||
|
|
|
@ -27,6 +27,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include Execute.gmk
|
||||
include Modules.gmk
|
||||
include Utils.gmk
|
||||
|
|
|
@ -536,6 +536,31 @@ else # $(HAS_SPEC)=true
|
|||
endef
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
# Functions for timers
|
||||
##############################################################################
|
||||
|
||||
# Store the build times in this directory.
|
||||
BUILDTIMESDIR=$(OUTPUTDIR)/make-support/build-times
|
||||
|
||||
# Record starting time for build of a sub repository.
|
||||
define RecordStartTime
|
||||
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) && \
|
||||
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
|
||||
endef
|
||||
|
||||
# Record ending time and calculate the difference and store it in a
|
||||
# easy to read format. Handles builds that cross midnight. Expects
|
||||
# that a build will never take 24 hours or more.
|
||||
define RecordEndTime
|
||||
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
|
||||
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
|
||||
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
|
||||
$(AWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
|
||||
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
|
||||
> $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
|
||||
endef
|
||||
|
||||
define StartGlobalTimer
|
||||
$(RM) -r $(BUILDTIMESDIR) 2> /dev/null && \
|
||||
$(MKDIR) -p $(BUILDTIMESDIR) && \
|
||||
|
|
|
@ -27,6 +27,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
include JarArchive.gmk
|
||||
include TextFileProcessing.gmk
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include TextFileProcessing.gmk
|
||||
|
||||
default: bundles
|
||||
|
|
|
@ -35,6 +35,8 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
MODULE_SRC := $(TOPDIR)/src/$(MODULE)
|
||||
|
||||
# All makefiles should add the targets to be built to this variable.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -41,6 +41,16 @@ $(eval $(call IncludeCustomExtension, SourceRevision-pre.gmk))
|
|||
|
||||
STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev
|
||||
|
||||
# Locate all sourcecode repositories included in the forest, as absolute paths
|
||||
FindAllReposAbs = \
|
||||
$(strip $(sort $(dir $(filter-out $(TOPDIR)/build/%, $(wildcard \
|
||||
$(addprefix $(TOPDIR)/, .git */.git */*/.git */*/*/.git */*/*/*/.git) \
|
||||
)))))
|
||||
|
||||
# Locate all sourcecode repositories included in the forest, as relative paths
|
||||
FindAllReposRel = \
|
||||
$(strip $(subst $(TOPDIR)/,.,$(patsubst $(TOPDIR)/%/, %, $(FindAllReposAbs))))
|
||||
|
||||
USE_SCM := false
|
||||
ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), )
|
||||
USE_SCM := true
|
||||
|
|
|
@ -30,6 +30,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include Modules.gmk
|
||||
|
||||
ALL_MODULES = $(call FindAllModules)
|
||||
|
|
|
@ -677,6 +677,10 @@ BUILD_JAR = @FIXPATH@ $(BUILD_JDK)/bin/jar
|
|||
|
||||
DOCS_REFERENCE_JAVADOC := @DOCS_REFERENCE_JAVADOC@
|
||||
|
||||
# A file containing a way to uniquely identify the source code revision that
|
||||
# the build was created from
|
||||
SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker
|
||||
|
||||
# Interim langtools modules and arguments
|
||||
INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
|
||||
INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
|
||||
|
|
|
@ -0,0 +1,303 @@
|
|||
#
|
||||
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
ifeq (,$(_MAKEBASE_GMK))
|
||||
$(error You must include MakeBase.gmk prior to including FileUtils.gmk)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Common file utility functions
|
||||
#
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
# Replace question marks with space in string. This macro needs to be called on
|
||||
# files from FindFiles in case any of them contains space in their file name,
|
||||
# since FindFiles replaces space with ?.
|
||||
# Param 1 - String to replace in
|
||||
DecodeSpace = \
|
||||
$(subst ?,$(SPACE),$(strip $1))
|
||||
|
||||
EncodeSpace = \
|
||||
$(subst $(SPACE),?,$(strip $1))
|
||||
|
||||
################################################################################
|
||||
# Take two paths and return the path of the last common directory.
|
||||
# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
|
||||
# foo/bar/baz, /foo/bar -> <empty>
|
||||
#
|
||||
# The x prefix is used to preserve the presence of the initial slash
|
||||
# On Windows paths are treated as case-insensitive
|
||||
#
|
||||
# $1 - Path to compare
|
||||
# $2 - Other path to compare
|
||||
FindCommonPathPrefix = \
|
||||
$(call DecodeSpace,$(patsubst x%,%,$(subst $(SPACE),/,$(strip \
|
||||
$(call FindCommonPathPrefixHelper1, \
|
||||
$(subst /,$(SPACE),x$(call EncodeSpace,$(strip $1))), \
|
||||
$(subst /,$(SPACE),x$(call EncodeSpace,$(strip $2)))) \
|
||||
))))
|
||||
|
||||
FindCommonPathPrefixHelper1 = \
|
||||
$(if $(filter $(OPENJDK_TARGET_OS), windows), \
|
||||
$(call FindCommonPathPrefixHelper2,$(call uppercase,$1),$(call uppercase,$2),$1), \
|
||||
$(call FindCommonPathPrefixHelper2,$1,$2,$1))
|
||||
|
||||
FindCommonPathPrefixHelper2 = \
|
||||
$(if $(call equals, $(firstword $1), $(firstword $2)), \
|
||||
$(if $(call equals, $(firstword $1),),, \
|
||||
$(firstword $3) \
|
||||
$(call FindCommonPathPrefixHelper2, \
|
||||
$(wordlist 2, $(words $1), $1), \
|
||||
$(wordlist 2, $(words $2), $2), \
|
||||
$(wordlist 2, $(words $3), $3) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Computes the relative path from a directory to a file
|
||||
# $1 - File to compute the relative path to
|
||||
# $2 - Directory to compute the relative path from
|
||||
RelativePath = \
|
||||
$(call DecodeSpace,$(strip $(call RelativePathHelper,$(call EncodeSpace \
|
||||
,$(strip $1)),$(call EncodeSpace \
|
||||
,$(strip $2)),$(call EncodeSpace \
|
||||
,$(call FindCommonPathPrefix,$1,$2)))))
|
||||
|
||||
RelativePathHelper = \
|
||||
$(eval $3_prefix_length := $(words $(subst /,$(SPACE),$3))) \
|
||||
$(eval $1_words := $(subst /,$(SPACE),$1)) \
|
||||
$(eval $2_words := $(subst /,$(SPACE),$2)) \
|
||||
$(if $(call equals,$($3_prefix_length),0),, \
|
||||
$(eval $1_words := $(wordlist 2,$(words $($1_words)),$(wordlist \
|
||||
$($3_prefix_length),$(words $($1_words)),$($1_words)))) \
|
||||
$(eval $2_words := $(wordlist 2,$(words $($2_words)),$(wordlist \
|
||||
$($3_prefix_length),$(words $($2_words)),$($2_words)))) \
|
||||
) \
|
||||
$(eval $1_suffix := $(subst $(SPACE),/,$($1_words))) \
|
||||
$(eval $2_dotdots := $(subst $(SPACE),/,$(foreach d,$($2_words),..))) \
|
||||
$(if $($1_suffix), \
|
||||
$(if $($2_dotdots), $($2_dotdots)/$($1_suffix), $($1_suffix)), \
|
||||
$(if $($2_dotdots), $($2_dotdots), .))
|
||||
|
||||
# Make directory for target file. Should handle spaces in filenames. Just
|
||||
# calling $(call MakeDir $(@D)) will not work if the directory contains a space
|
||||
# and the target file already exists. In that case, the target file will have
|
||||
# its wildcard ? resolved and the $(@D) will evaluate each space separated dir
|
||||
# part on its own.
|
||||
MakeTargetDir = \
|
||||
$(call MakeDir, $(dir $(call EncodeSpace, $@)))
|
||||
|
||||
################################################################################
|
||||
# All install-file and related macros automatically call DecodeSpace when needed.
|
||||
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
# On mac, extended attributes sometimes creep into the source files, which may later
|
||||
# cause the creation of ._* files which confuses testing. Clear these with xattr if
|
||||
# set. Some files get their write permissions removed after being copied to the
|
||||
# output dir. When these are copied again to images, xattr would fail. By only clearing
|
||||
# attributes when they are present, failing on this is avoided.
|
||||
#
|
||||
# If copying a soft link to a directory, need to delete the target first to avoid
|
||||
# weird errors.
|
||||
define install-file
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
# Work around a weirdness with cp on Macosx. When copying a symlink, if
|
||||
# the target of the link is write protected (e.g. 444), cp will add
|
||||
# write permission for the user on the target file (644). Avoid this by
|
||||
# using ln to create a new link instead.
|
||||
if [ -h '$(call DecodeSpace, $<)' ]; then \
|
||||
$(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \
|
||||
else \
|
||||
$(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
|
||||
fi
|
||||
if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then \
|
||||
$(XATTR) -cs '$(call DecodeSpace, $@)'; \
|
||||
fi
|
||||
endef
|
||||
else
|
||||
define install-file
|
||||
$(call MakeTargetDir)
|
||||
$(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
# Variant of install file that does not preserve symlinks
|
||||
define install-file-nolink
|
||||
$(call MakeTargetDir)
|
||||
$(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# link-file-* works similarly to install-file but creates a symlink instead.
|
||||
# There are two versions, either creating a relative or an absolute link. Be
|
||||
# careful when using this on Windows since the symlink created is only valid in
|
||||
# the unix emulation environment.
|
||||
# In msys2 we use mklink /J because its ln would perform a deep copy of the target.
|
||||
# This inhibits performance and can lead to issues with long paths. With mklink /J
|
||||
# relative linking does not work, so we handle the link as absolute path.
|
||||
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
|
||||
define link-file-relative
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
|
||||
endef
|
||||
else
|
||||
define link-file-relative
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
$(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
|
||||
define link-file-absolute
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
|
||||
endef
|
||||
else
|
||||
define link-file-absolute
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
$(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
# Recursive wildcard function. Walks down directories recursively and matches
|
||||
# files with the search patterns. Patterns use standard file wildcards (* and
|
||||
# ?).
|
||||
#
|
||||
# $1 - Directories to start search in
|
||||
# $2 - Search patterns
|
||||
rwildcard = \
|
||||
$(strip \
|
||||
$(foreach d, \
|
||||
$(patsubst %/,%,$(sort $(dir $(wildcard $(addsuffix /*/*, $(strip $1)))))), \
|
||||
$(call rwildcard,$d,$2) \
|
||||
) \
|
||||
$(call DoubleDollar, $(wildcard $(foreach p, $2, $(addsuffix /$(strip $p), $(strip $1))))) \
|
||||
)
|
||||
|
||||
# Find non directories using recursive wildcard function. This function may
|
||||
# be used directly when a small amount of directories is expected to be
|
||||
# searched and caching is not expected to be of use.
|
||||
#
|
||||
# $1 - Directory to start search in
|
||||
# $2 - Optional search patterns, defaults to '*'.
|
||||
WildcardFindFiles = \
|
||||
$(sort $(strip \
|
||||
$(eval WildcardFindFiles_result := $(call rwildcard,$(patsubst %/,%,$1),$(if $(strip $2),$2,*))) \
|
||||
$(filter-out $(patsubst %/,%,$(sort $(dir $(WildcardFindFiles_result)))), \
|
||||
$(WildcardFindFiles_result) \
|
||||
) \
|
||||
))
|
||||
|
||||
# Find non directories using the find utility in the shell. Safe to call for
|
||||
# non existing directories, or directories containing wildcards.
|
||||
#
|
||||
# Files containing space will get spaces replaced with ? because GNU Make
|
||||
# cannot handle lists of files with space in them. By using ?, make will match
|
||||
# the wildcard to space in many situations so we don't need to replace back
|
||||
# to space on every use. While not a complete solution it does allow some uses
|
||||
# of FindFiles to function with spaces in file names, including for
|
||||
# SetupCopyFiles. Unfortunately this does not work for WildcardFindFiles so
|
||||
# if files with spaces are anticipated, use ShellFindFiles directly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns, empty means find everything. Patterns use
|
||||
# standard file wildcards (* and ?) and should not be quoted.
|
||||
# $3 - Optional options to find.
|
||||
ShellFindFiles = \
|
||||
$(if $(wildcard $1), \
|
||||
$(sort \
|
||||
$(shell $(FIND) $3 $(patsubst %/,%,$(wildcard $1)) \( -type f -o -type l \) \
|
||||
$(if $(strip $2), -a \( -name "$(firstword $2)" \
|
||||
$(foreach p, $(filter-out $(firstword $2), $2), -o -name "$(p)") \)) \
|
||||
| $(TR) ' ' '?' \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Find non directories using the method most likely to work best for the
|
||||
# current build host
|
||||
#
|
||||
# $1 - Directory to start search in
|
||||
# $2 - Optional search patterns, defaults to '*'.
|
||||
ifeq ($(OPENJDK_BUILD_OS)-$(RWILDCARD_WORKS), windows-true)
|
||||
DirectFindFiles = $(WildcardFindFiles)
|
||||
else
|
||||
DirectFindFiles = $(ShellFindFiles)
|
||||
endif
|
||||
|
||||
# Finds files using a cache that is populated by FillFindCache below. If any of
|
||||
# the directories given have not been cached, DirectFindFiles is used for
|
||||
# everything. Caching is especially useful in Cygwin, where file finds are very
|
||||
# costly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns. If used, no caching is done.
|
||||
CacheFindFiles_CACHED_DIRS :=
|
||||
CacheFindFiles_CACHED_FILES :=
|
||||
CacheFindFiles = \
|
||||
$(if $2, \
|
||||
$(call DirectFindFiles, $1, $2) \
|
||||
, \
|
||||
$(if $(filter-out $(addsuffix /%, $(CacheFindFiles_CACHED_DIRS)) \
|
||||
$(CacheFindFiles_CACHED_DIRS), $1), \
|
||||
$(call DirectFindFiles, $1) \
|
||||
, \
|
||||
$(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(CacheFindFiles_CACHED_FILES)) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Explicitly adds files to the find cache used by CacheFindFiles.
|
||||
#
|
||||
# $1 - Directories to start search in
|
||||
FillFindCache = \
|
||||
$(eval CacheFindFiles_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
|
||||
$$(CacheFindFiles_CACHED_DIRS)) $$(CacheFindFiles_CACHED_DIRS), $1)) \
|
||||
$(if $(CacheFindFiles_NEW_DIRS), \
|
||||
$(eval CacheFindFiles_CACHED_DIRS += $$(patsubst %/,%,$$(CacheFindFiles_NEW_DIRS))) \
|
||||
$(eval CacheFindFiles_CACHED_FILES := $$(sort $$(CacheFindFiles_CACHED_FILES) \
|
||||
$$(call DirectFindFiles, $$(CacheFindFiles_NEW_DIRS)))) \
|
||||
)
|
||||
|
||||
# Findfiles is the default macro that should be used to find files in the file
|
||||
# system. This function does not always support files with spaces in the names.
|
||||
# If files with spaces are anticipated, use ShellFindFiles directly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns, empty means find everything. Patterns use
|
||||
# standard file wildcards (* and ?) and should not be quoted.
|
||||
ifeq ($(DISABLE_CACHE_FIND), true)
|
||||
FindFiles = $(DirectFindFiles)
|
||||
else
|
||||
FindFiles = $(CacheFindFiles)
|
||||
endif
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -30,6 +30,8 @@ ifeq (,$(_MAKEBASE_GMK))
|
|||
$(error You must include MakeBase.gmk prior to including JarArchive.gmk)
|
||||
endif
|
||||
|
||||
include MakeIO.gmk
|
||||
|
||||
FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST
|
||||
|
||||
# Setup make rules for creating a jar archive.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -30,6 +30,8 @@ ifeq (,$(_MAKEBASE_GMK))
|
|||
$(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
|
||||
endif
|
||||
|
||||
include MakeIO.gmk
|
||||
|
||||
# Java compilation needs SetupJarArchive and/or SetupZipArchive, if we're
|
||||
# generating a jar file or a source zip.
|
||||
include JarArchive.gmk
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
#
|
||||
|
||||
################################################################
|
||||
#
|
||||
# Setup common utility functions.
|
||||
#
|
||||
# MakeBase provides the core functionality needed and used by all makefiles. It
|
||||
# should be included by all makefiles. MakeBase provides essential
|
||||
# functionality for named parameter functions, variable dependency, tool
|
||||
# execution, logging and fixpath functionality.
|
||||
################################################################
|
||||
|
||||
ifndef _MAKEBASE_GMK
|
||||
|
@ -64,9 +65,6 @@ define NEWLINE
|
|||
|
||||
endef
|
||||
|
||||
# Make sure we have a value (could be overridden on command line by caller)
|
||||
CREATING_BUILDJDK ?= false
|
||||
|
||||
# Certain features only work in newer version of GNU Make. The build will still
|
||||
# function in 3.81, but will be less performant.
|
||||
ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
|
||||
|
@ -75,67 +73,16 @@ ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
|
|||
RWILDCARD_WORKS := true
|
||||
endif
|
||||
|
||||
|
||||
# For convenience, MakeBase.gmk continues to include these separate files, at
|
||||
# least for now.
|
||||
|
||||
# Utils.gmk must be included before FileUtils.gmk, since it uses some of the
|
||||
# basic utility functions there.
|
||||
include $(TOPDIR)/make/common/Utils.gmk
|
||||
include $(TOPDIR)/make/common/MakeIO.gmk
|
||||
include $(TOPDIR)/make/common/CopyFiles.gmk
|
||||
include $(TOPDIR)/make/common/FileUtils.gmk
|
||||
|
||||
################################################################################
|
||||
# Functions for timers
|
||||
################################################################################
|
||||
|
||||
# Store the build times in this directory.
|
||||
BUILDTIMESDIR=$(OUTPUTDIR)/make-support/build-times
|
||||
|
||||
# Record starting time for build of a sub repository.
|
||||
define RecordStartTime
|
||||
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) && \
|
||||
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
|
||||
endef
|
||||
|
||||
# Record ending time and calculate the difference and store it in a
|
||||
# easy to read format. Handles builds that cross midnight. Expects
|
||||
# that a build will never take 24 hours or more.
|
||||
define RecordEndTime
|
||||
$(DATE) '+%Y %m %d %H %M %S' | $(AWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
|
||||
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
|
||||
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \
|
||||
$(AWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \
|
||||
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \
|
||||
> $(BUILDTIMESDIR)/build_time_diff_$(strip $1)
|
||||
endef
|
||||
|
||||
# Hook to be called when starting to execute a top-level target
|
||||
define TargetEnter
|
||||
$(PRINTF) "## Starting $(patsubst %-only,%,$@)\n"
|
||||
$(call RecordStartTime,$(patsubst %-only,%,$@))
|
||||
endef
|
||||
|
||||
# Hook to be called when finish executing a top-level target
|
||||
define TargetExit
|
||||
$(call RecordEndTime,$(patsubst %-only,%,$@))
|
||||
$(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \
|
||||
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`"
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
|
||||
# A file containing a way to uniquely identify the source code revision that
|
||||
# the build was created from
|
||||
SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker
|
||||
|
||||
# Locate all sourcecode repositories included in the forest, as absolute paths
|
||||
FindAllReposAbs = \
|
||||
$(strip $(sort $(dir $(filter-out $(TOPDIR)/build/%, $(wildcard \
|
||||
$(addprefix $(TOPDIR)/, .git */.git */*/.git */*/*/.git */*/*/*/.git) \
|
||||
)))))
|
||||
|
||||
# Locate all sourcecode repositories included in the forest, as relative paths
|
||||
FindAllReposRel = \
|
||||
$(strip $(subst $(TOPDIR)/,.,$(patsubst $(TOPDIR)/%/, %, $(FindAllReposAbs))))
|
||||
# Make sure we have a value (could be overridden on command line by caller)
|
||||
CREATING_BUILDJDK ?= false
|
||||
|
||||
################################################################################
|
||||
|
||||
|
@ -237,224 +184,6 @@ define NamedParamsMacroTemplate
|
|||
$(call $(0)Body,$(strip $1))
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# Make directory without forking mkdir if not needed.
|
||||
#
|
||||
# If a directory with an encoded space is provided, the wildcard function
|
||||
# sometimes returns false answers (typically if the dir existed when the
|
||||
# makefile was parsed, but was deleted by a previous rule). In that case, always
|
||||
# call mkdir regardless of what wildcard says.
|
||||
#
|
||||
# 1: List of directories to create
|
||||
MakeDir = \
|
||||
$(strip \
|
||||
$(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \
|
||||
$(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \
|
||||
$(if $(wildcard $d), , $d) \
|
||||
) \
|
||||
))) \
|
||||
$(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
|
||||
)
|
||||
|
||||
# Make directory for target file. Should handle spaces in filenames. Just
|
||||
# calling $(call MakeDir $(@D)) will not work if the directory contains a space
|
||||
# and the target file already exists. In that case, the target file will have
|
||||
# its wildcard ? resolved and the $(@D) will evaluate each space separated dir
|
||||
# part on its own.
|
||||
MakeTargetDir = \
|
||||
$(call MakeDir, $(dir $(call EncodeSpace, $@)))
|
||||
|
||||
################################################################################
|
||||
# All install-file and related macros automatically call DecodeSpace when needed.
|
||||
|
||||
ifeq ($(call isTargetOs, macosx), true)
|
||||
# On mac, extended attributes sometimes creep into the source files, which may later
|
||||
# cause the creation of ._* files which confuses testing. Clear these with xattr if
|
||||
# set. Some files get their write permissions removed after being copied to the
|
||||
# output dir. When these are copied again to images, xattr would fail. By only clearing
|
||||
# attributes when they are present, failing on this is avoided.
|
||||
#
|
||||
# If copying a soft link to a directory, need to delete the target first to avoid
|
||||
# weird errors.
|
||||
define install-file
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
# Work around a weirdness with cp on Macosx. When copying a symlink, if
|
||||
# the target of the link is write protected (e.g. 444), cp will add
|
||||
# write permission for the user on the target file (644). Avoid this by
|
||||
# using ln to create a new link instead.
|
||||
if [ -h '$(call DecodeSpace, $<)' ]; then \
|
||||
$(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \
|
||||
else \
|
||||
$(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
|
||||
fi
|
||||
if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then \
|
||||
$(XATTR) -cs '$(call DecodeSpace, $@)'; \
|
||||
fi
|
||||
endef
|
||||
else
|
||||
define install-file
|
||||
$(call MakeTargetDir)
|
||||
$(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
# Variant of install file that does not preserve symlinks
|
||||
define install-file-nolink
|
||||
$(call MakeTargetDir)
|
||||
$(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# link-file-* works similarly to install-file but creates a symlink instead.
|
||||
# There are two versions, either creating a relative or an absolute link. Be
|
||||
# careful when using this on Windows since the symlink created is only valid in
|
||||
# the unix emulation environment.
|
||||
# In msys2 we use mklink /J because its ln would perform a deep copy of the target.
|
||||
# This inhibits performance and can lead to issues with long paths. With mklink /J
|
||||
# relative linking does not work, so we handle the link as absolute path.
|
||||
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
|
||||
define link-file-relative
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
|
||||
endef
|
||||
else
|
||||
define link-file-relative
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
$(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
|
||||
define link-file-absolute
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
|
||||
endef
|
||||
else
|
||||
define link-file-absolute
|
||||
$(call MakeTargetDir)
|
||||
$(RM) '$(call DecodeSpace, $@)'
|
||||
$(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
|
||||
endef
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
# Recursive wildcard function. Walks down directories recursively and matches
|
||||
# files with the search patterns. Patterns use standard file wildcards (* and
|
||||
# ?).
|
||||
#
|
||||
# $1 - Directories to start search in
|
||||
# $2 - Search patterns
|
||||
rwildcard = \
|
||||
$(strip \
|
||||
$(foreach d, \
|
||||
$(patsubst %/,%,$(sort $(dir $(wildcard $(addsuffix /*/*, $(strip $1)))))), \
|
||||
$(call rwildcard,$d,$2) \
|
||||
) \
|
||||
$(call DoubleDollar, $(wildcard $(foreach p, $2, $(addsuffix /$(strip $p), $(strip $1))))) \
|
||||
)
|
||||
|
||||
# Find non directories using recursive wildcard function. This function may
|
||||
# be used directly when a small amount of directories is expected to be
|
||||
# searched and caching is not expected to be of use.
|
||||
#
|
||||
# $1 - Directory to start search in
|
||||
# $2 - Optional search patterns, defaults to '*'.
|
||||
WildcardFindFiles = \
|
||||
$(sort $(strip \
|
||||
$(eval WildcardFindFiles_result := $(call rwildcard,$(patsubst %/,%,$1),$(if $(strip $2),$2,*))) \
|
||||
$(filter-out $(patsubst %/,%,$(sort $(dir $(WildcardFindFiles_result)))), \
|
||||
$(WildcardFindFiles_result) \
|
||||
) \
|
||||
))
|
||||
|
||||
# Find non directories using the find utility in the shell. Safe to call for
|
||||
# non existing directories, or directories containing wildcards.
|
||||
#
|
||||
# Files containing space will get spaces replaced with ? because GNU Make
|
||||
# cannot handle lists of files with space in them. By using ?, make will match
|
||||
# the wildcard to space in many situations so we don't need to replace back
|
||||
# to space on every use. While not a complete solution it does allow some uses
|
||||
# of FindFiles to function with spaces in file names, including for
|
||||
# SetupCopyFiles. Unfortunately this does not work for WildcardFindFiles so
|
||||
# if files with spaces are anticipated, use ShellFindFiles directly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns, empty means find everything. Patterns use
|
||||
# standard file wildcards (* and ?) and should not be quoted.
|
||||
# $3 - Optional options to find.
|
||||
ShellFindFiles = \
|
||||
$(if $(wildcard $1), \
|
||||
$(sort \
|
||||
$(shell $(FIND) $3 $(patsubst %/,%,$(wildcard $1)) \( -type f -o -type l \) \
|
||||
$(if $(strip $2), -a \( -name "$(firstword $2)" \
|
||||
$(foreach p, $(filter-out $(firstword $2), $2), -o -name "$(p)") \)) \
|
||||
| $(TR) ' ' '?' \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Find non directories using the method most likely to work best for the
|
||||
# current build host
|
||||
#
|
||||
# $1 - Directory to start search in
|
||||
# $2 - Optional search patterns, defaults to '*'.
|
||||
ifeq ($(OPENJDK_BUILD_OS)-$(RWILDCARD_WORKS), windows-true)
|
||||
DirectFindFiles = $(WildcardFindFiles)
|
||||
else
|
||||
DirectFindFiles = $(ShellFindFiles)
|
||||
endif
|
||||
|
||||
# Finds files using a cache that is populated by FillFindCache below. If any of
|
||||
# the directories given have not been cached, DirectFindFiles is used for
|
||||
# everything. Caching is especially useful in Cygwin, where file finds are very
|
||||
# costly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns. If used, no caching is done.
|
||||
CacheFindFiles_CACHED_DIRS :=
|
||||
CacheFindFiles_CACHED_FILES :=
|
||||
CacheFindFiles = \
|
||||
$(if $2, \
|
||||
$(call DirectFindFiles, $1, $2) \
|
||||
, \
|
||||
$(if $(filter-out $(addsuffix /%, $(CacheFindFiles_CACHED_DIRS)) \
|
||||
$(CacheFindFiles_CACHED_DIRS), $1), \
|
||||
$(call DirectFindFiles, $1) \
|
||||
, \
|
||||
$(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(CacheFindFiles_CACHED_FILES)) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Explicitly adds files to the find cache used by CacheFindFiles.
|
||||
#
|
||||
# $1 - Directories to start search in
|
||||
FillFindCache = \
|
||||
$(eval CacheFindFiles_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
|
||||
$$(CacheFindFiles_CACHED_DIRS)) $$(CacheFindFiles_CACHED_DIRS), $1)) \
|
||||
$(if $(CacheFindFiles_NEW_DIRS), \
|
||||
$(eval CacheFindFiles_CACHED_DIRS += $$(patsubst %/,%,$$(CacheFindFiles_NEW_DIRS))) \
|
||||
$(eval CacheFindFiles_CACHED_FILES := $$(sort $$(CacheFindFiles_CACHED_FILES) \
|
||||
$$(call DirectFindFiles, $$(CacheFindFiles_NEW_DIRS)))) \
|
||||
)
|
||||
|
||||
# Findfiles is the default macro that should be used to find files in the file
|
||||
# system. This function does not always support files with spaces in the names.
|
||||
# If files with spaces are anticipated, use ShellFindFiles directly.
|
||||
#
|
||||
# $1 - Directories to start search in.
|
||||
# $2 - Optional search patterns, empty means find everything. Patterns use
|
||||
# standard file wildcards (* and ?) and should not be quoted.
|
||||
ifeq ($(DISABLE_CACHE_FIND), true)
|
||||
FindFiles = $(DirectFindFiles)
|
||||
else
|
||||
FindFiles = $(CacheFindFiles)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# FixPath
|
||||
#
|
||||
|
|
|
@ -241,32 +241,3 @@ else # HAS_FILE_FUNCTION = false
|
|||
$$(call ListPathsSafely_IfPrintf,$1,$2,29751,30000)
|
||||
endef
|
||||
endif # HAS_FILE_FUNCTION
|
||||
|
||||
################################################################################
|
||||
# Write to and read from file
|
||||
|
||||
# Param 1 - File to read
|
||||
ReadFile = \
|
||||
$(shell $(CAT) $1)
|
||||
|
||||
# Param 1 - Text to write
|
||||
# Param 2 - File to write to
|
||||
ifeq ($(HAS_FILE_FUNCTION), true)
|
||||
WriteFile = \
|
||||
$(file >$2,$(strip $1))
|
||||
else
|
||||
# Use printf to get consistent behavior on all platforms.
|
||||
WriteFile = \
|
||||
$(shell $(PRINTF) "%s\n" $(strip $(call ShellQuote, $1)) > $2)
|
||||
endif
|
||||
|
||||
# Param 1 - Text to write
|
||||
# Param 2 - File to write to
|
||||
ifeq ($(HAS_FILE_FUNCTION), true)
|
||||
AppendFile = \
|
||||
$(file >>$2,$(strip $1))
|
||||
else
|
||||
# Use printf to get consistent behavior on all platforms.
|
||||
AppendFile = \
|
||||
$(shell $(PRINTF) "%s\n" $(strip $(call ShellQuote, $1)) >> $2)
|
||||
endif
|
||||
|
|
|
@ -36,6 +36,7 @@ ifeq ($(_MAKEBASE_GMK), )
|
|||
$(error You must include MakeBase.gmk prior to including NativeCompilation.gmk)
|
||||
endif
|
||||
|
||||
include MakeIO.gmk
|
||||
include native/CompileFile.gmk
|
||||
include native/DebugSymbols.gmk
|
||||
include native/Flags.gmk
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -29,29 +29,34 @@ endif
|
|||
|
||||
################################################################################
|
||||
#
|
||||
# Common utility functions
|
||||
# Basic utility functions available to MakeBase.gmk itself
|
||||
#
|
||||
################################################################################
|
||||
|
||||
### Debug functions
|
||||
# String equals
|
||||
equals = \
|
||||
$(if $(strip $1)$(strip $2),$(strip \
|
||||
$(and $(findstring $(strip $1),$(strip $2)),\
|
||||
$(findstring $(strip $2),$(strip $1)))), \
|
||||
true \
|
||||
)
|
||||
|
||||
# Prints the name and value of a variable
|
||||
PrintVar = \
|
||||
$(info $(strip $1) >$($(strip $1))<)
|
||||
# Convert the string given to upper case, without any $(shell)
|
||||
# Inspired by http://lists.gnu.org/archive/html/help-make/2013-09/msg00009.html
|
||||
uppercase_table := a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O \
|
||||
p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z
|
||||
|
||||
################################################################################
|
||||
# This macro translates $ into \$ to protect the $ from expansion in the shell.
|
||||
# To make this macro resilient against already escaped strings, first remove
|
||||
# any present escapes before escaping so that no double escapes are added.
|
||||
EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
|
||||
uppercase_internal = \
|
||||
$(if $(strip $1), $$(subst $(firstword $1), $(call uppercase_internal, \
|
||||
$(wordlist 2, $(words $1), $1), $2)), $2)
|
||||
|
||||
################################################################################
|
||||
# This macro works just like EscapeDollar above, but for #.
|
||||
EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1)))
|
||||
|
||||
################################################################################
|
||||
# This macro translates $ into $$ to protect the string from make itself.
|
||||
DoubleDollar = $(subst $$,$$$$,$(strip $1))
|
||||
# Convert a string to upper case. Works only on a-z.
|
||||
# $1 - The string to convert
|
||||
uppercase = \
|
||||
$(strip \
|
||||
$(eval uppercase_result := $(call uppercase_internal, $(uppercase_table), $1)) \
|
||||
$(uppercase_result) \
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Creates a sequence of increasing numbers (inclusive).
|
||||
|
@ -68,23 +73,142 @@ _sequence-do = \
|
|||
$(words $(SEQUENCE_COUNT)) \
|
||||
$(call _sequence-do,$1))
|
||||
|
||||
################################################################################
|
||||
# This macro translates $ into \$ to protect the $ from expansion in the shell.
|
||||
# To make this macro resilient against already escaped strings, first remove
|
||||
# any present escapes before escaping so that no double escapes are added.
|
||||
EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
|
||||
|
||||
################################################################################
|
||||
# This macro works just like EscapeDollar above, but for #.
|
||||
EscapeHash = $(subst \#,\\\#,$(subst \\\#,\#,$(strip $1)))
|
||||
|
||||
################################################################################
|
||||
# This macro translates $ into $$ to protect the string from make itself.
|
||||
DoubleDollar = $(subst $$,$$$$,$(strip $1))
|
||||
|
||||
################################################################################
|
||||
# ShellQuote
|
||||
#
|
||||
# Quotes a string with single quotes and replaces single quotes with '\'' so
|
||||
# that the contents survives being given to the shell.
|
||||
ShellQuote = \
|
||||
$(SQUOTE)$(subst $(SQUOTE),$(SQUOTE)\$(SQUOTE)$(SQUOTE),$(strip $1))$(SQUOTE)
|
||||
|
||||
################################################################################
|
||||
# Write to and read from file
|
||||
|
||||
# Param 1 - File to read
|
||||
ReadFile = \
|
||||
$(shell $(CAT) $1)
|
||||
|
||||
# Param 1 - Text to write
|
||||
# Param 2 - File to write to
|
||||
ifeq ($(HAS_FILE_FUNCTION), true)
|
||||
WriteFile = \
|
||||
$(file >$2,$(strip $1))
|
||||
else
|
||||
# Use printf to get consistent behavior on all platforms.
|
||||
WriteFile = \
|
||||
$(shell $(PRINTF) "%s\n" $(strip $(call ShellQuote, $1)) > $2)
|
||||
endif
|
||||
|
||||
# Param 1 - Text to write
|
||||
# Param 2 - File to write to
|
||||
ifeq ($(HAS_FILE_FUNCTION), true)
|
||||
AppendFile = \
|
||||
$(file >>$2,$(strip $1))
|
||||
else
|
||||
# Use printf to get consistent behavior on all platforms.
|
||||
AppendFile = \
|
||||
$(shell $(PRINTF) "%s\n" $(strip $(call ShellQuote, $1)) >> $2)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Make directory without forking mkdir if not needed.
|
||||
#
|
||||
# If a directory with an encoded space is provided, the wildcard function
|
||||
# sometimes returns false answers (typically if the dir existed when the
|
||||
# makefile was parsed, but was deleted by a previous rule). In that case, always
|
||||
# call mkdir regardless of what wildcard says.
|
||||
#
|
||||
# 1: List of directories to create
|
||||
MakeDir = \
|
||||
$(strip \
|
||||
$(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \
|
||||
$(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \
|
||||
$(if $(wildcard $d), , $d) \
|
||||
) \
|
||||
))) \
|
||||
$(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Check if our build or target conforms to certain restrictions. This set of
|
||||
# functions all work in similar ways, testing the property that the name
|
||||
# implies, so e.g. isTargetCpu test the CPU of the target system.
|
||||
#
|
||||
# $1 - A property, or a space separated list of properties to test for.
|
||||
#
|
||||
# Returns true if the actual property matches one of the properties in the list,
|
||||
# and false otherwise.
|
||||
#
|
||||
# Examples: $(call isTargetOs, linux windows) will return true when executed
|
||||
# on either linux or windows, and false otherwise.
|
||||
# $(call isBuildCpuArch, x86) will return true iff the build CPU Arch is x86.
|
||||
|
||||
isTargetOs = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, false))
|
||||
|
||||
isTargetOsType = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false))
|
||||
|
||||
isTargetCpu = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU), $1), true, false))
|
||||
|
||||
isTargetCpuArch = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU_ARCH), $1), true, false))
|
||||
|
||||
isTargetCpuBits = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU_BITS), $1), true, false))
|
||||
|
||||
isBuildOs = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS), $1), true, false))
|
||||
|
||||
isBuildOsType = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS_TYPE), $1), true, false))
|
||||
|
||||
isBuildOsEnv = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS_ENV), $1), true, false))
|
||||
|
||||
isBuildCpu = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_CPU), $1), true, false))
|
||||
|
||||
isBuildCpuArch = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_CPU_ARCH), $1), true, false))
|
||||
|
||||
isCompiler = \
|
||||
$(strip $(if $(filter $(TOOLCHAIN_TYPE), $1), true, false))
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Common utility functions
|
||||
#
|
||||
################################################################################
|
||||
|
||||
### Debug functions
|
||||
|
||||
# Prints the name and value of a variable
|
||||
PrintVar = \
|
||||
$(info $(strip $1) >$($(strip $1))<)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Strip both arguments. Append the first argument to the second argument. If the
|
||||
# first argument is empty, return the empty string.
|
||||
IfAppend = \
|
||||
$(if $(strip $1),$(strip $1)$(strip $2),)
|
||||
|
||||
################################################################################
|
||||
# Replace question marks with space in string. This macro needs to be called on
|
||||
# files from FindFiles in case any of them contains space in their file name,
|
||||
# since FindFiles replaces space with ?.
|
||||
# Param 1 - String to replace in
|
||||
DecodeSpace = \
|
||||
$(subst ?,$(SPACE),$(strip $1))
|
||||
|
||||
EncodeSpace = \
|
||||
$(subst $(SPACE),?,$(strip $1))
|
||||
|
||||
################################################################################
|
||||
# Assign a variable only if it is empty
|
||||
# Param 1 - Variable to assign
|
||||
|
@ -92,65 +216,6 @@ EncodeSpace = \
|
|||
SetIfEmpty = \
|
||||
$(if $($(strip $1)),,$(eval $(strip $1) := $2))
|
||||
|
||||
################################################################################
|
||||
# Take two paths and return the path of the last common directory.
|
||||
# Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
|
||||
# foo/bar/baz, /foo/bar -> <empty>
|
||||
#
|
||||
# The x prefix is used to preserve the presence of the initial slash
|
||||
# On Windows paths are treated as case-insensitive
|
||||
#
|
||||
# $1 - Path to compare
|
||||
# $2 - Other path to compare
|
||||
FindCommonPathPrefix = \
|
||||
$(call DecodeSpace,$(patsubst x%,%,$(subst $(SPACE),/,$(strip \
|
||||
$(call FindCommonPathPrefixHelper1, \
|
||||
$(subst /,$(SPACE),x$(call EncodeSpace,$(strip $1))), \
|
||||
$(subst /,$(SPACE),x$(call EncodeSpace,$(strip $2)))) \
|
||||
))))
|
||||
|
||||
FindCommonPathPrefixHelper1 = \
|
||||
$(if $(filter $(OPENJDK_TARGET_OS), windows), \
|
||||
$(call FindCommonPathPrefixHelper2,$(call uppercase,$1),$(call uppercase,$2),$1), \
|
||||
$(call FindCommonPathPrefixHelper2,$1,$2,$1))
|
||||
|
||||
FindCommonPathPrefixHelper2 = \
|
||||
$(if $(call equals, $(firstword $1), $(firstword $2)), \
|
||||
$(if $(call equals, $(firstword $1),),, \
|
||||
$(firstword $3) \
|
||||
$(call FindCommonPathPrefixHelper2, \
|
||||
$(wordlist 2, $(words $1), $1), \
|
||||
$(wordlist 2, $(words $2), $2), \
|
||||
$(wordlist 2, $(words $3), $3) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Computes the relative path from a directory to a file
|
||||
# $1 - File to compute the relative path to
|
||||
# $2 - Directory to compute the relative path from
|
||||
RelativePath = \
|
||||
$(call DecodeSpace,$(strip $(call RelativePathHelper,$(call EncodeSpace \
|
||||
,$(strip $1)),$(call EncodeSpace \
|
||||
,$(strip $2)),$(call EncodeSpace \
|
||||
,$(call FindCommonPathPrefix,$1,$2)))))
|
||||
|
||||
RelativePathHelper = \
|
||||
$(eval $3_prefix_length := $(words $(subst /,$(SPACE),$3))) \
|
||||
$(eval $1_words := $(subst /,$(SPACE),$1)) \
|
||||
$(eval $2_words := $(subst /,$(SPACE),$2)) \
|
||||
$(if $(call equals,$($3_prefix_length),0),, \
|
||||
$(eval $1_words := $(wordlist 2,$(words $($1_words)),$(wordlist \
|
||||
$($3_prefix_length),$(words $($1_words)),$($1_words)))) \
|
||||
$(eval $2_words := $(wordlist 2,$(words $($2_words)),$(wordlist \
|
||||
$($3_prefix_length),$(words $($2_words)),$($2_words)))) \
|
||||
) \
|
||||
$(eval $1_suffix := $(subst $(SPACE),/,$($1_words))) \
|
||||
$(eval $2_dotdots := $(subst $(SPACE),/,$(foreach d,$($2_words),..))) \
|
||||
$(if $($1_suffix), \
|
||||
$(if $($2_dotdots), $($2_dotdots)/$($1_suffix), $($1_suffix)), \
|
||||
$(if $($2_dotdots), $($2_dotdots), .))
|
||||
|
||||
################################################################################
|
||||
# Filter out duplicate sub strings while preserving order. Keeps the first occurrence.
|
||||
uniq = \
|
||||
|
@ -173,14 +238,6 @@ dups = \
|
|||
$(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
|
||||
$(words $(filter $v, $1))), $v)))
|
||||
|
||||
# String equals
|
||||
equals = \
|
||||
$(if $(strip $1)$(strip $2),$(strip \
|
||||
$(and $(findstring $(strip $1),$(strip $2)),\
|
||||
$(findstring $(strip $2),$(strip $1)))), \
|
||||
true \
|
||||
)
|
||||
|
||||
# Remove a whole list of prefixes
|
||||
# $1 - List of prefixes
|
||||
# $2 - List of elements to process
|
||||
|
@ -188,23 +245,6 @@ remove-prefixes = \
|
|||
$(strip $(if $1,$(patsubst $(firstword $1)%,%,\
|
||||
$(call remove-prefixes,$(filter-out $(firstword $1),$1),$2)),$2))
|
||||
|
||||
# Convert the string given to upper case, without any $(shell)
|
||||
# Inspired by http://lists.gnu.org/archive/html/help-make/2013-09/msg00009.html
|
||||
uppercase_table := a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O \
|
||||
p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z
|
||||
|
||||
uppercase_internal = \
|
||||
$(if $(strip $1), $$(subst $(firstword $1), $(call uppercase_internal, \
|
||||
$(wordlist 2, $(words $1), $1), $2)), $2)
|
||||
|
||||
# Convert a string to upper case. Works only on a-z.
|
||||
# $1 - The string to convert
|
||||
uppercase = \
|
||||
$(strip \
|
||||
$(eval uppercase_result := $(call uppercase_internal, $(uppercase_table), $1)) \
|
||||
$(uppercase_result) \
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Boolean operators.
|
||||
|
||||
|
@ -290,14 +330,6 @@ define ParseKeywordVariableBody
|
|||
endif
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# ShellQuote
|
||||
#
|
||||
# Quotes a string with single quotes and replaces single quotes with '\'' so
|
||||
# that the contents survives being given to the shell.
|
||||
ShellQuote = \
|
||||
$(SQUOTE)$(subst $(SQUOTE),$(SQUOTE)\$(SQUOTE)$(SQUOTE),$(strip $1))$(SQUOTE)
|
||||
|
||||
################################################################################
|
||||
# Find lib dir for module
|
||||
# Param 1 - module name
|
||||
|
@ -329,53 +361,6 @@ check-jvm-variant = \
|
|||
$(error Internal error: Invalid variant tested: $1)) \
|
||||
$(if $(filter $1, $(JVM_VARIANTS)), true, false))
|
||||
|
||||
################################################################################
|
||||
# Check if our build or target conforms to certain restrictions. This set of
|
||||
# functions all work in similar ways, testing the property that the name
|
||||
# implies, so e.g. isTargetCpu test the CPU of the target system.
|
||||
#
|
||||
# $1 - A property, or a space separated list of properties to test for.
|
||||
#
|
||||
# Returns true if the actual property matches one of the properties in the list,
|
||||
# and false otherwise.
|
||||
#
|
||||
# Examples: $(call isTargetOs, linux windows) will return true when executed
|
||||
# on either linux or windows, and false otherwise.
|
||||
# $(call isBuildCpuArch, x86) will return true iff the build CPU Arch is x86.
|
||||
|
||||
isTargetOs = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, false))
|
||||
|
||||
isTargetOsType = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false))
|
||||
|
||||
isTargetCpu = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU), $1), true, false))
|
||||
|
||||
isTargetCpuArch = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU_ARCH), $1), true, false))
|
||||
|
||||
isTargetCpuBits = \
|
||||
$(strip $(if $(filter $(OPENJDK_TARGET_CPU_BITS), $1), true, false))
|
||||
|
||||
isBuildOs = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS), $1), true, false))
|
||||
|
||||
isBuildOsType = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS_TYPE), $1), true, false))
|
||||
|
||||
isBuildOsEnv = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_OS_ENV), $1), true, false))
|
||||
|
||||
isBuildCpu = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_CPU), $1), true, false))
|
||||
|
||||
isBuildCpuArch = \
|
||||
$(strip $(if $(filter $(OPENJDK_BUILD_CPU_ARCH), $1), true, false))
|
||||
|
||||
isCompiler = \
|
||||
$(strip $(if $(filter $(TOOLCHAIN_TYPE), $1), true, false))
|
||||
|
||||
################################################################################
|
||||
# Converts a space separated list to a comma separated list.
|
||||
#
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
LIB_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)
|
||||
CONF_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE)
|
||||
LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JdkNativeCompilation.gmk
|
||||
include Modules.gmk
|
||||
include ProcessMarkdown.gmk
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
# Copy all built libraries into exploded jdk
|
||||
LIB_TARGETS := $(filter $(LIB_OUTPUTDIR)/%, $(TARGETS))
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
$(eval $(call IncludeCustomExtension, hotspot/gensrc/GensrcJvmti.gmk))
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
# Include support files that will setup compiler flags due to the selected
|
||||
# jvm feature set, specific file overrides, and general flags.
|
||||
include lib/JvmFeatures.gmk
|
||||
|
|
|
@ -28,6 +28,8 @@ default: all
|
|||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
$(foreach v, $(JVM_VARIANTS), \
|
||||
$(eval $(call SetupCopyFiles, COPY_GTEST_$v, \
|
||||
SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
include LibCommon.gmk
|
||||
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
|
||||
LIBAWT_DEFAULT_HEADER_DIRS := \
|
||||
common/awt/utility \
|
||||
libawt/awt/image \
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
# questions.
|
||||
#
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JarArchive.gmk
|
||||
include JavaCompilation.gmk
|
||||
include Modules.gmk
|
||||
|
|
|
@ -27,6 +27,8 @@ default: build
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
|
||||
TARGETS :=
|
||||
|
|
|
@ -27,6 +27,8 @@ default: build
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
|
||||
TARGETS :=
|
||||
|
|
|
@ -28,6 +28,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include JavaCompilation.gmk
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -33,6 +33,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -33,6 +33,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
$(eval $(call IncludeCustomExtension, test/JtregNativeHotspot.gmk))
|
||||
|
|
|
@ -33,6 +33,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
$(eval $(call IncludeCustomExtension, test/JtregNativeJdk.gmk))
|
||||
|
|
|
@ -33,6 +33,8 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
include CopyFiles.gmk
|
||||
include TestFilesCompilation.gmk
|
||||
|
||||
$(eval $(call IncludeCustomExtension, test/JtregNativeLibTest.gmk))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,6 +25,7 @@ default: all
|
|||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include CopyFiles.gmk
|
||||
include UtilsForTests.gmk
|
||||
|
||||
THIS_FILE := $(TOPDIR)/test/make/TestCopyFiles.gmk
|
||||
|
|
Загрузка…
Ссылка в новой задаче