[SV 45728] Detect changes in .VARIABLES more accurately.

For performance, we only recompute .VARIABLES when (a) it's expanded
and (b) when its value will change from a previous expansion.  To
determine (b) we were checking the number of entries in the hash
table which used to work until we started undefining entries: now if
you undefine and redefine the same number of entries in between
expanding .VARIABLES, it doesn't detect any change.  Instead, keep
an increasing change number.
* variables.c: Add variable_changenum.
(define_variable_in_set, merge_variable_sets): Increment
variable_changenum if adding a new variable to the global set.
(undefine_variable_in_set): Increment variable_changenum if
undefining a variable from the global set.
(lookup_special_var): Test variable_changenum not the hash table.
* tests/scripts/variables/special: Test undefining variables.
This commit is contained in:
Paul Smith
2016-03-13 18:13:00 -04:00
parent 247b71e690
commit 9ae02b7916
2 changed files with 49 additions and 32 deletions

View File

@@ -14,14 +14,22 @@ X2 := $(sort $(filter FOO BAR,$(.VARIABLES)))
BAR := bar
all:
@echo X1 = $(X1)
@echo X2 = $(X2)
@echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
all: ; @echo X1 = $(X1); echo X2 = $(X2); echo LAST = $(sort $(filter FOO BAR,$(.VARIABLES)))
',
'', "X1 =\nX2 = FOO\nLAST = BAR FOO\n");
# SV 45728: Test that undefining a variable is reflected properly
&run_make_test('
FOO := foo
BAR := bar
$(info one: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
undefine BAR
BAZ := baz
$(info two: $(sort $(filter FOO BAR BAZ,$(.VARIABLES))))
all:;@:
',
'', "one: BAR FOO\ntwo: BAZ FOO\n");
# $makefile2 = &get_tmpfile;
# open(MAKEFILE, "> $makefile2");
@@ -31,9 +39,9 @@ all:
# X1 := $(sort $(.TARGETS))
# all: foo
# @echo X1 = $(X1)
# @echo X2 = $(X2)
# @echo LAST = $(sort $(.TARGETS))
# @echo X1 = $(X1)
# @echo X2 = $(X2)
# @echo LAST = $(sort $(.TARGETS))
# X2 := $(sort $(.TARGETS))
@@ -56,16 +64,16 @@ define foo
: foo-one\
foo-two
: foo-three
: foo-four
: foo-four
endef
orig: ; : orig-one
: orig-two \
: orig-two \
orig-three \
orig-four \
orig-five \\\\
: orig-six
$(foo)
orig-four \
orig-five \\\\
: orig-six
$(foo)
.RECIPEPREFIX = >
test: ; : test-one
@@ -78,19 +86,19 @@ test-three \
.RECIPEPREFIX =
reset: ; : reset-one
: reset-two \
: reset-two \
reset-three \
reset-four \
reset-five \\\\
: reset-six
$(foo)
reset-four \
reset-five \\\\
: reset-six
$(foo)
',
'orig test reset',
': orig-one
: orig-two \
orig-three \
orig-four \
orig-five \\\\
orig-five \\\\
: orig-six
: foo-one foo-two
: foo-three
@@ -99,7 +107,7 @@ orig-four \
: test-two \
test-three \
test-four \
test-five \\\\
test-five \\\\
: test-six
: foo-one foo-two
: foo-three
@@ -108,7 +116,7 @@ test-four \
: reset-two \
reset-three \
reset-four \
reset-five \\\\
reset-five \\\\
: reset-six
: foo-one foo-two
: foo-three