Add color output
This commit is contained in:
parent
0dd629a990
commit
db5c3b74fb
33
Makefile
33
Makefile
|
@ -1,3 +1,7 @@
|
||||||
|
ifndef VERBOSE
|
||||||
|
.SILENT:
|
||||||
|
endif
|
||||||
|
|
||||||
STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
||||||
ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||||
ROOT_DIR := $(dir $(ROOT_MAKEFILE))
|
ROOT_DIR := $(dir $(ROOT_MAKEFILE))
|
||||||
|
@ -216,15 +220,37 @@ endef
|
||||||
# $1 Keymap
|
# $1 Keymap
|
||||||
define PARSE_KEYMAP
|
define PARSE_KEYMAP
|
||||||
CURRENT_KM = $1
|
CURRENT_KM = $1
|
||||||
COMMANDS += KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
|
COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
|
||||||
COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM) := Keyboard $$(CURRENT_KB), Subproject $$(CURRENT_SP), Keymap $$(CURRENT_KM)
|
COMMANDS += $$(COMMAND)
|
||||||
|
ifeq ($$(CURRENT_SP),)
|
||||||
|
KB_SP := $(CURRENT_KB)
|
||||||
|
else
|
||||||
|
KB_SP := $(CURRENT_KB)/$$(CURRENT_SP)
|
||||||
|
endif
|
||||||
|
KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
|
||||||
|
COMMAND_$$(COMMAND) := \
|
||||||
|
printf "Compiling $$(KB_SP) with $(BOLD)$$(CURRENT_KM)$(NO_COLOR)" | \
|
||||||
|
$(AWK) '{ printf "%-118s", $$$$0;}'; \
|
||||||
|
LOG=$$$$(echo "$$(MAKE) -c $(ROOT_DIR) -f build_keyboard.mk VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true" 2>&1) ; \
|
||||||
|
if [ $$$$? -gt 0 ]; \
|
||||||
|
then $$(PRINT_ERROR_PLAIN); \
|
||||||
|
elif [ "$$$$LOG" != "" ] ; \
|
||||||
|
then $$(PRINT_WARNING_PLAIN); \
|
||||||
|
else \
|
||||||
|
$$(PRINT_OK); \
|
||||||
|
fi;
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define PARSE_ALL_KEYMAPS
|
define PARSE_ALL_KEYMAPS
|
||||||
$$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
|
$$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
RUN_COMMAND = echo "Running": $(COMMAND_$(COMMAND));
|
include $(ROOT_DIR)/message.mk
|
||||||
|
|
||||||
|
#RUN_COMMAND = echo "Running": $(COMMAND_$(COMMAND));
|
||||||
|
RUN_COMMAND = \
|
||||||
|
$(COMMAND_$(COMMAND))
|
||||||
|
#LOG=$$(echo $(COMMAND) VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR_PLAIN); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_PLAIN); else $(PRINT_OK); fi; \
|
||||||
|
|
||||||
# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
|
# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
|
||||||
SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
|
SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
|
||||||
|
@ -244,3 +270,4 @@ all-keyboards: allkb-allsp-allkm
|
||||||
|
|
||||||
.PHONY: all-keyboards-defaults
|
.PHONY: all-keyboards-defaults
|
||||||
all-keyboards-defaults: allkb-allsp-default
|
all-keyboards-defaults: allkb-allsp-default
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
COLOR ?= true
|
||||||
|
|
||||||
|
ifeq ($(COLOR),true)
|
||||||
|
NO_COLOR=\033[0m
|
||||||
|
OK_COLOR=\033[32;01m
|
||||||
|
ERROR_COLOR=\033[31;01m
|
||||||
|
WARN_COLOR=\033[33;01m
|
||||||
|
BLUE=\033[0;34m
|
||||||
|
BOLD=\033[1m
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(shell awk --version 2>/dev/null),)
|
||||||
|
AWK=awk
|
||||||
|
else
|
||||||
|
AWK=cat && test
|
||||||
|
endif
|
||||||
|
|
||||||
|
OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
|
||||||
|
ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
|
||||||
|
WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
|
||||||
|
|
||||||
|
ifndef $(SILENT)
|
||||||
|
SILENT = false
|
||||||
|
endif
|
||||||
|
|
||||||
|
TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }'
|
||||||
|
TAB_LOG_PLAIN = printf "$$LOG\n"
|
||||||
|
AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
|
||||||
|
AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }'
|
||||||
|
PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && exit 1
|
||||||
|
PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG)
|
||||||
|
PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1
|
||||||
|
PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
|
||||||
|
PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
|
||||||
|
BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi;
|
Loading…
Reference in New Issue