mirror of
https://github.com/mirror/make.git
synced 2025-01-27 12:51:07 +08:00
Moved expansion of simple pattern-specific variables from the rebuild stage
to the read stage.
This commit is contained in:
parent
fb6410f435
commit
b0d67e0e15
@ -1,3 +1,10 @@
|
||||
2004-10-05 Boris Kolpackov <boris@kolpackov.net>
|
||||
|
||||
* read.c (record_target_var): Expand simple pattern-specific
|
||||
variable.
|
||||
* variable.c (initialize_file_variables): Do not expand simple
|
||||
pattern-specific variable.
|
||||
|
||||
2004-09-28 Boris Kolpackov <boris@kolpackov.net>
|
||||
|
||||
* remake.c (update_file_1): When rebuilding makefiles inherit
|
||||
|
7
read.c
7
read.c
@ -1675,7 +1675,12 @@ record_target_var (struct nameseq *filenames, char *defn,
|
||||
variable definition. */
|
||||
v = parse_variable_definition (&p->variable, defn);
|
||||
assert (v != 0);
|
||||
v->value = xstrdup (v->value);
|
||||
|
||||
if (v->flavor == f_simple)
|
||||
v->value = allocated_variable_expand (v->value);
|
||||
else
|
||||
v->value = xstrdup (v->value);
|
||||
|
||||
fname = p->target;
|
||||
}
|
||||
else
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-10-05 Boris Kolpackov <boris@kolpackov.net>
|
||||
|
||||
* scripts/features/patspecific_vars: Test simple/recursive
|
||||
variable expansion.
|
||||
|
||||
2004-09-28 Boris Kolpackov <boris@kolpackov.net>
|
||||
|
||||
* scripts/features/include: Test dontcare flag inheritance
|
||||
|
@ -70,4 +70,55 @@ run_make_test('
|
||||
@test "$(foo)" == "$$foo"
|
||||
', '', '');
|
||||
|
||||
|
||||
# TEST #6 -- test expansion of pattern-specific simple variables
|
||||
#
|
||||
run_make_test('
|
||||
.PHONY: all
|
||||
|
||||
all: inherit := good $$t
|
||||
all: bar baz
|
||||
|
||||
b%: pattern := good $$t
|
||||
|
||||
global := orginal $$t
|
||||
|
||||
|
||||
# normal target
|
||||
#
|
||||
ifdef rec
|
||||
bar: a = global: $(global) pattern: $(pattern) inherit: $(inherit)
|
||||
else
|
||||
bar: a := global: $(global) pattern: $(pattern) inherit: $(inherit)
|
||||
endif
|
||||
|
||||
bar: ; @echo \'normal: $a;\'
|
||||
|
||||
|
||||
# pattern target
|
||||
#
|
||||
ifdef rec
|
||||
%z: a = global: $(global) pattern: $(pattern) inherit: $(inherit)
|
||||
else
|
||||
%z: a := global: $(global) pattern: $(pattern) inherit: $(inherit)
|
||||
endif
|
||||
|
||||
%z: ; @echo \'pattrn: $a;\'
|
||||
|
||||
|
||||
global := new $$t
|
||||
',
|
||||
'',
|
||||
'normal: global: orginal $t pattern: inherit: ;
|
||||
pattrn: global: orginal $t pattern: inherit: ;');
|
||||
|
||||
|
||||
# TEST #7 -- test expansion of pattern-specific recursive variables
|
||||
#
|
||||
run_make_test(undef, # reuse previous makefile
|
||||
'rec=1',
|
||||
'normal: global: new $t pattern: good $t inherit: good $t;
|
||||
pattrn: global: new $t pattern: good $t inherit: good $t;');
|
||||
|
||||
|
||||
1;
|
||||
|
23
variable.c
23
variable.c
@ -495,10 +495,25 @@ initialize_file_variables (struct file *file, int reading)
|
||||
do
|
||||
{
|
||||
/* We found one, so insert it into the set. */
|
||||
struct variable *v = do_variable_definition (
|
||||
&p->variable.fileinfo, p->variable.name,
|
||||
p->variable.value, p->variable.origin,
|
||||
p->variable.flavor, 1);
|
||||
|
||||
struct variable *v;
|
||||
|
||||
if (p->variable.flavor == f_simple)
|
||||
{
|
||||
v = define_variable_loc (
|
||||
p->variable.name, strlen (p->variable.name),
|
||||
p->variable.value, p->variable.origin,
|
||||
0, &p->variable.fileinfo);
|
||||
|
||||
v->flavor = f_simple;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = do_variable_definition (
|
||||
&p->variable.fileinfo, p->variable.name,
|
||||
p->variable.value, p->variable.origin,
|
||||
p->variable.flavor, 1);
|
||||
}
|
||||
|
||||
/* Also mark it as a per-target and copy export status. */
|
||||
v->per_target = p->variable.per_target;
|
||||
|
Loading…
Reference in New Issue
Block a user