[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02-fyi-autom4te-freezes.patch
From: |
Akim Demaille |
Subject: |
02-fyi-autom4te-freezes.patch |
Date: |
Tue, 05 Feb 2002 09:09:37 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
Implement `autom4te --freeze'.
* bin/autom4te.in (&freeze): New.
* lib/autoconf/autoconf.m4, lib/autotest/general.m4,
* lib/m4sugar/m4sh.m4: Don't include files given by autom4te.
Index: bin/autom4te.in
--- bin/autom4te.in Wed, 30 Jan 2002 22:24:26 +0100 akim
+++ bin/autom4te.in Wed, 30 Jan 2002 23:34:56 +0100 akim
@@ -272,6 +272,9 @@ sub load
# 0 for EXIT_SUCCESS.
my $exit_status = 0;
+# Do we freeze?
+my $freeze = 0;
+
# $M4.
my $m4 = $ENV{"M4"} || '@M4@';
# Some non-GNU m4's don't reject the --help option, so give them /dev/null.
@@ -344,8 +347,8 @@ sub load
$help = << "EOF";
Usage: $0 [OPTION] ... [FILES]
-Run GNU M4 on the FILES, avoiding useless runs. If tracing, the output
-consists of the traces only, otherwise output the expansion of the FILES.
+Run GNU M4 on the FILES, avoiding useless runs. Output the traces if tracing,
+the frozen file if freezing, otherwise the expansion of the FILES.
If some of the FILES are named \`FILE.m4f\' they are considered to be M4
frozen files of all the previous files (which are therefore not loaded).
@@ -392,6 +395,9 @@ Tracing:
-t, --trace=MACRO report the MACRO invocations
-p, --preselect=MACRO prepare to trace MACRO in a future run
+Freezing:
+ -F, --freeze produce an M4 frozen state file for FILES
+
Report bugs to <address@hidden>.
EOF
@@ -496,12 +502,25 @@ sub parse_args ()
# by hand.
"t|trace=s" => address@hidden,
"p|preselect=s" => address@hidden,
+
+ # Freezing.
+ "F|freeze" => \$freeze,
);
die "$me: too few arguments
Try `$me --help' for more information.\n"
unless @ARGV;
+ # Freezing:
+ # We cannot trace at the same time (well, we can, but it sounds insane).
+ # And it implies melting: there is risk not to update properly using
+ # old frozen files, and worse yet: we could load a frozen file and
+ # refreeze it! A sort of caching :)
+ die "$me: cannot freeze and trace\n"
+ if $freeze && @trace;
+ $melt = 1
+ if $freeze;
+
# Normalize the includes: the first occurrence is enough, several is
# a pain since it introduces a useless difference in the path which
# invalidates the cache. And strip `.' which is implicit and always
@@ -1003,6 +1022,56 @@ sub up_to_date ($)
}
+## ---------- ##
+## Freezing. ##
+## ---------- ##
+
+# freeze ($OUTPUT)
+# ----------------
+sub freeze ($)
+{
+ my ($output) = @_;
+
+ # When processing the file with diversion disabled, there must be no
+ # output but comments and empty lines.
+ my $command = ("$m4"
+ . ' --fatal-warning'
+ . join (' --include=', '', reverse @include)
+ . ' --define=divert'
+ . " @ARGV"
+ . ' </dev/null');
+ verbose "running: $command";
+ my $result = `$command`;
+ $result =~ s/#.*\n//g;
+ $result =~ s/^\n//mg;
+ if ($?)
+ {
+ verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
+ exit $? >> 8;
+ }
+ if ($result)
+ {
+ print STDERR "$me: freezing produced output:\n$result";
+ exit 1;
+ }
+
+ # If freezing produces output, something went wrong: a bad `divert',
+ # or an improper paren etc.
+ $command = ("$m4"
+ . ' --fatal-warning'
+ . join (' --include=', '', reverse @include)
+ . " --freeze-state=$output"
+ . " @ARGV"
+ . ' </dev/null');
+ verbose "running: $command";
+ system $command;
+ if ($?)
+ {
+ verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
+ exit $? >> 8;
+ }
+}
+
## -------------- ##
## Main program. ##
## -------------- ##
@@ -1010,6 +1079,13 @@ sub up_to_date ($)
mktmpdir ('t4');
load_configuration;
parse_args;
+
+# Freezing does not involve the cache.
+if ($freeze)
+ {
+ freeze ($output);
+ exit 0;
+ }
# We need our cache directory.
if (! -d "$cache")
Index: lib/autoconf/autoconf.m4
--- lib/autoconf/autoconf.m4 Thu, 11 Oct 2001 18:59:41 +0200 akim
+++ lib/autoconf/autoconf.m4 Wed, 30 Jan 2002 23:28:57 +0100 akim
@@ -1,7 +1,6 @@
-divert(-1)# -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf. -*- Autoconf -*-
# Driver that loads the Autoconf macro files.
-# Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -51,9 +50,6 @@
# yet when Autoconf is frozen.
# Do not sinclude ./aclocal.m4 here, to prevent it from being frozen.
-changequote()
-changequote([, ])
-include([m4sugar/m4sh.m4])
# general includes some AU_DEFUN.
m4_include([autoconf/autoupdate.m4])
Index: lib/autotest/autotest.m4
--- lib/autotest/autotest.m4 Thu, 23 Aug 2001 23:06:00 +0200 akim
+++ lib/autotest/autotest.m4 Wed, 30 Jan 2002 23:41:18 +0100 akim
@@ -1,7 +1,6 @@
-divert(-1)# -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf. -*- Autoconf -*-
# M4 macros used in building test suites.
-# Copyright 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -45,7 +44,4 @@
# such potential, you must delete any notice of this special exception
# to the GPL from your modified version.
-changequote()
-changequote([, ])
-include([m4sugar/m4sh.m4])
m4_include([autotest/general.m4])
Index: lib/m4sugar/m4sh.m4
--- lib/m4sugar/m4sh.m4 Wed, 30 Jan 2002 21:23:41 +0100 akim
+++ lib/m4sugar/m4sh.m4 Wed, 30 Jan 2002 23:29:22 +0100 akim
@@ -1,8 +1,7 @@
-changequote()changequote([, ])include(m4sugar/m4sugar.m4)# -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf. -*- Autoconf -*-
# M4 sugar for common shell constructs.
# Requires GNU M4 and M4sugar.
-# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 02-fyi-autom4te-freezes.patch,
Akim Demaille <=