Re: RFC: Add public macros AC_LOG_CMD and AC_LOG_FILE.

2024-06-24 Thread Zack Weinberg
On Mon, Jun 24, 2024, at 2:56 AM, Nick Bowler wrote:
> On 2024-06-23 22:23, Zack Weinberg wrote:
>> I'm thinking of making AC_RUN_LOG, which has existed forever but is
>> undocumented, an official documented macro ...
>
> Yes, please!
>
> I will note that Autoconf has a lot of "run and log a command" internal
> macros with various comments of the form "doesn't work well" suggesting
> that this is a hard feature to get right.

... Wow, this is a bigger mess than I thought last night.  Up to bad
quotation in third party macros, however, I *think* almost all of it
is obsolete and can be scrapped.  Stay tuned.

> I think at the same time it would be worth documenting the AS_LINENO
> functionality, which is the main internal functionality of these
> macros that (unless you just goes ahead and use it) Autoconf users
> can't really replicate in their own logging.

I believe what you mean is you want _AS_ECHO_LOG to be promoted to a
documented and supported macro, and for AS_LINENO_PUSH and AS_LINENO_POP
also to be documented for external use.  Is this correct?  Did I miss
any other internal macros that ought to be available for external
use?  I don't think we should tell people to be using $as_lineno directly,
is there some use case for it that isn't covered by existing macros?

> If you implement this, please explain in the manual what "labeled with
> /label/" really means, otherwise I'm left wondering why this macro
> exists when we can almost as easily write something like:
>
>   { echo label; cat file; } >&AS_MESSAGE_LOG_FD
>
> Including example logfile output together with the example program
> might be sufficient.

Will do.  The main point of the macro is that it does something a little
fancier than "cat file", so it's unambiguous where normal log output
resumes. Like the existing _AC_MSG_LOG_CONFTEST does:

configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "lexlib-probe"
| #define PACKAGE_TARNAME "lexlib-probe"
| #define PACKAGE_VERSION "1"
| ... etc ...
configure: result: no

The "label" will go where _AC_MSG_LOG_CONFTEST prints "failed program was".

zw



Re: RFC: Add public macros AC_LOG_CMD and AC_LOG_FILE.

2024-06-24 Thread Nick Bowler
On 2024-06-24 10:04, Zack Weinberg wrote:
> On Mon, Jun 24, 2024, at 2:56 AM, Nick Bowler wrote:
>> I think at the same time it would be worth documenting the AS_LINENO
>> functionality, which is the main internal functionality of these
>> macros that (unless you just goes ahead and use it) Autoconf users
>> can't really replicate in their own logging.
> 
> I believe what you mean is you want _AS_ECHO_LOG to be promoted to a
> documented and supported macro, and for AS_LINENO_PUSH and AS_LINENO_POP
> also to be documented for external use.  Is this correct?  Did I miss
> any other internal macros that ought to be available for external
> use?

> I don't think we should tell people to be using $as_lineno directly,
> is there some use case for it that isn't covered by existing macros?

On reflection, I think I may have had a mistaken understanding of the
purpose of the as_lineno when I last looked at these macros.  I assumed
it was related to supporting shells without LINENO support but it seems
it is not the case, so maybe nothing is actually needed.

Perhaps a link from the (very short) description of AS_LINENO_PREPARE[1]
to the description of LINENO[2] might have helped.

That being said, something like AS_ECHO_LOG (with or without
AS_LINENO_PUSH/POP) looks generally useful, although I don't have an
immediate use case offhand besides implementing an AC_RUN_LOG workalike.

[1] 
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AS_005fLINENO_005fPREPARE
[2] 
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-LINENO-1

[...]
> Will do.  The main point of the macro is that it does something a little
> fancier than "cat file", so it's unambiguous where normal log output
> resumes. Like the existing _AC_MSG_LOG_CONFTEST does:
> 
> configure: failed program was:
> | /* confdefs.h */
> | #define PACKAGE_NAME "lexlib-probe"
> | #define PACKAGE_TARNAME "lexlib-probe"
> | #define PACKAGE_VERSION "1"
> | ... etc ...
> configure: result: no
> 
> The "label" will go where _AC_MSG_LOG_CONFTEST prints "failed program was".

Looks great, this example output definitely helps to understand when one
might want to use this macro.

Cheers,
  Nick