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.
This commit is contained in:
parent
3ed96312af
commit
1036115f2d
@ -171,6 +171,7 @@ include $(RIOTMAKE)/utils/checks.mk
|
||||
include $(RIOTMAKE)/docker.inc.mk
|
||||
|
||||
# include color echo macros
|
||||
include $(RIOTMAKE)/utils/ansi.mk
|
||||
include $(RIOTMAKE)/color.inc.mk
|
||||
|
||||
# include concurrency helpers
|
||||
|
||||
@ -14,12 +14,11 @@ ifneq ($(CC_NOCOLOR),1)
|
||||
IS_TERMINAL = $(if $(MAKE_TERMOUT),$(MAKE_TERMERR),)
|
||||
# Check if terminal support colored output
|
||||
ifneq ($(IS_TERMINAL),)
|
||||
_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
|
||||
COLOR_GREEN := $(ANSI_GREEN)
|
||||
COLOR_RED := $(ANSI_RED)
|
||||
COLOR_YELLOW := $(ANSI_YELLOW)
|
||||
COLOR_PURPLE := $(ANSI_PURPLE)
|
||||
COLOR_RESET := $(ANSI_RESET)
|
||||
ifeq ($(OS),Darwin)
|
||||
COLOR_ECHO := echo -e
|
||||
SHELL=bash
|
||||
|
||||
11
makefiles/utils/ansi.mk
Normal file
11
makefiles/utils/ansi.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# ANSI Terminal codes and other escape sequences.
|
||||
# The objective of this definitions is to be able to write special characters
|
||||
# without resorting to shell commands like echo.
|
||||
|
||||
include $(RIOTMAKE)/utils/ansi_special.mk
|
||||
|
||||
ANSI_GREEN := $(ANSI_ESC)[1;32m
|
||||
ANSI_RED := $(ANSI_ESC)[1;31m
|
||||
ANSI_YELLOW := $(ANSI_ESC)[1;33m
|
||||
ANSI_PURPLE := $(ANSI_ESC)[1;35m
|
||||
ANSI_RESET := $(ANSI_ESC)[0m
|
||||
16
makefiles/utils/ansi_special.mk
Normal file
16
makefiles/utils/ansi_special.mk
Normal file
@ -0,0 +1,16 @@
|
||||
# Make does not recognize escaped characters (e.g. \t, \033, etc).
|
||||
# The following variables contain the characters themselves.
|
||||
# This file is inherently fragile (i.e. your editor could destroy the tab
|
||||
# without you realizing, to be careful when editing this.
|
||||
|
||||
# To generate this: $ printf "ANSI_ESC := \033# comment"
|
||||
ANSI_ESC := # you may or may not be able to see that character in your editor
|
||||
|
||||
# The third parameter to the subst is a tab - be careful not to replace it with
|
||||
# spaces!
|
||||
TAB := $(subst ,, )
|
||||
|
||||
define NEWLINE
|
||||
|
||||
|
||||
endef
|
||||
Loading…
x
Reference in New Issue
Block a user