8136385: Various build speed improvements for windows

Reviewed-by: ihse
This commit is contained in:
Erik Joelsson 2015-09-28 11:39:13 +02:00
parent c28cba0346
commit 8b5e47f2c8
4 changed files with 139 additions and 292 deletions

View File

@ -122,9 +122,9 @@ define SetupArchiveBody
$1_GREP_INCLUDES:=| ( $(GREP) $$(patsubst %,$(SPACE)-e$(SPACE)$(DQUOTE)%$(DQUOTE),$$($1_GREP_INCLUDE_PATTERNS)) \
|| test "$$$$?" = "1" )
else
$1_GREP_INCLUDE_OUTPUT:=$(RM) $$($1_BIN)/_the.$$($1_JARNAME)_include $$(NEWLINE) \
$$(call ListPathsSafely,$1_GREP_INCLUDE_PATTERNS,\n, \
>> $$($1_BIN)/_the.$$($1_JARNAME)_include)
$1_GREP_INCLUDE_OUTPUT = \
$$(eval $$(call ListPathsSafely,$1_GREP_INCLUDE_PATTERNS, \
$$($1_BIN)/_the.$$($1_JARNAME)_include))
$1_GREP_INCLUDES:=| ( $(GREP) -f $$($1_BIN)/_the.$$($1_JARNAME)_include \
|| test "$$$$?" = "1" )
endif
@ -138,9 +138,9 @@ define SetupArchiveBody
$1_GREP_EXCLUDES:=| ( $(GREP) -v $$(patsubst %,$(SPACE)-e$(SPACE)$(DQUOTE)%$(DQUOTE),$$($1_GREP_EXCLUDE_PATTERNS)) \
|| test "$$$$?" = "1" )
else
$1_GREP_EXCLUDE_OUTPUT=$(RM) $$($1_BIN)/_the.$$($1_JARNAME)_exclude $$(NEWLINE) \
$$(call ListPathsSafely,$1_GREP_EXCLUDE_PATTERNS,\n, \
>> $$($1_BIN)/_the.$$($1_JARNAME)_exclude)
$1_GREP_EXCLUDE_OUTPUT = \
$$(eval $$(call ListPathsSafely,$1_GREP_EXCLUDE_PATTERNS, \
$$($1_BIN)/_the.$$($1_JARNAME)_exclude))
$1_GREP_EXCLUDES:=| ( $(GREP) -v -f $$($1_BIN)/_the.$$($1_JARNAME)_exclude \
|| test "$$$$?" = "1" )
endif
@ -190,13 +190,12 @@ define SetupArchiveBody
# The EXTRA_FILES_RESOLVED varible must be set in the macro so that it's evaluated
# in the recipe when the files are guaranteed to exist.
$1_CAPTURE_EXTRA_FILES=\
$(RM) $$($1_BIN)/_the.$$($1_JARNAME)_contents.extra $$(NEWLINE) \
$$(eval $1_EXTRA_FILES_RESOLVED:=$$(call DoubleDollar, $$(call DoubleDollar, \
$$(eval $1_EXTRA_FILES_RESOLVED:=$$(call DoubleDollar, \
$$(wildcard $$(foreach src, $$($1_SRCS), \
$$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES))))) \
$$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES)))) \
$$(if $$($1_EXTRA_FILES_RESOLVED), \
$$(call ListPathsSafely,$1_EXTRA_FILES_RESOLVED,\n, \
>> $$($1_BIN)/_the.$$($1_JARNAME)_contents.extra) $$(NEWLINE) \
$$(eval $$(call ListPathsSafely,$1_EXTRA_FILES_RESOLVED, \
$$($1_BIN)/_the.$$($1_JARNAME)_contents.extra)) \
$(SED) $$(foreach src,$$($1_SRCS), -e 's|$$(src)/|-C $$(src) |g') \
$$($1_BIN)/_the.$$($1_JARNAME)_contents.extra \
>> $$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE))
@ -577,7 +576,7 @@ define SetupJavaCompilationBody
$$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
$(MKDIR) -p $$(@D) $$(dir $$($1_SJAVAC_PORTFILE))
$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
$$(eval $$(call ListPathsSafely,$1_SRCS, $$($1_BIN)/_the.$1_batch.tmp))
$(ECHO) Compiling $1
$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch.log, $$($1_SAFE_NAME), \
$$($1_JVM) $$($1_SJAVAC) \
@ -636,8 +635,7 @@ define SetupJavaCompilationBody
# When not using sjavac, pass along all sources to javac using an @file.
$$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE)
$(MKDIR) -p $$(@D)
$(RM) $$($1_BIN)/_the.$1_batch $$($1_BIN)/_the.$1_batch.tmp
$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp)
$$(eval $$(call ListPathsSafely,$1_SRCS, $$($1_BIN)/_the.$1_batch.tmp))
$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1
$(call LogFailures, $$($1_BIN)/_the.$$($1_SAFE_NAME)_batch.log, $$($1_SAFE_NAME), \
$$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \

View File

@ -64,6 +64,11 @@ define NEWLINE
endef
# In GNU Make 4.0 and higher, there is a file function for writing to files.
ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
HAS_FILE_FUNCTION := true
endif
##############################
# Functions
##############################
@ -122,266 +127,111 @@ EscapeDollar = $(subst $$,\$$,$(subst \$$,$$,$(strip $1)))
DoubleDollar = $(subst $$,$$$$,$(strip $1))
################################################################################
# ListPathsSafely can be used to print command parameters to a file. This is
# typically done if the command line lenght risk being too long for the
# OS/shell. In later make versions, the file function can be used for this
# purpose. For earlier versions, a more complex implementation is provided.
#
# The function ListPathsSafely can be called either directly or, more commonly
# from a recipe line. If called from a recipe, it will be executed in the
# evaluation phase of that recipe, which means that it will write to the file
# before any other line in the recipe has been run.
ifeq ($(HAS_FILE_FUNCTION), true)
# Param 1 - Name of variable containing paths/arguments to output
# Param 2 - File to print to
# Param 3 - Set to true to append to file instead of overwriting
define ListPathsSafely
$$(call MakeDir, $$(dir $$(strip $2)))
$$(file $$(if $$(filter true, $$(strip $3)),>>,>) \
$$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1)))))
endef
# If the variable that you want to send to stdout for piping into a file or otherwise,
# is potentially long, for example the a list of file paths, eg a list of all package directories.
# Then you need to use ListPathsSafely, which optimistically splits the output into several shell
# calls as well as use compression on recurrent file paths segments, to get around the potential
# command line length problem that exists in cygwin and other shells.
compress_pre:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl))
compress_post:=$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl))
compress_paths=$(compress_pre)\
else # HAS_FILE_FUNCTION
$(eval compress_paths = \
$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl)))
compress_paths += \
$(subst $(SRC_ROOT),X97,\
$(subst $(OUTPUT_ROOT),X98,\
$(subst X,X00,\
$(subst $(SPACE),\n,$(strip $1)))))\
$(compress_post)
$(subst $(SPACE),\n,$(strip $1)))))
$(eval compress_paths += \
$(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-post-compress.incl)))
decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed -e 's|X99|\\n|g' \
decompress_paths=$(SED) -f $(SRC_ROOT)/make/common/support/ListPathsSafely-uncompress.sed \
-e 's|X99|\\n|g' \
-e 's|X98|$(OUTPUT_ROOT)|g' -e 's|X97|$(SRC_ROOT)|g' \
-e 's|X00|X|g' | tr '\n' '$2'
-e 's|X00|X|g'
define ListPathsSafely_If
$(if $(word $3,$($1)),$(eval $1_LPS$3:=$(call compress_paths,$(wordlist $3,$4,$($1)))))
endef
ListPathsSafely_IfPrintf = \
$(if $(word $3,$($(strip $1))), \
$(shell $(PRINTF) -- "$(strip $(call EscapeDollar, \
$(call compress_paths, $(wordlist $3,$4,$($(strip $1))))))\n" \
| $(decompress_paths) >> $2))
define ListPathsSafely_Printf
$(if $(strip $($1_LPS$4)),$(if $(findstring $(LOG_LEVEL),trace),,@)printf \
-- "$(strip $(call EscapeDollar, $($1_LPS$4)))\n" | $(decompress_paths) $3)
endef
# Receipt example:
# rm -f thepaths
# $(call ListPathsSafely,THEPATHS,\n, >> thepaths)
# The \n argument means translate spaces into \n
# if instead , , (a space) is supplied, then spaces remain spaces.
# Param 1 - Name of variable containing paths/arguments to output
# Param 2 - File to print to
# Param 3 - Set to true to append to file instead of overwriting
define ListPathsSafely
$(if $(word 16001,$($1)),$(error Cannot list safely more than 16000 paths. $1 has $(words $($1)) paths!))
$(ECHO) $(LOG_DEBUG) Writing $(words $($1)) paths to '$3'
$(call ListPathsSafely_If,$1,$2,1,250)
$(call ListPathsSafely_If,$1,$2,251,500)
$(call ListPathsSafely_If,$1,$2,501,750)
$(call ListPathsSafely_If,$1,$2,751,1000)
$(call ListPathsSafely_If,$1,$2,1001,1250)
$(call ListPathsSafely_If,$1,$2,1251,1500)
$(call ListPathsSafely_If,$1,$2,1501,1750)
$(call ListPathsSafely_If,$1,$2,1751,2000)
$(call ListPathsSafely_If,$1,$2,2001,2250)
$(call ListPathsSafely_If,$1,$2,2251,2500)
$(call ListPathsSafely_If,$1,$2,2501,2750)
$(call ListPathsSafely_If,$1,$2,2751,3000)
$(call ListPathsSafely_If,$1,$2,3001,3250)
$(call ListPathsSafely_If,$1,$2,3251,3500)
$(call ListPathsSafely_If,$1,$2,3501,3750)
$(call ListPathsSafely_If,$1,$2,3751,4000)
$(call ListPathsSafely_If,$1,$2,4001,4250)
$(call ListPathsSafely_If,$1,$2,4251,4500)
$(call ListPathsSafely_If,$1,$2,4501,4750)
$(call ListPathsSafely_If,$1,$2,4751,5000)
$(call ListPathsSafely_If,$1,$2,5001,5250)
$(call ListPathsSafely_If,$1,$2,5251,5500)
$(call ListPathsSafely_If,$1,$2,5501,5750)
$(call ListPathsSafely_If,$1,$2,5751,6000)
$(call ListPathsSafely_If,$1,$2,6001,6250)
$(call ListPathsSafely_If,$1,$2,6251,6500)
$(call ListPathsSafely_If,$1,$2,6501,6750)
$(call ListPathsSafely_If,$1,$2,6751,7000)
$(call ListPathsSafely_If,$1,$2,7001,7250)
$(call ListPathsSafely_If,$1,$2,7251,7500)
$(call ListPathsSafely_If,$1,$2,7501,7750)
$(call ListPathsSafely_If,$1,$2,7751,8000)
$(call ListPathsSafely_If,$1,$2,8001,8250)
$(call ListPathsSafely_If,$1,$2,8251,8500)
$(call ListPathsSafely_If,$1,$2,8501,8750)
$(call ListPathsSafely_If,$1,$2,8751,9000)
$(call ListPathsSafely_If,$1,$2,9001,9250)
$(call ListPathsSafely_If,$1,$2,9251,9500)
$(call ListPathsSafely_If,$1,$2,9501,9750)
$(call ListPathsSafely_If,$1,$2,9751,10000)
$(call ListPathsSafely_If,$1,$2,10001,10250)
$(call ListPathsSafely_If,$1,$2,10251,10500)
$(call ListPathsSafely_If,$1,$2,10501,10750)
$(call ListPathsSafely_If,$1,$2,10751,11000)
$(call ListPathsSafely_If,$1,$2,11001,11250)
$(call ListPathsSafely_If,$1,$2,11251,11500)
$(call ListPathsSafely_If,$1,$2,11501,11750)
$(call ListPathsSafely_If,$1,$2,11751,12000)
$(call ListPathsSafely_If,$1,$2,12001,12250)
$(call ListPathsSafely_If,$1,$2,12251,12500)
$(call ListPathsSafely_If,$1,$2,12501,12750)
$(call ListPathsSafely_If,$1,$2,12751,13000)
$(call ListPathsSafely_If,$1,$2,13001,13250)
$(call ListPathsSafely_If,$1,$2,13251,13500)
$(call ListPathsSafely_If,$1,$2,13501,13750)
$(call ListPathsSafely_If,$1,$2,13751,14000)
$(call ListPathsSafely_If,$1,$2,14001,14250)
$(call ListPathsSafely_If,$1,$2,14251,14500)
$(call ListPathsSafely_If,$1,$2,14501,14750)
$(call ListPathsSafely_If,$1,$2,14751,15000)
$(call ListPathsSafely_If,$1,$2,15001,15250)
$(call ListPathsSafely_If,$1,$2,15251,15500)
$(call ListPathsSafely_If,$1,$2,15501,15750)
$(call ListPathsSafely_If,$1,$2,15751,16000)
$(call ListPathsSafely_Printf,$1,$2,$3,1)
$(call ListPathsSafely_Printf,$1,$2,$3,251)
$(call ListPathsSafely_Printf,$1,$2,$3,501)
$(call ListPathsSafely_Printf,$1,$2,$3,751)
$(call ListPathsSafely_Printf,$1,$2,$3,1001)
$(call ListPathsSafely_Printf,$1,$2,$3,1251)
$(call ListPathsSafely_Printf,$1,$2,$3,1501)
$(call ListPathsSafely_Printf,$1,$2,$3,1751)
$(call ListPathsSafely_Printf,$1,$2,$3,2001)
$(call ListPathsSafely_Printf,$1,$2,$3,2251)
$(call ListPathsSafely_Printf,$1,$2,$3,2501)
$(call ListPathsSafely_Printf,$1,$2,$3,2751)
$(call ListPathsSafely_Printf,$1,$2,$3,3001)
$(call ListPathsSafely_Printf,$1,$2,$3,3251)
$(call ListPathsSafely_Printf,$1,$2,$3,3501)
$(call ListPathsSafely_Printf,$1,$2,$3,3751)
$(call ListPathsSafely_Printf,$1,$2,$3,4001)
$(call ListPathsSafely_Printf,$1,$2,$3,4251)
$(call ListPathsSafely_Printf,$1,$2,$3,4501)
$(call ListPathsSafely_Printf,$1,$2,$3,4751)
$(call ListPathsSafely_Printf,$1,$2,$3,5001)
$(call ListPathsSafely_Printf,$1,$2,$3,5251)
$(call ListPathsSafely_Printf,$1,$2,$3,5501)
$(call ListPathsSafely_Printf,$1,$2,$3,5751)
$(call ListPathsSafely_Printf,$1,$2,$3,6001)
$(call ListPathsSafely_Printf,$1,$2,$3,6251)
$(call ListPathsSafely_Printf,$1,$2,$3,6501)
$(call ListPathsSafely_Printf,$1,$2,$3,6751)
$(call ListPathsSafely_Printf,$1,$2,$3,7001)
$(call ListPathsSafely_Printf,$1,$2,$3,7251)
$(call ListPathsSafely_Printf,$1,$2,$3,7501)
$(call ListPathsSafely_Printf,$1,$2,$3,7751)
$(call ListPathsSafely_Printf,$1,$2,$3,8001)
$(call ListPathsSafely_Printf,$1,$2,$3,8251)
$(call ListPathsSafely_Printf,$1,$2,$3,8501)
$(call ListPathsSafely_Printf,$1,$2,$3,8751)
$(call ListPathsSafely_Printf,$1,$2,$3,9001)
$(call ListPathsSafely_Printf,$1,$2,$3,9251)
$(call ListPathsSafely_Printf,$1,$2,$3,9501)
$(call ListPathsSafely_Printf,$1,$2,$3,9751)
$(call ListPathsSafely_Printf,$1,$2,$3,10001)
$(call ListPathsSafely_Printf,$1,$2,$3,10251)
$(call ListPathsSafely_Printf,$1,$2,$3,10501)
$(call ListPathsSafely_Printf,$1,$2,$3,10751)
$(call ListPathsSafely_Printf,$1,$2,$3,11001)
$(call ListPathsSafely_Printf,$1,$2,$3,11251)
$(call ListPathsSafely_Printf,$1,$2,$3,11501)
$(call ListPathsSafely_Printf,$1,$2,$3,11751)
$(call ListPathsSafely_Printf,$1,$2,$3,12001)
$(call ListPathsSafely_Printf,$1,$2,$3,12251)
$(call ListPathsSafely_Printf,$1,$2,$3,12501)
$(call ListPathsSafely_Printf,$1,$2,$3,12751)
$(call ListPathsSafely_Printf,$1,$2,$3,13001)
$(call ListPathsSafely_Printf,$1,$2,$3,13251)
$(call ListPathsSafely_Printf,$1,$2,$3,13501)
$(call ListPathsSafely_Printf,$1,$2,$3,13751)
$(call ListPathsSafely_Printf,$1,$2,$3,14001)
$(call ListPathsSafely_Printf,$1,$2,$3,14251)
$(call ListPathsSafely_Printf,$1,$2,$3,14501)
$(call ListPathsSafely_Printf,$1,$2,$3,14751)
$(call ListPathsSafely_Printf,$1,$2,$3,15001)
$(call ListPathsSafely_Printf,$1,$2,$3,15251)
$(call ListPathsSafely_Printf,$1,$2,$3,15501)
$(call ListPathsSafely_Printf,$1,$2,$3,15751)
endef
define ListPathsSafelyNow_IfPrintf
ifneq (,$$(word $4,$$($1)))
$$(eval $1_LPS$4:=$$(call compress_paths,$$(wordlist $4,$5,$$($1))))
$$(shell printf -- "$$(strip $$($1_LPS$4))\n" | $(decompress_paths) $3)
endif
endef
# And an non-receipt version:
define ListPathsSafelyNow
ifneq (,$$(word 10001,$$($1)))
$$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!)
endif
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1,250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,251,500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,501,750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,751,1000)
$$(call MakeDir, $$(dir $2))
ifneq ($$(strip $3), true)
$$(shell $(RM) $$(strip $2))
endif
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1001,1250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1251,1500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1501,1750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,1751,2000)
$$(call ListPathsSafely_IfPrintf,$1,$2,1,250)
$$(call ListPathsSafely_IfPrintf,$1,$2,251,500)
$$(call ListPathsSafely_IfPrintf,$1,$2,501,750)
$$(call ListPathsSafely_IfPrintf,$1,$2,751,1000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2001,2250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2251,2500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2501,2750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,2751,3000)
$$(call ListPathsSafely_IfPrintf,$1,$2,1001,1250)
$$(call ListPathsSafely_IfPrintf,$1,$2,1251,1500)
$$(call ListPathsSafely_IfPrintf,$1,$2,1501,1750)
$$(call ListPathsSafely_IfPrintf,$1,$2,1751,2000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3001,3250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3251,3500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3501,3750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,3751,4000)
$$(call ListPathsSafely_IfPrintf,$1,$2,2001,2250)
$$(call ListPathsSafely_IfPrintf,$1,$2,2251,2500)
$$(call ListPathsSafely_IfPrintf,$1,$2,2501,2750)
$$(call ListPathsSafely_IfPrintf,$1,$2,2751,3000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4001,4250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4251,4500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4501,4750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,4751,5000)
$$(call ListPathsSafely_IfPrintf,$1,$2,3001,3250)
$$(call ListPathsSafely_IfPrintf,$1,$2,3251,3500)
$$(call ListPathsSafely_IfPrintf,$1,$2,3501,3750)
$$(call ListPathsSafely_IfPrintf,$1,$2,3751,4000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5001,5250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5251,5500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5501,5750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,5751,6000)
$$(call ListPathsSafely_IfPrintf,$1,$2,4001,4250)
$$(call ListPathsSafely_IfPrintf,$1,$2,4251,4500)
$$(call ListPathsSafely_IfPrintf,$1,$2,4501,4750)
$$(call ListPathsSafely_IfPrintf,$1,$2,4751,5000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6001,6250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6251,6500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6501,6750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,6751,7000)
$$(call ListPathsSafely_IfPrintf,$1,$2,5001,5250)
$$(call ListPathsSafely_IfPrintf,$1,$2,5251,5500)
$$(call ListPathsSafely_IfPrintf,$1,$2,5501,5750)
$$(call ListPathsSafely_IfPrintf,$1,$2,5751,6000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7001,7250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7251,7500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7501,7750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,7751,8000)
$$(call ListPathsSafely_IfPrintf,$1,$2,6001,6250)
$$(call ListPathsSafely_IfPrintf,$1,$2,6251,6500)
$$(call ListPathsSafely_IfPrintf,$1,$2,6501,6750)
$$(call ListPathsSafely_IfPrintf,$1,$2,6751,7000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8001,8250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8251,8500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8501,8750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,8751,9000)
$$(call ListPathsSafely_IfPrintf,$1,$2,7001,7250)
$$(call ListPathsSafely_IfPrintf,$1,$2,7251,7500)
$$(call ListPathsSafely_IfPrintf,$1,$2,7501,7750)
$$(call ListPathsSafely_IfPrintf,$1,$2,7751,8000)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9001,9250)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9251,9500)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9501,9750)
$(call ListPathsSafelyNow_IfPrintf,$1,$2,$3,9751,10000)
$$(call ListPathsSafely_IfPrintf,$1,$2,8001,8250)
$$(call ListPathsSafely_IfPrintf,$1,$2,8251,8500)
$$(call ListPathsSafely_IfPrintf,$1,$2,8501,8750)
$$(call ListPathsSafely_IfPrintf,$1,$2,8751,9000)
$$(call ListPathsSafely_IfPrintf,$1,$2,9001,9250)
$$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500)
$$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
$$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
endef
endif # HAS_FILE_FUNCTION
# The source tips can come from the Mercurial repository, or in the files
# $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
@ -727,9 +577,14 @@ ReadFile = \
# 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" $(call ShellQuote, $1) > $2)
endif
################################################################################
# DependOnVariable
@ -767,15 +622,16 @@ DependOnVariableFileName = \
# Param 1 - Name of variable
# Param 2 - (optional) name of file to store value in
DependOnVariableHelper = \
$(strip $(if $(and $(wildcard $(call DependOnVariableFileName, $1, $2)),\
$(call equals, $(strip $($1)), \
$(call ReadFile, $(call DependOnVariableFileName, $1, $2)))),,\
$(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \
$(if $(findstring $(LOG_LEVEL), trace), \
$(info Variable $1: >$(strip $($1))<) \
$(info File: >$(call ReadFile, $(call DependOnVariableFileName, $1, $2))<)) \
$(call WriteFile, $($1), $(call DependOnVariableFileName, $1, $2))) \
$(call DependOnVariableFileName, $1, $2))
$(strip \
$(eval -include $(call DependOnVariableFileName, $1, $2)) \
$(if $(call equals, $(strip $($1)), $(strip $($1_old))),,\
$(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \
$(if $(findstring $(LOG_LEVEL), trace), \
$(info NewVariable $1: >$(strip $($1))<) \
$(info OldVariable $1: >$(strip $($1_old))<)) \
$(call WriteFile, $1_old:=$($1), $(call DependOnVariableFileName, $1, $2))) \
$(call DependOnVariableFileName, $1, $2) \
)
# Main macro
# Param 1 - Name of variable

View File

@ -211,23 +211,25 @@ define add_native_source
$(call LogFailures, $$($1_$2_OBJ).log, $$($1_SAFE_NAME)_$$(notdir $2), \
$$($1_$2_COMP) $$($1_$2_FLAGS) $$($1_$2_DEP_FLAG) $$($1_$2_DEP) $(CC_OUT_OPTION)$$($1_$2_OBJ) $2)
endif
# Create a dependency target file from the dependency file.
# Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
ifneq ($$($1_$2_DEP),)
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
endif
else
# The Visual Studio compiler lacks a feature for generating make dependencies, but by
# setting -showIncludes, all included files are printed. These are filtered out and
# parsed into make dependences.
# Keep as much as possible on one execution line for best performance on Windows
($(call LogFailures, $$($1_$2_OBJ).log, $$($1_SAFE_NAME)_$$(notdir $2), \
$$($1_$2_COMP) $$($1_$2_FLAGS) -showIncludes $$($1_$2_DEBUG_OUT_FLAGS) \
$(CC_OUT_OPTION)$$($1_$2_OBJ) $2) ; echo $$$$? > $$($1_$2_DEP).exitvalue) \
| $(TEE) $$($1_$2_DEP).raw | $(GREP) -v -e "^Note: including file:" \
-e "^$(notdir $2)$$$$" || test "$$$$?" = "1" ; \
exit `cat $$($1_$2_DEP).exitvalue`
$(RM) $$($1_$2_DEP).exitvalue
($(ECHO) $$@: \\ \
&& $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) | $(SORT) -u > $$($1_$2_DEP)
endif
# Create a dependency target file from the dependency file.
# Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
ifneq ($$($1_$2_DEP),)
exit `cat $$($1_$2_DEP).exitvalue` ; \
$(RM) $$($1_$2_DEP).exitvalue ; \\
($(ECHO) $$@: \\ ; \
$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) | $(SORT) -u > $$($1_$2_DEP) ; \
$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
endif
endif
@ -628,6 +630,10 @@ define SetupNativeCompilationBody
"-map:$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map"
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).pdb \
$$($1_OBJECT_DIR)/$$($1_NOSUFFIX).map
# No separate command is needed for debuginfo on windows, instead
# touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
$1_CREATE_DEBUGINFO_CMDS := $(TOUCH) $$($1_TARGET)
else ifneq ($(findstring $(OPENJDK_TARGET_OS), linux solaris), )
$1_DEBUGINFO_FILES := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).debuginfo
@ -678,18 +684,13 @@ define SetupNativeCompilationBody
$$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_REAL_MAPFILE) \
$$($1_VARDEPS_FILE)
$(ECHO) $(LOG_INFO) "Linking $$($1_BASENAME)"
$(ECHO) $(LOG_INFO) "Linking $$($1_BASENAME)" ; \
$(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
$(LD_OUT_OPTION)$$@ \
$$($1_EXPECTED_OBJS) $$($1_RES) \
$$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX))
$$($1_LDFLAGS_SUFFIX) $$($1_EXTRA_LDFLAGS_SUFFIX)) ; \
$$($1_CREATE_DEBUGINFO_CMDS)
# Touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
ifeq ($(OPENJDK_TARGET_OS), windows)
$(TOUCH) $$@
endif
endif
@ -719,7 +720,7 @@ define SetupNativeCompilationBody
$$($1_TARGET): $$($1_EXPECTED_OBJS) $$($1_RES) $$($1_MANIFEST) \
$$($1_VARDEPS_FILE)
$(ECHO) $(LOG_INFO) "Linking executable $$($1_BASENAME)"
$(ECHO) $(LOG_INFO) "Linking executable $$($1_BASENAME)" ; \
$(call LogFailures, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link.log, $$($1_SAFE_NAME)_link, \
$$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
$(EXE_OUT_OPTION)$$($1_TARGET) \
@ -738,11 +739,6 @@ define SetupNativeCompilationBody
endif
endif
$$($1_CREATE_DEBUGINFO_CMDS)
# Touch target to make sure it has a later time stamp than the debug
# symbol files to avoid unnecessary relinking on rebuild.
ifeq ($(OPENJDK_TARGET_OS), windows)
$(TOUCH) $$@
endif
endif
endef

View File

@ -213,23 +213,20 @@ VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
VARDEP_TEST_VAR2 := value3
VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
ifneq ($(VARDEP_VALUE_FILE), $(VARDEP_RETURN_VALUE))
$(error Expected: $(VARDEP_VALUE_FILE) - DependOnVariable: $(VARDEP_RETURN_VALUE))
endif
$(eval $(call assert-equals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
Wrong filename returned))
VARDEP_FILE_CONTENTS := $(shell $(CAT) $(VARDEP_VALUE_FILE))
ifneq ($(VARDEP_TEST_VAR2), $(VARDEP_FILE_CONTENTS))
$(error Expected: $(VARDEP_TEST_VAR2) - DependOnVariable file contained: \
$(VARDEP_FILE_CONTENTS))
endif
$(eval $(call assert-equals, $(VARDEP_FILE_CONTENTS), \
VARDEP_TEST_VAR2_old:=$(VARDEP_TEST_VAR2), \
Wrong contents in vardeps file))
# Test with a variable value containing some problematic characters
VARDEP_TEST_VAR3 := foo '""' "''" bar
VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
VARDEP_FILE_CONTENTS := $(shell $(CAT) $(VARDEP_VALUE_FILE))
ifneq ($(VARDEP_TEST_VAR3), $(VARDEP_FILE_CONTENTS))
$(error Expected: >$(VARDEP_TEST_VAR3)< - DependOnVariable file contained: \
>$(VARDEP_FILE_CONTENTS)<)
endif
$(eval $(call assert-equals, $(VARDEP_FILE_CONTENTS), \
VARDEP_TEST_VAR3_old:=$(VARDEP_TEST_VAR3), \
Wrong contents in vardep file))
TEST_TARGETS += test-vardep