8140484: Vardeps broken when variable value contains '$'
authorerikj
Tue, 27 Oct 2015 13:48:21 +0100
changeset 33054 bcb9f5ea5761
parent 33053 da30e97b39ed
child 33055 3676b99f33cf
8140484: Vardeps broken when variable value contains '$' Reviewed-by: tbell
make/common/MakeBase.gmk
test/make/TestMakeBase.gmk
--- a/make/common/MakeBase.gmk	Thu Oct 22 11:12:30 2015 -0700
+++ b/make/common/MakeBase.gmk	Tue Oct 27 13:48:21 2015 +0100
@@ -640,7 +640,8 @@
           $(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 WriteFile, $1_old:=$(call DoubleDollar,$($1)), \
+              $(call DependOnVariableFileName, $1, $2))) \
         $(call DependOnVariableFileName, $1, $2) \
     )
 
--- a/test/make/TestMakeBase.gmk	Thu Oct 22 11:12:30 2015 -0700
+++ b/test/make/TestMakeBase.gmk	Tue Oct 27 13:48:21 2015 +0100
@@ -207,6 +207,12 @@
 	test ! -e $(VARDEP_FLAG_FILE)
 	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=" value3  foo" $(VARDEP_TARGET_FILE)
 	test ! -e $(VARDEP_FLAG_FILE)
+        #
+        # Test including some problematic characters
+	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$$$ORIGIN' $(VARDEP_TARGET_FILE)
+	$(RM) $(VARDEP_FLAG_FILE)
+	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$$$ORIGIN' $(VARDEP_TARGET_FILE)
+	test ! -e $(VARDEP_FLAG_FILE)
 
 # Test specifying a specific value file to store variable in
 VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
@@ -215,17 +221,15 @@
 VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
 $(eval $(call assert-equals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
     Wrong filename returned))
-VARDEP_FILE_CONTENTS := $(shell $(CAT) $(VARDEP_VALUE_FILE))
-$(eval $(call assert-equals, $(VARDEP_FILE_CONTENTS), \
-    VARDEP_TEST_VAR2_old:=$(VARDEP_TEST_VAR2), \
+-include $(VARDEP_VALUE_FILE)
+$(eval $(call assert-equals, $(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_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN
 VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
-VARDEP_FILE_CONTENTS := $(shell $(CAT) $(VARDEP_VALUE_FILE))
-$(eval $(call assert-equals, $(VARDEP_FILE_CONTENTS), \
-    VARDEP_TEST_VAR3_old:=$(VARDEP_TEST_VAR3), \
+-include $(VARDEP_VALUE_FILE)
+$(eval $(call assert-equals, $(VARDEP_TEST_VAR3_old), $(VARDEP_TEST_VAR3), \
     Wrong contents in vardep file))
 
 TEST_TARGETS += test-vardep