Fixed bug in implicit rule prerequisite evaluation code. Added test.

This commit is contained in:
Boris Kolpackov 2004-09-21 20:23:12 +00:00
parent 6e51d9c90a
commit 73e7767ffc
6 changed files with 86 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2004-09-21 Boris Kolpackov <boris@kolpackov.net>
* file.c (snap_deps): Mark .PHONY prerequisites as targets.
* implicit.c (pattern_search): When considering an implicit rule's
prerequisite check that it is actually a target rather then
just an entry in the file hashtable.
2004-09-21 Paul D. Smith <psmith@gnu.org>
* read.c (readstring): Fix some logic errors in backslash handling.

3
file.c
View File

@ -455,8 +455,9 @@ snap_deps (void)
for (d = f->deps; d != 0; d = d->next)
for (f2 = d->file; f2 != 0; f2 = f2->prev)
{
/* Mark this file as phony and nonexistent. */
/* Mark this file as phony nonexistent target. */
f2->phony = 1;
f2->is_target = 1;
f2->last_mtime = NONEXISTENT_MTIME;
f2->mtime_before_update = NONEXISTENT_MTIME;
}

View File

@ -342,6 +342,8 @@ pattern_search (struct file *file, int archive,
deps_found = 0;
for (dep = rule->deps; dep != 0; dep = dep->next)
{
struct file *f;
/* If the dependency name has a %, substitute the stem. */
p = strchr (dep_name (dep), '%');
if (p != 0)
@ -396,7 +398,7 @@ pattern_search (struct file *file, int archive,
directory (the one gotten by prepending FILENAME's directory),
so it might actually exist. */
if (lookup_file (p) != 0
if (((f = lookup_file (p)) != 0 && f->is_target)
|| ((!dep->changed || check_lastslash) && file_exists_p (p)))
{
found_files_im[deps_found] = dep->ignore_mtime;

View File

@ -1,3 +1,11 @@
2004-09-21 Boris Kolpackov <boris@kolpackov.net>
* run_make_tests.pl: Change `#!/usr/local/bin/perl' to be
`#!/usr/bin/env perl'.
* scripts/features/implicit_prereq_eval: Test implicit rule
prerequisite evaluation code.
2004-09-21 Paul D. Smith <psmith@gnu.org>
* run_make_tests.pl (run_make_test): Enhance to allow the make

View File

@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# -*-perl-*-
# Test driver for the Make test suite

View File

@ -0,0 +1,64 @@
$description = "Test implicit rule prerequisite evaluation code.";
$details = "The makefile created by this test has a set of implicit rule
pairs with the first rule usually not applying because its prerequisites
cannot be made and the second rule which should succeed.";
open(MAKEFILE,"> $makefile");
# The contents of the Makefile ...
print MAKEFILE <<EOF;
.PHONY: all
all: case.1 case.2 case.3
a: void
# 1 - existing file
#
%.1: void
\@false
%.1: $makefile
\@true
# 2 - phony
#
%.2: void
\@false
%.2: 2.phony
\@true
.PHONY: 2.phony
# 3 - implicit-phony
#
%.3: void
\@false
%.3: 3.implicit-phony
\@true
3.implicit-phony:
EOF
close(MAKEFILE);
&run_make_with_options($makefile,
"",
&get_logfile,
0);
# This makefile doesn't produce anything except exit code.
#
&compare_output("",&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1;