8249292: DependOnVariable macro fails on empty value
Reviewed-by: tbell
This commit is contained in:
parent
ee1efed55d
commit
c83ce2e8d9
@ -484,7 +484,7 @@ endif
|
||||
# Defines the sub directory structure to store variable value file in
|
||||
DependOnVariableDirName = \
|
||||
$(strip $(addsuffix $(if $(MODULE),/$(MODULE)), \
|
||||
$(subst $(TOPDIR)/,, $(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \
|
||||
$(subst $(WORKSPACE_ROOT)/,, $(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \
|
||||
$(firstword $(MAKEFILE_LIST)), \
|
||||
$(CURDIR)/$(firstword $(MAKEFILE_LIST))))))
|
||||
|
||||
@ -496,6 +496,13 @@ DependOnVariableFileName = \
|
||||
$(strip $(if $(strip $2), $2, \
|
||||
$(MAKESUPPORT_OUTPUTDIR)/vardeps/$(DependOnVariableDirName)/$(strip $1).vardeps))
|
||||
|
||||
# Writes the vardeps file. Assumes $1_filename has been setup
|
||||
# Param 1 - Name of variable
|
||||
DependOnVariableWriteFile = \
|
||||
$(call MakeDir, $(dir $($1_filename))) \
|
||||
$(call WriteFile, $1_old:=$(call DoubleDollar,$(call EscapeHash,$($1))), \
|
||||
$($1_filename)) \
|
||||
|
||||
# Does the actual work with parameters stripped.
|
||||
# If the file exists AND the contents is the same as the variable, do nothing
|
||||
# else print a new file.
|
||||
@ -505,14 +512,18 @@ DependOnVariableFileName = \
|
||||
DependOnVariableHelper = \
|
||||
$(strip \
|
||||
$(eval $1_filename := $(call DependOnVariableFileName, $1, $2)) \
|
||||
$(if $(wildcard $($1_filename)), $(eval include $($1_filename))) \
|
||||
$(if $(call equals, $(strip $($1)), $(strip $($1_old))),,\
|
||||
$(call MakeDir, $(dir $($1_filename))) \
|
||||
$(if $(findstring $(LOG_LEVEL), trace), \
|
||||
$(info NewVariable $1: >$(strip $($1))<) \
|
||||
$(info OldVariable $1: >$(strip $($1_old))<)) \
|
||||
$(call WriteFile, $1_old:=$(call DoubleDollar,$(call EscapeHash,$($1))), \
|
||||
$($1_filename))) \
|
||||
$(if $(wildcard $($1_filename)), \
|
||||
$(eval include $($1_filename)) \
|
||||
$(if $(call equals, $(strip $($1)), $(strip $($1_old))),,\
|
||||
$(if $(findstring $(LOG_LEVEL), trace), \
|
||||
$(info NewVariable $1: >$(strip $($1))<) \
|
||||
$(info OldVariable $1: >$(strip $($1_old))<) \
|
||||
) \
|
||||
$(call DependOnVariableWriteFile,$1) \
|
||||
) \
|
||||
, \
|
||||
$(call DependOnVariableWriteFile,$1) \
|
||||
) \
|
||||
$($1_filename) \
|
||||
)
|
||||
|
||||
|
@ -179,11 +179,11 @@ VARDEP_SRC_FILE := $(VARDEP_DIR)/src-file
|
||||
VARDEP_TARGET_FILE := $(VARDEP_DIR)/target-file
|
||||
VARDEP_FLAG_FILE := $(VARDEP_DIR)/flag-file
|
||||
|
||||
$(VARDEP_DIR)/src-file:
|
||||
$(VARDEP_SRC_FILE):
|
||||
$(MKDIR) -p $(@D)
|
||||
$(ECHO) "some string XXX" > $@
|
||||
|
||||
$(VARDEP_TARGET_FILE): $(VARDEP_DIR)/src-file \
|
||||
$(VARDEP_TARGET_FILE): $(VARDEP_SRC_FILE) \
|
||||
$(call DependOnVariable, VARDEP_TEST_VAR)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(SED) -e 's/XXX/$(VARDEP_TEST_VAR)/g' $< > $@
|
||||
@ -233,6 +233,31 @@ test-vardep:
|
||||
$(RM) $(VARDEP_FLAG_FILE)
|
||||
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
|
||||
test ! -e $(VARDEP_FLAG_FILE)
|
||||
#
|
||||
# Test having the variable be empty, first from scratch, with even
|
||||
# the vardep file deleted.
|
||||
$(SLEEP_ON_MAC)
|
||||
$(RM) $(VARDEP_FLAG_FILE) $(VARDEP_TARGET_FILE) \
|
||||
$(call DependOnVariableFileName,VARDEP_TEST_VAR)
|
||||
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
|
||||
$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test -e $(VARDEP_FLAG_FILE)
|
||||
#
|
||||
# Then rebuild with same empty value, nothing should happen
|
||||
$(SLEEP_ON_MAC)
|
||||
$(RM) $(VARDEP_FLAG_FILE)
|
||||
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
|
||||
$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test ! -e $(VARDEP_FLAG_FILE)
|
||||
#
|
||||
# Try setting a value again and verify that the target gets rebuilt
|
||||
$(SLEEP_ON_MAC)
|
||||
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
|
||||
$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
|
||||
test -e $(VARDEP_FLAG_FILE)
|
||||
|
||||
# Test specifying a specific value file to store variable in
|
||||
VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
|
||||
|
Loading…
Reference in New Issue
Block a user