aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-08-08 01:16:06 +0300
committerFred Sundvik <fsundvik@gmail.com>2016-08-20 03:56:29 +0300
commitdb5c3b74fb6541879bfad9930d2a659b1d89cd83 (patch)
treead500b9d7742fafc69287101a68fcecb8952dc50
parent0dd629a990e1546614dfa2b430489571c2550f7a (diff)
downloadqmk_firmware-db5c3b74fb6541879bfad9930d2a659b1d89cd83.tar.gz
qmk_firmware-db5c3b74fb6541879bfad9930d2a659b1d89cd83.zip
Add color output
-rw-r--r--Makefile33
-rw-r--r--message.mk35
2 files changed, 65 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index a02fa24a2..e5becd7ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,7 @@
1ifndef VERBOSE
2.SILENT:
3endif
4
1STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST)) 5STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
2ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST)) 6ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
3ROOT_DIR := $(dir $(ROOT_MAKEFILE)) 7ROOT_DIR := $(dir $(ROOT_MAKEFILE))
@@ -216,15 +220,37 @@ endef
216# $1 Keymap 220# $1 Keymap
217define PARSE_KEYMAP 221define PARSE_KEYMAP
218 CURRENT_KM = $1 222 CURRENT_KM = $1
219 COMMANDS += KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM) 223 COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
220 COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM) := Keyboard $$(CURRENT_KB), Subproject $$(CURRENT_SP), Keymap $$(CURRENT_KM) 224 COMMANDS += $$(COMMAND)
225 ifeq ($$(CURRENT_SP),)
226 KB_SP := $(CURRENT_KB)
227 else
228 KB_SP := $(CURRENT_KB)/$$(CURRENT_SP)
229 endif
230 KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
231 COMMAND_$$(COMMAND) := \
232 printf "Compiling $$(KB_SP) with $(BOLD)$$(CURRENT_KM)$(NO_COLOR)" | \
233 $(AWK) '{ printf "%-118s", $$$$0;}'; \
234 LOG=$$$$(echo "$$(MAKE) -c $(ROOT_DIR) -f build_keyboard.mk VERBOSE=$(VERBOSE) COLOR=$(COLOR) SILENT=true" 2>&1) ; \
235 if [ $$$$? -gt 0 ]; \
236 then $$(PRINT_ERROR_PLAIN); \
237 elif [ "$$$$LOG" != "" ] ; \
238 then $$(PRINT_WARNING_PLAIN); \
239 else \
240 $$(PRINT_OK); \
241 fi;
221endef 242endef
222 243
223define PARSE_ALL_KEYMAPS 244define PARSE_ALL_KEYMAPS
224 $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS))) 245 $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
225endef 246endef
226 247
227RUN_COMMAND = echo "Running": $(COMMAND_$(COMMAND)); 248include $(ROOT_DIR)/message.mk
249
250#RUN_COMMAND = echo "Running": $(COMMAND_$(COMMAND));
251RUN_COMMAND = \
252$(COMMAND_$(COMMAND))
253#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; \
228 254
229# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps 255# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
230SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile))) 256SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
@@ -244,3 +270,4 @@ all-keyboards: allkb-allsp-allkm
244 270
245.PHONY: all-keyboards-defaults 271.PHONY: all-keyboards-defaults
246all-keyboards-defaults: allkb-allsp-default 272all-keyboards-defaults: allkb-allsp-default
273
diff --git a/message.mk b/message.mk
new file mode 100644
index 000000000..2ebf76a58
--- /dev/null
+++ b/message.mk
@@ -0,0 +1,35 @@
1COLOR ?= true
2
3ifeq ($(COLOR),true)
4 NO_COLOR=\033[0m
5 OK_COLOR=\033[32;01m
6 ERROR_COLOR=\033[31;01m
7 WARN_COLOR=\033[33;01m
8 BLUE=\033[0;34m
9 BOLD=\033[1m
10endif
11
12ifneq ($(shell awk --version 2>/dev/null),)
13 AWK=awk
14else
15 AWK=cat && test
16endif
17
18OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
19ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
20WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
21
22ifndef $(SILENT)
23 SILENT = false
24endif
25
26TAB_LOG = printf "\n$$LOG\n\n" | $(AWK) '{ sub(/^/," | "); print }'
27TAB_LOG_PLAIN = printf "$$LOG\n"
28AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
29AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }'
30PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && exit 1
31PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG)
32PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && exit 1
33PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
34PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
35BUILD_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