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

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.
This commit is contained in:
Juan Carrano 2019-08-30 13:55:32 +02:00 committed by Francisco Molina
parent 3c5c3ba4af
commit 3ed96312af
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8

View File

@ -3,6 +3,7 @@
COLOR_GREEN :=
COLOR_RED :=
COLOR_YELLOW :=
COLOR_PURPLE :=
COLOR_RESET :=
COLOR_ECHO := /usr/bin/env echo
@ -13,11 +14,12 @@ ifneq ($(CC_NOCOLOR),1)
IS_TERMINAL = $(if $(MAKE_TERMOUT),$(MAKE_TERMERR),)
# Check if terminal support colored output
ifneq ($(IS_TERMINAL),)
COLOR_GREEN := \033[1;32m
COLOR_RED := \033[1;31m
COLOR_YELLOW := \033[1;33m
COLOR_PURPLE := \033[1;35m
COLOR_RESET := \033[0m
_ANSI_ESC := $(shell printf "\033")
COLOR_GREEN := $(_ANSI_ESC)[1;32m
COLOR_RED := $(_ANSI_ESC)[1;31m
COLOR_YELLOW := $(_ANSI_ESC)[1;33m
COLOR_PURPLE := $(_ANSI_ESC)[1;35m
COLOR_RESET := $(_ANSI_ESC)[0m
ifeq ($(OS),Darwin)
COLOR_ECHO := echo -e
SHELL=bash