[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -V, --verbose, as opposite of -s, --silent, --quiet
From: |
Alejandro Colomar (man-pages) |
Subject: |
Re: -V, --verbose, as opposite of -s, --silent, --quiet |
Date: |
Mon, 25 Oct 2021 22:28:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
Hello Paul, Dmitry, and David!
> On Sat, Oct 23, 2021 at 6:06 AM Paul Smith <psmith@gnu.org
> <mailto:psmith@gnu.org>> wrote:
>
> On Sat, 2021-10-23 at 03:01 +0200, Alejandro Colomar (man-pages)
wrote:
> > I'd like a project to use '--silent' by default, to have readable
> > output, and hide most of the full commands, which would be too
> > noisy.
> >
> > So, ideally, I'd like to have 'MAKEFLAGS += --silent' in the
> > Makefile.
>
> Actually what you really want is the .SILENT special target.
>
>
https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#index-_002eSILENT
>
<https://www.gnu.org/software/make/manual/html_node/Special-Targets.html#index-_002eSILENT>
>
> That leads to this best-practice way to handle verbose output:
>
> http://make.mad-scientist.net/managing-recipe-echoing/
> <http://make.mad-scientist.net/managing-recipe-echoing/>
>
>
Hmm! Yes, I knew about .SILENT, but didn't know about this usage of it.
It's interesting and simple enough, so I've started using it.
Since I use '--warn-undefined-variables', and also to help readability
to someone who may not know about this usage and may wonder what does
that $(V) mean, I used the following:
V :=
$(V).SILENT:
Thanks!
On 10/23/21 10:28 PM, David Boyce wrote:
BTW we use a slightly different and, I think, slightly improved version
of what's shown there (see below). Improvements are:
1. Either the verbose or the concise output is shown, vs both in verbose
mode as the original does.
I thought about it, and I prefer printing both for the following reasons:
The verbose output tends to use many lines for each command, since it
may easily use 500 characters per command. Having a short line that
uses uppercase at the beginning makes it much easier to know where each
command starts.
Also, if you put that into a log file, then you can easily grep for the
short line that you know you want to search, and next to it will be the
long line (something like a dictionary).
And anyway, one short line per command (typically around 5-8 lines)
won't hurt readability too much.
2. It uses $(info ...) instead of echo which saves a fork/exec per
recipe (note: this is safe only when used in the first recipe line).
Yup! I also use $(info ...) since mad scientist showed it to me. It
made a huge impact in performance.
3. It provides a default "MAKING $@" message as demonstrated in the example.
Nah, I prefer explicit $(info ...) lines always. Makes it easier to
read, and also I prefer showing the command that runs every target.
Cheers,
Alex
4. A special case is used to ensure the clean target is always verbose.
David
$ cat Makefile
.PHONY: all
all: hola
ifeq ($(V),)
vb = $(info $(or $1,MAKING $(@F)))
.SILENT:
endif
hola: hola.o
$(call vb)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
%.o: %.c
$(call vb,CC $(<F) -> $(@F))
$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
.PHONY: clean
clean: clean_recipe = $(RM) *.o hola
clean:
@$(info $(clean_recipe))
@$(clean_recipe)
$ make clean; make
rm -f *.o hola
CC hola.c -> hola.o
MAKING hola
$ make clean; make V=1
rm -f *.o hola
cc -c -o hola.o hola.c
cc -o hola hola.o
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
- -V, --verbose, as opposite of -s, --silent, --quiet, Alejandro Colomar (man-pages), 2021/10/22
- Re: -V, --verbose, as opposite of -s, --silent, --quiet, Paul Smith, 2021/10/23
- Re: -V, --verbose, as opposite of -s, --silent, --quiet, David Boyce, 2021/10/23
- Re: -V, --verbose, as opposite of -s, --silent, --quiet,
Alejandro Colomar (man-pages) <=
- Re: -V, --verbose, as opposite of -s, --silent, --quiet, Paul Smith, 2021/10/25
- Re: -V, --verbose, as opposite of -s, --silent, --quiet, Alejandro Colomar (man-pages), 2021/10/25
Re: -V, --verbose, as opposite of -s, --silent, --quiet, Dmitry Goncharov, 2021/10/23
- Prev by Date:
Re: [bug #61226] A regression prevents generation of missing included dependency files.
- Next by Date:
Re: -V, --verbose, as opposite of -s, --silent, --quiet
- Previous by thread:
Re: -V, --verbose, as opposite of -s, --silent, --quiet
- Next by thread:
Re: -V, --verbose, as opposite of -s, --silent, --quiet
- Index(es):