mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-28 15:57:48 +00:00
4e12a5fa45
Initial implementation by Christof Warlich <cwarlich@gmx.de> * NEWS: Announce the new feature. * doc/make.texi (Other Special Variables): Document .EXTRA_PREREQS. * src/dep.h (struct dep): New flag to note extra prereq deps. * src/filedef.h (expand_extra_prereqs): Declare a function to expand the value of .EXTRA_PREREQS. * src/file.c (expand_extra_prereqs): Given a struct variable lookup of .EXTRA_PREREQS, convert it into a list of deps and for each one make sure it has a struct file and has the new flag set. (snap_file): A new function invoked by hash_map that will perform per-file operations: set up second expansion, intermediate, and also .EXTRA_PREREQS. Manage circular dependencies by ignoring them. (snap_deps): Defer per-file operations until the end. Look up the global .EXTRA_PREREQS and pass it along to snap_file for each file. * src/implicit.c (struct patdeps): Remember the extra prereqs flag. (pattern_search): Transfer extra prereqs flag settings into the matched pattern rule. * src/rule.h (snap_implicit_rules): Rename count_implicit_rules to snap_implicit_rules since we now do more than count. * src/rule.c (snap_implicit_rules): As we walk through all the pattern rules, add in any global .EXTRA_PREREQS to the dep list. Ensure we take them into account for the max number of prereqs and name length. * src/main.c (main): Add extra-prereqs to .FEATURES. Call the renamed snap_implicit_rules. * tests/scripts/variables/EXTRA_PREREQS: Add tests.
151 lines
4.6 KiB
Perl
151 lines
4.6 KiB
Perl
# -*-perl-*-
|
|
|
|
$description = "Test the .EXTRA_PREREQS special variable.";
|
|
$details = "";
|
|
|
|
# Simple global .EXTRA_PREREQS and automatic variable settings
|
|
run_make_test('
|
|
.EXTRA_PREREQS = tick tack
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
|
|
tick tack: ; @echo $@
|
|
',
|
|
'', "tick\ntack\ntick tack/all///////\n");
|
|
|
|
# Global .EXTRA_PREREQS and pattern rules
|
|
run_make_test('
|
|
.EXTRA_PREREQS = tick tack
|
|
a%: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
|
|
tick tack: ; @echo $@
|
|
',
|
|
'all', "tick\ntack\ntick tack/all//////ll/\n");
|
|
|
|
# Simple target-specific .EXTRA_PREREQS and automatic variable settings
|
|
run_make_test('
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
|
|
all: .EXTRA_PREREQS = tick tack
|
|
tick tack: ; @echo $@
|
|
',
|
|
'', "tick\ntack\ntick tack/all///////\n");
|
|
|
|
# Simple pattern-specific .EXTRA_PREREQS and automatic variable settings
|
|
# This is not currently supported :-/
|
|
if (0) {
|
|
run_make_test('
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS}/$@/$</$^/$?/$+/$|/$*/
|
|
a%: .EXTRA_PREREQS = tick tack
|
|
tick tack: ; @echo $@
|
|
',
|
|
'', "tick\ntack\ntick tack/all///////\n");
|
|
}
|
|
|
|
touch('hi');
|
|
|
|
# Basic test target specific .EXTRA_PREREQS:
|
|
run_make_test('
|
|
DEPENDENCY_ONLY_PREREQUISITES = ho hey
|
|
OTHER_PREREQUISITES := foo bar baz
|
|
target: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
|
|
target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
|
|
.PHONY: target ${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES}
|
|
${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES}: ; @echo $@
|
|
',
|
|
'', "foo\nbar\nbaz\nho\nhey\nhi ho hey foo bar baz\n");
|
|
|
|
# Test target specific .EXTRA_PREREQS and pattern rules:
|
|
run_make_test('
|
|
all: target.dst
|
|
DEPENDENCY_ONLY_PREREQUISITES = ho hey
|
|
target.dst: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
|
|
%.dst: %.src ; @echo ${.EXTRA_PREREQS} $^
|
|
.PHONY: ${DEPENDENCY_ONLY_PREREQUISITES} target.src
|
|
${DEPENDENCY_ONLY_PREREQUISITES} target.src: ; @echo $@
|
|
',
|
|
'', "target.src\nho\nhey\nhi ho hey target.src\n");
|
|
|
|
# Test that global .EXTRA_PREREQS are built first:
|
|
run_make_test('
|
|
.EXTRA_PREREQS = hi ho hey
|
|
OTHER_PREREQUISITES := foo bar baz
|
|
target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
|
|
.PHONY: target ${.EXTRA_PREREQS} ${OTHER_PREREQUISITES}
|
|
${.EXTRA_PREREQS} ${OTHER_PREREQUISITES}: ; @echo $@
|
|
',
|
|
'', "hi\nho\nhey\nfoo\nbar\nbaz\nhi ho hey foo bar baz\n");
|
|
|
|
# Test that target specific .EXTRA_PREREQS override global .EXTRA_PREREQS:
|
|
run_make_test('
|
|
.EXTRA_PREREQS = tick tack
|
|
DEPENDENCY_ONLY_PREREQUISITES = ho hey
|
|
OTHER_PREREQUISITES := foo bar baz
|
|
target: .EXTRA_PREREQS := hi ${DEPENDENCY_ONLY_PREREQUISITES}
|
|
target: ${OTHER_PREREQUISITES} ; @echo ${.EXTRA_PREREQS} $^
|
|
.PHONY: target ${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES} ${.EXTRA_PREREQS}
|
|
${DEPENDENCY_ONLY_PREREQUISITES} ${OTHER_PREREQUISITES} ${.EXTRA_PREREQS}: ; @echo $@
|
|
',
|
|
'', "tick\ntack\nfoo\nbar\nbaz\nho\nhey\nhi ho hey foo bar baz\n");
|
|
|
|
# Cleanup:
|
|
unlink('hi');
|
|
|
|
# Test error reporting of global .EXTRA_PREREQS:
|
|
run_make_test('
|
|
.EXTRA_PREREQS = tick tack
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS} $^
|
|
',
|
|
'', "#MAKE#: *** No rule to make target 'tick', needed by 'all'. Stop.", 512);
|
|
|
|
# Test error reporting of global .EXTRA_PREREQS and keep-going:
|
|
run_make_test('
|
|
.EXTRA_PREREQS = tick tack
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS} $^
|
|
',
|
|
'-k', "#MAKE#: *** No rule to make target 'tick', needed by 'all'.\n#MAKE#: *** No rule to make target 'tack', needed by 'all'.\n#MAKE#: Target 'all' not remade because of errors.", 512);
|
|
|
|
# Test error reporting of target specific .EXTRA_PREREQS and keep-going:
|
|
run_make_test('
|
|
all: .EXTRA_PREREQS = tick tack
|
|
.PHONY: all
|
|
all: ; @echo ${.EXTRA_PREREQS} $^
|
|
',
|
|
'-k',
|
|
"#MAKE#: *** No rule to make target 'tick', needed by 'all'.
|
|
#MAKE#: *** No rule to make target 'tack', needed by 'all'.
|
|
#MAKE#: Target 'all' not remade because of errors.\n", 512);
|
|
|
|
# Test wildcard
|
|
|
|
touch('tick', 'tack');
|
|
|
|
run_make_test('
|
|
.EXTRA_PREREQS = *ck
|
|
.PHONY: all tick tack
|
|
all: ; @echo ${.EXTRA_PREREQS} $^
|
|
tick tack: ; @echo $@
|
|
',
|
|
'', "tack\ntick\ntack tick\n");
|
|
|
|
run_make_test('
|
|
.PHONY: all tick tack
|
|
all: ; @echo ${.EXTRA_PREREQS} $^
|
|
all: .EXTRA_PREREQS = *ck
|
|
tick tack: ; @echo $@
|
|
',
|
|
'', "tack\ntick\ntack tick\n");
|
|
|
|
run_make_test('
|
|
.PHONY: tick tack
|
|
a%: ; @echo ${.EXTRA_PREREQS} $^
|
|
.EXTRA_PREREQS = *ck
|
|
tick tack: ; @echo $@
|
|
',
|
|
'all', "tack\ntick\ntack tick\n");
|
|
|
|
unlink('tick', 'tack');
|
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
1;
|