mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
make: Centralize color use
This commit is contained in:
parent
e9c369e2d7
commit
4d8aad8ad1
@ -34,23 +34,32 @@ BOARDS := $(filter-out $(BOARD_BLACKLIST), $(BOARDS))
|
||||
.PHONY: buildtest info-objsize info-buildsize info-buildsizes \
|
||||
info-buildsizes-diff info-build info-boards-supported
|
||||
|
||||
|
||||
COLOR_GREEN :=
|
||||
COLOR_RED :=
|
||||
COLOR_PURPLE :=
|
||||
COLOR_RESET :=
|
||||
COLOR_ECHO := /bin/echo
|
||||
ifeq (, ${JENKINS_URL})
|
||||
ifeq (0, $(shell tput colors 2>&1 > /dev/null; echo $$?))
|
||||
COLOR_GREEN := \033[1;32m
|
||||
COLOR_RED := \033[1;31m
|
||||
COLOR_PURPLE := \033[1;35m
|
||||
COLOR_RESET := \033[0m
|
||||
COLOR_ECHO := /bin/echo -e
|
||||
endif
|
||||
endif
|
||||
|
||||
buildtest:
|
||||
@if [ -z "$${JENKINS_URL}" ] && tput colors 2>&1 > /dev/null; then \
|
||||
GREEN='\033[1;32m'; RED='\033[1;31m'; PURPLE='\033[1;35m'; RESET='\033[0m'; \
|
||||
ECHO='/bin/echo -e'; \
|
||||
else \
|
||||
GREEN=''; RED=''; PURPLE=''; RESET=''; \
|
||||
ECHO='/bin/echo'; \
|
||||
fi; \
|
||||
\
|
||||
@ \
|
||||
BUILDTESTOK=true; \
|
||||
rm -rf "$$BINDIRBASE"; \
|
||||
for BOARD in $(BOARDS); do \
|
||||
RIOTNOLINK=$$(case ' $(BOARD_INSUFFICIENT_RAM) ' in *" $${BOARD} "*) echo 1; esac); \
|
||||
$${ECHO} -n "Building for $${BOARD} "; \
|
||||
[ -n "$${RIOTNOLINK}" ] && $${ECHO} -n "(no linking) "; \
|
||||
${COLOR_ECHO} -n "Building for $${BOARD} "; \
|
||||
[ -n "$${RIOTNOLINK}" ] && ${COLOR_ECHO} -n "(no linking) "; \
|
||||
for NTH_TRY in 1 2; do \
|
||||
$${ECHO} -n ".. "; \
|
||||
${COLOR_ECHO} -n ".. "; \
|
||||
LOG=$$(env -i \
|
||||
HOME=$${HOME} \
|
||||
PATH=$${PATH} \
|
||||
@ -63,12 +72,12 @@ buildtest:
|
||||
RIOT_VERSION=$${RIOT_VERSION} \
|
||||
$(MAKE) -j$(NPROC) 2>&1 >/dev/null) ; \
|
||||
if [ "$${?}" = "0" ]; then \
|
||||
$${ECHO} "$${GREEN}success$${RESET}"; \
|
||||
${COLOR_ECHO} "${COLOR_GREEN}success${COLOR_RESET}"; \
|
||||
elif [ -n "$${RIOT_DO_RETRY}" ] && $${BUILDTESTOK} && [ $${NTH_TRY} = 1 ]; then \
|
||||
$${ECHO} -n "$${PURPLE}retrying$${RESET} "; \
|
||||
${COLOR_ECHO} -n "${COLOR_PURPLE}retrying${COLOR_RESET} "; \
|
||||
continue; \
|
||||
else \
|
||||
$${ECHO} "$${RED}failed$${RESET}"; \
|
||||
${COLOR_ECHO} "${COLOR_RED}failed${COLOR_RESET}"; \
|
||||
echo "$${LOG}" | grep -v -E '^make(\[[[:digit:]]])?:'; \
|
||||
BUILDTESTOK=false; \
|
||||
fi; \
|
||||
@ -112,8 +121,6 @@ info-buildsizes:
|
||||
|
||||
info-buildsizes-diff: SHELL=bash
|
||||
info-buildsizes-diff:
|
||||
@GREEN='\033[1;32m'; RED='\033[1;31m'; RESET='\033[0m'; \
|
||||
\
|
||||
echo -e "text\tdata\tbss\tdec\tBOARD/BINDIRBASE\n"; \
|
||||
for BOARD in $(BOARDS); do \
|
||||
for BINDIRBASE in $${OLDBIN} $${NEWBIN}; do \
|
||||
@ -131,16 +138,16 @@ info-buildsizes-diff:
|
||||
for I in 0 1 2 3; do \
|
||||
if [[ -n "$${NEW[I]}" && -n "$${OLD[I]}" ]]; then \
|
||||
DIFF=$$(($${NEW[I]} - $${OLD[I]})); \
|
||||
if [[ "$${DIFF}" -gt 0 ]]; then echo -ne "$${RED}"; fi; \
|
||||
if [[ "$${DIFF}" -lt 0 ]]; then echo -ne "$${GREEN}"; fi; \
|
||||
if [[ "$${DIFF}" -gt 0 ]]; then $(COLOR_ECHO) -n "${COLOR_RED}"; fi; \
|
||||
if [[ "$${DIFF}" -lt 0 ]]; then $(COLOR_ECHO) -n "${COLOR_GREEN}"; fi; \
|
||||
else \
|
||||
DIFF="$${RED}ERR"; \
|
||||
fi; \
|
||||
echo -ne "$${DIFF}\t$${RESET}"; \
|
||||
done; \
|
||||
echo "$${BOARD}"; \
|
||||
for I in 0 1 2 3; do echo -ne "$${OLD[I]-$${RED}ERR$${RESET}}\t"; done; echo -e "$${OLDBIN}"; \
|
||||
for I in 0 1 2 3; do echo -ne "$${NEW[I]-$${RED}ERR$${RESET}}\t"; done; echo -e "$${NEWBIN}\n"; \
|
||||
for I in 0 1 2 3; do echo -ne "$${OLD[I]-${COLOR_RED}ERR${COLOR_RESET}}\t"; done; echo -e "$${OLDBIN}"; \
|
||||
for I in 0 1 2 3; do echo -ne "$${NEW[I]-${COLOR_RED}ERR${COLOR_RESET}}\t"; done; echo -e "$${NEWBIN}\n"; \
|
||||
done; \
|
||||
done;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user