From: Akim Demaille Date: Thu, 21 Aug 2003 17:25:28 +0000 (+0000) Subject: First stab at preserving warnings between calls to autom4te, X-Git-Tag: AUTOCONF-2.57b~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e491f8318006ebbc477bbdeda34c751d144435f7;p=thirdparty%2Fautoconf.git First stab at preserving warnings between calls to autom4te, including when the cache is used. There are still several issues: (i) there are too many runs of m4 (one for include, one for warnings, and some more), (ii) warnings spreading on several lines are not handled gracefully, (iii) the code meant to have the call stack display for errors does not work (its handling should move from m4 to autom4te). * bin/autom4te.in Autom4te::Channels, Autom4te::ChannelDefs): Use them. (@preselect): Add m4_warn. ($exit_status): Remove, use $exit_code. ($help): Use Autom4te::ChannelDefs::usage. (&handle_m4): No longer define the m4_warnings. At each run, extract and report the warnings. Always cache the result, including if the exit status is on failure, since if nothing changes, we should result in the same failure, hence we can use the cache. * lib/m4sugar/m4sugar.m4 (m4_warning_ifelse, _m4_warning_ifelse) (_m4_warning_error_ifelse, __m4_warning_error_ifelse, _m4_warn): Remove. (m4_warn): Redefine as a do-nothing: it is its invocation that matters, as warnings are now reported via traces. * lib/autoconf/general.m4 (AC_DIAGNOSE): Don't make it a copy of the contents of m4_warn: make it _call_ m4_warn, so that tracing the latter reveals calls to the former. Adjust the tests. * tests/m4sugar.at (m4@&t@_warn): Use existing warning categories. --- diff --git a/ChangeLog b/ChangeLog index 4967490f..78cf74ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2003-08-21 Akim Demaille + + First stab at preserving warnings between calls to autom4te, + including when the cache is used. + + There are still several issues: (i) there are too many runs of m4 + (one for include, one for warnings, and some more), (ii) warnings + spreading on several lines are not handled gracefully, (iii) the + code meant to have the call stack display for errors does not work + (its handling should move from m4 to autom4te). + + * bin/autom4te.in Autom4te::Channels, Autom4te::ChannelDefs): + Use them. + (@preselect): Add m4_warn. + ($exit_status): Remove, use $exit_code. + ($help): Use Autom4te::ChannelDefs::usage. + (&handle_m4): No longer define the m4_warnings. + At each run, extract and report the warnings. + Always cache the result, including if the exit status is on + failure, since if nothing changes, we should result in the same + failure, hence we can use the cache. + * lib/m4sugar/m4sugar.m4 (m4_warning_ifelse, _m4_warning_ifelse) + (_m4_warning_error_ifelse, __m4_warning_error_ifelse, _m4_warn): + Remove. + (m4_warn): Redefine as a do-nothing: it is its invocation that + matters, as warnings are now reported via traces. + * lib/autoconf/general.m4 (AC_DIAGNOSE): Don't make it a copy of + the contents of m4_warn: make it _call_ m4_warn, so that tracing + the latter reveals calls to the former. + + Adjust the tests. + + * tests/m4sugar.at (m4@&t@_warn): Use existing warning categories. + 2003-08-21 Akim Demaille * bin/autoreconf.pm (Autom4te::Channels, Autom4te::ChannelDefs): diff --git a/NEWS b/NEWS index 30f601da..c2a33e4b 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ ** Autotest and local.at The optional file local.at is always included in Autotest test suites. +** Warnings + The warnings are always issued, including with cached runs. + This became a significant problem since aclocal and automake can + run autoconf behind the scene. + * Major changes in Autoconf 2.57a Released 2003-06-20 by Akim Demaille. diff --git a/bin/autom4te.in b/bin/autom4te.in index 6c028dbc..e9c7830e 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -236,6 +236,8 @@ sub load package Autom4te; +use Autom4te::ChannelDefs; +use Autom4te::Channels; use Autom4te::FileUtils; use Autom4te::General; use File::Basename; @@ -273,17 +275,13 @@ my %trace; # `m4_pattern_allow' to check the output. # # FIXME: What about `sinclude'? -my @preselect = ('include', 'm4_pattern_allow', 'm4_pattern_forbid'); - -# List of warnings. -my @warning; +my @preselect = ('include', + 'm4_pattern_allow', 'm4_pattern_forbid', + 'm4_warn'); # M4 include path. my @include; -# 0 for EXIT_SUCCESS. -my $exit_status = 0; - # Do we freeze? my $freeze = 0; @@ -356,8 +354,7 @@ my %m4_builtin_alternate_name; # $HELP # ----- -$help = << "EOF"; -Usage: $0 [OPTION] ... [FILES] +$help = "Usage: $0 [OPTION] ... [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. @@ -391,14 +388,7 @@ Languages include: \`M4sh\' create M4sh shell scripts \`M4sugar\' create M4sugar output -Warning categories include: - \`cross\' cross compilation issues - \`obsolete\' obsolete constructs - \`syntax\' dubious syntactic constructs - \`all\' all the warnings - \`no-CATEGORY\' turn off the warnings on CATEGORY - \`none\' turn off all the warnings - \`error\' warnings are error +" . Autom4te::ChannelDefs::usage . " The environment variable \`WARNINGS\' is honored. @@ -414,7 +404,7 @@ Freezing: -F, --freeze produce an M4 frozen state file for FILES Report bugs to . -EOF +"; # $VERSION # -------- @@ -540,11 +530,12 @@ sub parse_args () # Process the arguments for real this time. my @trace; my @prepend_include; + parse_WARNINGS; getopt ( # Operation modes: "o|output=s" => \$output, - "W|warnings=s" => \@warning, + "W|warnings=s" => \&parse_warnings, "m|mode=s" => \$mode, "M|melt" => \$melt, @@ -656,13 +647,6 @@ sub handle_m4 ($@) { my ($req, @macro) = @_; - # The warnings are the concatenation of 1. application's defaults, - # 2. $WARNINGS, $3 command line options, in that order. - # Set them in the order expected by the M4 macros: the converse. - my $m4_warnings = - lc join (',', reverse (split (',', ($ENV{'WARNINGS'} || '')), - map { split /,/ } @warning)); - # GNU m4 appends when using --error-output. unlink ($tcache . $req->id . "t"); @@ -674,7 +658,6 @@ sub handle_m4 ($@) # when we are interrupted (that leaves corrupted files). xsystem ("$m4" . join (' --include=', '', @include) - . " --define=m4_warnings=$m4_warnings" . ' --debug=aflq' . (!exists $ENV{'AUTOM4TE_NO_FATAL'} ? ' --fatal-warning' : '') . " --error-output=$tcache" . $req->id . "t" @@ -805,7 +788,7 @@ sub handle_output ($$) # This is unsatisfying but... my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b'; my $file = new Autom4te::XFile ($ARGV[$#ARGV]); - $exit_status = 1; + $exit_code = 1; while ($_ = $file->getline) { @@ -1207,6 +1190,15 @@ verbose "$me: the trace request object is:\n" . $req->marshall; handle_m4 ($req, keys %{$req->macro}) if $force || ! $req->valid; +# Issue the warnings each time autom4te was run. +handle_traces ($req, "$tmp/warnings", + ('m4_warn' => "\$1::\$f:\$l::\$2\n\n")); +for (split (/\n{2,}/, contents ("$tmp/warnings"))) +{ + my ($cat, $loc, $msg) = split '::'; + msg $cat, $loc, "warning: $msg"; +} + # Now output... if (%trace) { @@ -1225,13 +1217,11 @@ else if mtime ($output) < mtime ($ocache . $req->id); } -# If all went fine, the cache is valid. -$req->valid (1) - if $exit_status == 0; - +# If we ran up to here, the cache is valid. +$req->valid (1); Request->save ($icache_file); -exit $exit_status; +exit $exit_code; ### Setup "GNU" style for perl-mode and cperl-mode. ## Local Variables: diff --git a/configure b/configure index 3e2d8cf0..ff71c4ca 100755 --- a/configure +++ b/configure @@ -23,7 +23,7 @@ elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then fi # Support unset when possible. -if (as_foo=foo; unset as_foo) >/dev/null 2>&1; then +if ((MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -2118,7 +2118,7 @@ elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then fi # Support unset when possible. -if (as_foo=foo; unset as_foo) >/dev/null 2>&1; then +if ((MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 5aa163b4..32d38be0 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1875,8 +1875,8 @@ m4_define([AC_SUBST_FILE], # AC_DIAGNOSE(CATEGORY, MESSAGE) # AC_FATAL(MESSAGE, [EXIT-STATUS]) # -------------------------------- -m4_copy([m4_warn], [AC_DIAGNOSE]) -m4_copy([m4_fatal], [AC_FATAL]) +m4_define([AC_DIAGNOSE], [m4_warn($@)]) +m4_define([AC_FATAL], [m4_fatal($@)]) # AC_WARNING(MESSAGE) diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index c217d57e..2fd34960 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -206,70 +206,11 @@ m4_define([m4_assert], ## ------------- ## -# m4_warning_ifelse(CATEGORY, IF-TRUE, IF-FALSE) -# ---------------------------------------------- -# If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise -# IF-FALSE. -# -# The variable `m4_warnings' contains a comma separated list of -# warnings which order is the converse from the one specified by -# the user, i.e., if she specified `-W error,none,obsolete', -# `m4_warnings' is `obsolete,none,error'. We read it from left to -# right, and: -# - if none or noCATEGORY is met, run IF-FALSE -# - if all or CATEGORY is met, run IF-TRUE -# - if there is nothing left, run IF-FALSE. -m4_define([m4_warning_ifelse], -[_m4_warning_ifelse([$1], [$2], [$3], m4_warnings)]) - - -# _m4_warning_ifelse(CATEGORY, IF-TRUE, IF-FALSE, WARNING1, ...) -# -------------------------------------------------------------- -# Implementation of the loop described above. -m4_define([_m4_warning_ifelse], -[m4_case([$4], - [$1], [$2], - [all], [$2], - [], [$3], - [none], [$3], - [no-$1], [$3], - [$0([$1], [$2], [$3], m4_shiftn(4, $@))])]) - - -# _m4_warning_error_ifelse(IF-TRUE, IF-FALSE) -# ------------------------------------------- -# The same as m4_warning_ifelse, but scan for `error' only. -m4_define([_m4_warning_error_ifelse], -[__m4_warning_error_ifelse([$1], [$2], m4_warnings)]) - - -# __m4_warning_error_ifelse(IF-TRUE, IF-FALSE) -# -------------------------------------------- -# The same as _m4_warning_ifelse, but scan for `error' only. -m4_define([__m4_warning_error_ifelse], -[m4_case([$3], - [error], [$1], - [], [$2], - [no-error], [$2], - [$0([$1], [$2], m4_shiftn(3, $@))])]) - - - -# _m4_warn(MESSAGE) -# ----------------- -# Report MESSAGE as a warning, unless the user requested -W error, -# in which case report a fatal error. -m4_define([_m4_warn], -[_m4_warning_error_ifelse([m4_fatal([$1])], - [m4_warning([$1])])]) - - # m4_warn(CATEGORY, MESSAGE) # -------------------------- # Report a MESSAGE to the autoconf user if the CATEGORY of warnings -# is requested (in fact, not disabled). -m4_define([m4_warn], -[m4_warning_ifelse([$1], [_m4_warn([$2])])]) +# is requested (in fact, not disabled). This is for traces only. +m4_define([m4_warn], []) diff --git a/man/autom4te.1 b/man/autom4te.1 index e9c46cba..8ed78df7 100644 --- a/man/autom4te.1 +++ b/man/autom4te.1 @@ -72,23 +72,35 @@ create M4sugar output `cross' cross compilation issues .TP +`gnu' +GNU coding standards (default in gnu and gnits modes) +.TP `obsolete' -obsolete constructs +obsolete features or constructions +.TP +`override' +user redefinitions of Automake rules or variables +.TP +`portability' +portability issues .TP `syntax' -dubious syntactic constructs +dubious syntactic constructs (default) +.TP +`unsupported' +unsupported or incomplete features (default) .TP `all' all the warnings .TP `no-CATEGORY' -turn off the warnings on CATEGORY +turn off warnings in CATEGORY .TP `none' turn off all the warnings .TP `error' -warnings are error +treat warnings as errors .PP The environment variable `WARNINGS' is honored. .SS "Library directories:" diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 40322974..99a4c300 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -42,8 +42,8 @@ AT_SETUP([[m4@&t@_warn]]) # warnings. But maybe autom4te should handle that by itself? AT_DATA_M4SUGAR([script.4s], -[[m4_warn([foo], [foo]) -m4_warn([bar], [bar]) +[[m4_warn([obsolete], [obsolete]) +m4_warn([cross], [cross]) m4_warn([syntax], [syntax]) ]]) @@ -52,17 +52,17 @@ AT_CHECK_M4SUGAR([-o-], 0, [], ]) AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [], -[script.4s:1: warning: foo -script.4s:2: warning: bar +[script.4s:1: warning: obsolete +script.4s:2: warning: cross script.4s:3: warning: syntax ]) -AT_CHECK_M4SUGAR([-o- -Wnone,bar -f], 0, [], -[script.4s:2: warning: bar +AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [], +[script.4s:2: warning: cross ]) -AT_CHECK_M4SUGAR([-o- -Wnone,bar,error -f], 1, [], -[[script.4s:2: error: bar +AT_CHECK_M4SUGAR([-o- -Wnone,cross,error -f], 1, [], +[[script.4s:2: error: cross script.4s:2: the top level autom4te: m4 failed with exit status: 1 ]])