colorization: Put colorization of config in COLORIZE

Also standardize the size of the output of the various steps.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2021-02-10 22:53:36 +01:00
parent 70c9271721
commit 16ab4de4f8
3 changed files with 48 additions and 21 deletions

View File

@ -219,9 +219,9 @@ MIQ_CFGTEST= "$<" -o "$<".exe > "$<".err 2>&1 && \
"$<".exe > "$<".out \
$(MIQ_CFGSET)
MIQ_CFG_PRINT= if [ $$MIQ_CFGRC == 1 ]; then \
echo "$(POS_COLOR)OK$(DEF_COLOR)"; \
echo "[OK]"; \
else \
echo "$(ERR_COLOR)NO$(DEF_COLOR)"; \
echo "[NO]"; \
fi;
MIQ_CFGUNDEF0= $$MIQ_CFGRC \
| sed -e 's|^\#define \(.*\) 0$$|/* \#undef \1 */|g' > "$@"; \
@ -276,3 +276,16 @@ MIQ_PKGCONFIG_LIBS_OPTIONAL= \
(pkg-config --libs $* --silence-errors > $@ \
&& MIQ_CFGRC=1 || MIQ_CFGRC=0; \
true)
#------------------------------------------------------------------------------
# Test checks
#------------------------------------------------------------------------------
MIQ_TEST= && MIQ_RC=1 || MIQ_RC=0; true
PRINT_TEST_OK= if [ $$MIQ_RC == 1 ]; then \
echo "[OK]"; \
else \
echo "[KO]"; \
fi;

View File

@ -186,9 +186,12 @@ ERROR_MSG= '[Ee]rror\( \?\[\?[A-Za-z]\+[0-9]\+\]\?\)\?:'
#------------------------------------------------------------------------------
# Colorization
#------------------------------------------------------------------------------
# These use ANSI code, but they work on Mac, Windows, Linux, BSD and VMS, which is good enough
# These use ANSI code, but they work on Mac, Windows, Linux, BSD and VMS,
# which is good enough for most use cases.
# Change them if you want to work from an hpterm on HP-UX ;-)
INFO_STEP_COL= \\033[37;44m
INFO_ESTEP_COL= \\033[37;41m
INFO_WSTEP_COL= \\033[30;43m
INFO_NAME_COL= \\033[33;44m
INFO_LINE_COL= \\033[36;49m
INFO_ERR_COL= \\033[31m
@ -196,13 +199,16 @@ INFO_WRN_COL= \\033[33m
INFO_POS_COL= \\033[32m
INFO_RST_COL= \\033[39;49;27m
INFO_CLR_EOL= \\033[K
INFO= printf "%-20s %s %s %s %s %s %s %s\n"
INFO_NONL= printf "%-20s %-30s %s %s %s %s %s %s"
INFO= printf "%-16s %-56s%6s\n"
INFO_NONL= printf "%-16s %-56s"
INFO_TEST= printf "%-16s %-56s%6s\n"
# Color for build steps
STEP_COLOR:= $(shell printf "$(INFO_STEP_COL)")
LINE_COLOR:= $(shell printf "$(INFO_NAME_COL)")
NAME_COLOR:= $(shell printf "$(INFO_LINE_COL)")
WSTEP_COLOR:= $(shell printf "$(INFO_WSTEP_COL)")
ESTEP_COLOR:= $(shell printf "$(INFO_ESTEP_COL)")
LINE_COLOR:= $(shell printf "$(INFO_LINE_COL)")
NAME_COLOR:= $(shell printf "$(INFO_NAME_COL)")
ERR_COLOR:= $(shell printf "$(INFO_ERR_COL)")
WRN_COLOR:= $(shell printf "$(INFO_WRN_COL)")
POS_COLOR:= $(shell printf "$(INFO_POS_COL)")
@ -216,12 +222,19 @@ LINE_BUFFERED=--line-buffered
COLOR_FILTER= | grep $(LINE_BUFFERED) -v -e "^true &&" -e "^[A-Za-z0-9_-]\+\.\(c\|h\|cpp\|hpp\)$$" \
$(COLORIZE)
COLORIZE= | sed $(SEDOPT_$(OS_NAME)) \
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ww]arning\)/$(POS_COLOR)\1$(WRN_COLOR)\2$(DEF_COLOR)/g' \
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ee]rror\)/$(POS_COLOR)\1$(ERR_COLOR)\2$(DEF_COLOR)/g' \
-e 's/^\(\[BEGIN\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[END\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[[A-Z/ 0-9-]\{1,\}\]\)\(.*\)$$/$(LINE_COLOR)\1$(NAME_COLOR)\2$(DEF_COLOR)/g'
COLORIZE= | sed $(SEDOPT_$(OS_NAME)) \
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ww]arning\)/$(POS_COLOR)\1$(WRN_COLOR)\2$(DEF_COLOR)/g' \
-e 's/^\(.*[,:(]\{1,\}[0-9]*[ :)]*\)\([Ee]rror\)/$(POS_COLOR)\1$(ERR_COLOR)\2$(DEF_COLOR)/g' \
-e 's/^\(\[BEGIN\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[END\]\)\(.*\)$$/$(STEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/\(\[OK\]\)/$(POS_COLOR)\1$(DEF_COLOR)/g' \
-e 's/\(\[NO\]\)/$(ERR_COLOR)\1$(DEF_COLOR)/g' \
-e 's/\(\[KO\]\)/$(ERR_COLOR)\1$(DEF_COLOR)/g' \
-e 's/^\(\[WARNING\]\)\(.*\)$$/$(WSTEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[MISSING\]\)\(.*\)$$/$(WSTEP_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[ERROR\]\)\(.*\)$$/$(ERR_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[FAIL\]\)\(.*\)$$/$(ERR_COLOR)\1\2$(CLR_EOLINE)$(DEF_COLOR)/g' \
-e 's/^\(\[[A-Z/ 0-9-]\{1,\}\]\)\(.*\)$$/$(NAME_COLOR)\1$(LINE_COLOR)\2$(DEF_COLOR)/g'
#------------------------------------------------------------------------------

View File

@ -262,9 +262,9 @@ help:
.postbuild $(RUN_TESTS:%=.tests) .goodbye
.hello:
@$(INFO) "[BEGIN]" $(TARGET) $(BUILDENV) in "$(MIQ_PRETTYDIR)"
@$(INFO) "[BEGIN]" "$(TARGET) $(BUILDENV) in $(MIQ_PRETTYDIR)"
.goodbye:
@$(INFO) "[END]" $(TARGET) $(BUILDENV) in "$(MIQ_PRETTYDIR)"
@$(INFO) "[END]" "$(TARGET) $(BUILDENV) in $(MIQ_PRETTYDIR)"
# Sequencing build steps and build step hooks
.config: .hello
@ -392,12 +392,13 @@ PRINT_COMPILE= $(PRINT_COMMAND) $(INFO) "[COMPILE$(MIQ_PRINTCOUNT)] " $<;
PRINT_LINK= $(PRINT_COMMAND) $(INFO) "[LINK]" $(shell basename $@);
PRINT_GENERATE= $(PRINT_COMMAND) $(INFO) "[GENERATE]" "$(shell basename "$@")";
PRINT_VARIANT= $(PRINT_COMMAND) $(INFO) "[VARIANT]" "$*";
PRINT_INSTALL= $(PRINT_COMMAND) $(INFO) "[INSTALL] " $(*F) in $(<D) $(COLORIZE);
PRINT_UNINSTALL=$(PRINT_COMMAND) $(INFO) "[UNINSTALL] " $(*F) $(COLORIZE);
PRINT_CLEAN= $(PRINT_COMMAND) $(INFO) "[CLEAN] " $@ $(MIQ_PRETTYDIR) $(COLORIZE);
PRINT_COPY= $(PRINT_COMMAND) $(INFO) "[COPY]" $< '=>' $@ ;
PRINT_DEPEND= $(PRINT_COMMAND) $(INFO) "[DEPEND] " $< ;
PRINT_TEST= $(PRINT_COMMAND) $(INFO) "[TEST]" $(@:.test=) ;
PRINT_INSTALL= $(PRINT_COMMAND) $(INFO) "[INSTALL]" "$(*F) in $(<D)" $(COLORIZE);
PRINT_UNINSTALL=$(PRINT_COMMAND) $(INFO) "[UNINSTALL] " "$(*F)" $(COLORIZE);
PRINT_CLEAN= $(PRINT_COMMAND) $(INFO) "[CLEAN] " "$@ $(MIQ_PRETTYDIR)" $(COLORIZE);
PRINT_COPY= $(PRINT_COMMAND) $(INFO) "[COPY]" "$< '=>' $@" ;
PRINT_DEPEND= $(PRINT_COMMAND) $(INFO) "[DEPEND] " "$<" ;
PRINT_TEST= $(PRINT_COMMAND) $(INFO_NONL) "[TEST]" "$(@:.test=)";
PRINT_RESULT= $(PRINT_COMMAND) $(INFO) "[TEST]" "$(@:.test=)" "[$(shell cat $*.result)]";
PRINT_CONFIG= $(PRINT_COMMAND) $(INFO_NONL) "[CONFIG]" "$(MIQ_ORIGTARGET)" ;
PRINT_PKGCONFIG=$(PRINT_COMMAND) $(INFO) "[PKGCONFIG]" "$*" ;
PRINT_LIBCONFIG=$(PRINT_COMMAND) $(INFO) "[LIBCONFIG]" "lib$*" ;