1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

8 Commits

Author SHA1 Message Date
Juan Carrano
9fe8f54db9
makefiles/color: Add color functions.
c_xxxx functions can be used to wrap a piece of text in a
$(COLOR_X)...$(COLOR_RESET) block, thereby avoiding the easy mistake
of forgetting to place a COLOR_RESET.
2021-05-04 10:57:47 +02:00
Juan Carrano
1036115f2d
makefiles/utils/ansi: Refactor ansi codes into their own file.
The escape codes and special chars now live in their own module. The
color module is only concerned with detecting whether to use colors or
not.

Additional variables are defined with hard a coded ESC char, a tab and a
newline. This removes the need for echo or printf.
2021-05-04 10:52:50 +02:00
Juan Carrano
3ed96312af
makefiles/color: preprocess color strings.
The color strings COLOR_* are redefined so that they don't have to be
processed by "echo -e". This is done by storing the already interpreted
ANSI sequence in a shell variable.

With this change, not only can color messages be printed using normal
`echo` with no switches: colors also work with the `info` and `warning`
builtins of make.

The COLOR_ECHO variable is kept because it is also being used (confusingly)
to intepret tabs an newlines. This will be fixed in another commit.

This change should change absolutely anything and colors should still work
as always.
2021-05-04 10:50:58 +02:00
Benjamin Valentin
b18b8e4f77 makefiles/color: fix build on NixOS
On NixOS, there is no `/bin/echo`, instead
`which echo` will return

    /home/benpicco/.nix-profile/bin/echo

so hard-coding the path will break here.

Use `/usr/bin/env` to get the path of `echo`.
This should be availiable on all systems at the same location.
2020-02-27 18:13:36 +01:00
Francisco Molina
b1ca4597ef makefiles/color.inc.mk: don't set CC_NOCOLOR
If CC_NOCOLOR was not set by the user it was set according to the
terminal support of colored output.

But since CC_NOCOLOR is also used to set `-fdiagnostics-color` flags
this means changing `CFLAGS` according to terminal support of colored
output.

This is not needed for `-fdiagnostics-color` since this option is by
default `auto` if the compiler supports colored output, and `auto`
means it will only use color when standard error is a terminal.
2020-01-10 08:58:54 +01:00
Juan Carrano
0d6a8879bc makefiles/color: detect if writing to terminal.
The current code for detecting whether colors should be used by default
was not working. Normally what programs such as git or grep do is check
if they are writing to a pipe.

To see the issue by yourself:

$ BOARD=samr21-xpro make -C tests/periph_qdec > I_SHOULD_NOT_HAVE_COLORS 2>&1

This commit uses MAKE_TERMOUT, MAKE_TERMERR and if ANY of them is NOT
a terminal, colors are disabled.
2019-08-30 16:35:25 +02:00
Xavier Clive
c6af3f733d make: Do not attempt to use color if the terminal cannot support it 2017-11-16 20:04:18 +01:00
daa277b36e make: refactor info- and buildtest targets 2017-09-14 13:15:53 +02:00