diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2016-08-08 01:16:06 +0300 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2016-08-20 03:56:29 +0300 |
commit | db5c3b74fb6541879bfad9930d2a659b1d89cd83 (patch) | |
tree | ad500b9d7742fafc69287101a68fcecb8952dc50 /message.mk | |
parent | 0dd629a990e1546614dfa2b430489571c2550f7a (diff) | |
download | qmk_firmware-db5c3b74fb6541879bfad9930d2a659b1d89cd83.tar.gz |
Add color output
Diffstat (limited to 'message.mk')
-rw-r--r-- | message.mk | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/message.mk b/message.mk new file mode 100644 index 000000000..2ebf76a58 --- /dev/null +++ b/message.mk @@ -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;
\ No newline at end of file |