[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `-f' ignored? autom4te.cache issue?
From: |
Akim Demaille |
Subject: |
Re: `-f' ignored? autom4te.cache issue? |
Date: |
16 Oct 2002 19:06:35 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
Actually, the patch I apply is the following. There were still things
that I had not properly understood in up_to_date. Now it looks like:
+ while ($_ = $deps->getline)
+ {
+ chomp;
+ my $file = find_file ("$_?", @include);
+ # If a file which used to be included is no longer there, then
+ # don't say it's missing (it might no longer be included). But
+ # of course, that cause the output to be outdated (as if the
+ # time stamp of that missing file was newer).
+ return 0
+ if ! $file;
+ push @dep, $file;
+ }
I must say that I'm quite bothered by:
/tmp % echo "include(I don't exist)" >foo.m4 nostromo 19:03
/tmp % autom4te foo.m4; echo $? nostromo 19:03
/usr/local/bin/m4: foo.m4: 1: Cannot open I don't exist: No such file or
directory
0
but I'm not sure how this M4 bug should be worked around :(
Redefining m4_include? But how can I test? First run test -f???
Nope, since that does not take the path into account. m4_sysval isn't
set either :( :( :(
Index: ChangeLog
from Akim Demaille <address@hidden>
Because of caching, some files that no longer exist and are no
longer required can still cause errors.
Reported by Alexandre Duret-Lutz.
* bin/autom4te.in (&parse_args): Do not prepend `--reload-state'
to frozen files in @ARGV, as @ARGV must remain being a list of
files. Rather, at M4 call sites, use this...
(&files_to_options): New function.
(&freeze): Use &error.
(&up_to_date): If a file that was included according to the cache
is no longer there, then the output is out dated.
(&main): Don't even check whether a file is up to date is anyway
--force is given.
* tests/tools.at (autom4te cache): New.
Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.71
diff -u -u -r1.71 autom4te.in
--- bin/autom4te.in 8 Oct 2002 23:04:33 -0000 1.71
+++ bin/autom4te.in 16 Oct 2002 17:02:03 -0000
@@ -419,6 +419,30 @@
## ---------- ##
+# $OPTION
+# files_to_options (@FILE)
+# ------------------------
+# Transform Autom4te conventions (e.g., using foo.m4f to designate a frozen
+# file) into a suitable command line for M4 (e.g., using --reload-state).
+sub files_to_options (@)
+{
+ my (@file) = @_;
+ my @res;
+ foreach my $file (@file)
+ {
+ if ($file =~ /\.m4f$/)
+ {
+ push @res, "--reload-state=$file";
+ }
+ else
+ {
+ push @res, $file;
+ }
+ }
+ return join ' ', @res;
+}
+
+
# load_configuration ()
# ---------------------
# Load the configuration file.
@@ -562,7 +586,7 @@
my $file = find_file ("$_?", @include);
if (!$melt && $file)
{
- @argv = ("--reload-state=$file");
+ @argv = ($file);
}
else
{
@@ -610,7 +634,7 @@
. ' --debug=aflq'
. " --error-output=$tcache" . $req->id . "t"
. join (' --trace=', '', sort @macro)
- . " @ARGV"
+ . " " . files_to_options (@ARGV)
. ' </dev/null'
. " >$ocache" . $req->id . "t");
@@ -1028,7 +1052,18 @@
('include' => '$1',
'm4_include' => '$1'));
my $deps = new Autom4te::XFile ("$tmp/dependencies");
- push @dep, map { chomp; find_file ($_, @include) } $deps->getlines;
+ while ($_ = $deps->getline)
+ {
+ chomp;
+ my $file = find_file ("$_?", @include);
+ # If a file which used to be included is no longer there, then
+ # don't say it's missing (it might no longer be included). But
+ # of course, that cause the output to be outdated (as if the
+ # time stamp of that missing file was newer).
+ return 0
+ if ! $file;
+ push @dep, $file;
+ }
# If $FILE is younger than one of its dependencies, it is outdated.
return up_to_date_p ($file, @dep);
@@ -1051,15 +1086,13 @@
. ' --fatal-warning'
. join (' --include=', '', @include)
. ' --define=divert'
- . " @ARGV"
+ . " " . files_to_options (@ARGV)
. ' </dev/null');
$result =~ s/#.*\n//g;
$result =~ s/^\n//mg;
- if ($result)
- {
- print STDERR "$me: freezing produced output:\n$result";
- exit 1;
- }
+
+ error "freezing produced output:\n$result"
+ if $result;
# If freezing produces output, something went wrong: a bad `divert',
# or an improper paren etc.
@@ -1067,7 +1100,7 @@
. ' --fatal-warning'
. join (' --include=', '', @include)
. " --freeze-state=$output"
- . " @ARGV"
+ . " " . files_to_options (@ARGV)
. ' </dev/null');
}
@@ -1104,16 +1137,13 @@
'path' => address@hidden,
'macro' => [keys %trace, @preselect]);
-# If $REQ's cache files are not up to date, declare it invalid.
+# If $REQ's cache files are not up to date, or simply if the user
+# discarded them (-f), declare it invalid.
$req->valid (0)
- if ! up_to_date ($req);
+ if $force || ! up_to_date ($req);
# We now know whether we can trust the Request object. Say it.
-if ($verbose)
- {
- print STDERR "$me: the trace request object is:\n";
- print STDERR $req->marshall;
- }
+verbose "$me: the trace request object is:\n" . $req->marshall;
# We need to run M4 if (i) the users wants it (--force), (ii) $REQ is
# invalid.
Index: tests/tools.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/tools.at,v
retrieving revision 1.65
diff -u -u -r1.65 tools.at
--- tests/tools.at 16 Oct 2002 06:38:50 -0000 1.65
+++ tests/tools.at 16 Oct 2002 17:02:04 -0000
@@ -111,6 +111,39 @@
+## ------------------ ##
+## autom4te's cache. ##
+## ------------------ ##
+
+AT_SETUP([autom4te cache])
+
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([foo])
+]])
+
+# Everything is OK.
+touch foo
+AT_CHECK_M4SUGAR
+
+# We moved a file: it should fail
+mkdir sub
+mv foo sub
+AT_CHECK_M4SUGAR([], [], [], [stderr])
+AT_CHECK([[sed 's/^[^:]*m4:/m4:/' stderr]], [],
+[m4: script.4s: 1: Cannot open foo: No such file or directory
+])
+
+# But if we change the main file, then we should no longer complain of
+# missing files.
+AT_DATA_M4SUGAR([[script.4s]],
+[[m4_include([sub/foo])
+]])
+AT_CHECK_M4SUGAR
+
+AT_CLEANUP
+
+
+
## ------------------ ##
## autoconf --trace. ##