]> git.donarmstrong.com Git - qmk_firmware.git/blob - Makefile
Detect failures when running multiple tests
[qmk_firmware.git] / Makefile
1 ifndef VERBOSE
2 .SILENT:
3 endif
4
5 # Allow the silent with lower caps to work the same way as upper caps
6 ifdef silent
7     SILENT = $(silent)
8 endif
9
10 ifdef SILENT
11     SUB_IS_SILENT := $(SILENT)
12 endif
13
14 # We need to make sure that silent is always turned off at the top level
15 # Otherwise the [OK], [ERROR] and [WARN] messags won't be displayed correctly
16 override SILENT := false
17
18 ON_ERROR := error_occured=1
19
20 STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
21 ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
22 ROOT_DIR := $(dir $(ROOT_MAKEFILE))
23 ifeq ($(ROOT_DIR),)
24     ROOT_DIR := .
25 endif
26 ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
27 ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
28 ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
29 ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
30 STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
31 TEST_DIR := $(ROOT_DIR)/.build/test
32
33 MAKEFILE_INCLUDED=yes
34
35 # Helper function to process the newt element of a space separated path 
36 # It works a bit like the traditional functional head tail
37 # so the CURRENT_PATH_ELEMENT will beome the new head
38 # and the PATH_ELEMENTS are the rest that are still unprocessed
39 define NEXT_PATH_ELEMENT
40     $$(eval CURRENT_PATH_ELEMENT := $$(firstword  $$(PATH_ELEMENTS)))
41     $$(eval PATH_ELEMENTS := $$(wordlist  2,9999,$$(PATH_ELEMENTS)))
42 endef
43
44 # We change the / to spaces so that we more easily can work with the elements 
45 # separately
46 PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR))
47 # Initialize the path elements list for further processing
48 $(eval $(call NEXT_PATH_ELEMENT))
49
50 # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct 
51 # variables depending on which directory you stand in.
52 # It's really a very simple if else chain, if you squint enough, 
53 # but the makefile syntax makes it very verbose. 
54 # If we are in a subfolder of keyboards
55 ifeq ($(CURRENT_PATH_ELEMENT),keyboards)
56     $(eval $(call NEXT_PATH_ELEMENT))
57     KEYBOARD := $(CURRENT_PATH_ELEMENT)
58     $(eval $(call NEXT_PATH_ELEMENT))
59     # If we are in a subfolder of keymaps, or in other words in a keymap
60     # folder
61     ifeq ($(CURRENT_PATH_ELEMENT),keymaps)
62         $(eval $(call NEXT_PATH_ELEMENT))
63         KEYMAP := $(CURRENT_PATH_ELEMENT)
64      # else if we are not in the keyboard folder itself
65     else ifneq ($(CURRENT_PATH_ELEMENT),)
66         # the we can assume it's a subproject, as no other folders
67         # should have make files in them
68         SUBPROJECT := $(CURRENT_PATH_ELEMENT)
69         $(eval $(call NEXT_PATH_ELEMENT))
70         # if we are inside a keymap folder of a subproject
71         ifeq ($(CURRENT_PATH_ELEMENT),keymaps)
72             $(eval $(call NEXT_PATH_ELEMENT))
73             KEYMAP := $(CURRENT_PATH_ELEMENT)
74         endif
75     endif
76 endif
77
78 # Only consider folders with makefiles, to prevent errors in case there are extra folders
79 KEYBOARDS := $(notdir $(patsubst %/Makefile,%,$(wildcard $(ROOT_DIR)/keyboards/*/Makefile)))
80
81 #Compability with the old make variables, anything you specify directly on the command line
82 # always overrides the detected folders
83 ifdef keyboard
84     KEYBOARD := $(keyboard)
85 endif
86 ifdef sub
87     SUBPROJECT := $(sub)
88 endif
89 ifdef subproject
90     SUBPROJECT := $(subproject)
91 endif
92 ifdef keymap
93     KEYMAP := $(keymap)
94 endif
95
96 # Uncomment these for debugging
97 #$(info Keyboard: $(KEYBOARD))
98 #$(info Keymap: $(KEYMAP))
99 #$(info Subproject: $(SUBPROJECT))
100 #$(info Keyboards: $(KEYBOARDS))
101
102
103 # Set the default goal depening on where we are running make from
104 # this handles the case where you run make without any arguments
105 .DEFAULT_GOAL := all
106 ifneq ($(KEYMAP),)
107     ifeq ($(SUBPROJECT),)
108          # Inside a keymap folder, just build the keymap, with the 
109          # default subproject
110         .DEFAULT_GOAL := $(KEYBOARD)-$(KEYMAP)
111     else
112          # Inside a subproject keyamp folder, build the keymap
113          # for that subproject
114         .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-$(KEYMAP)
115     endif
116 else ifneq ($(SUBPROJECT),)
117      # Inside a subproject folder, build all keymaps for that subproject
118     .DEFAULT_GOAL := $(KEYBOARD)-$(SUBPROJECT)-allkm
119 else ifneq ($(KEYBOARD),)
120      # Inside a keyboard folder, build all keymaps for all subprojects
121      # Note that this is different from the old behaviour, which would
122      # build only the default keymap of the default keyboard
123     .DEFAULT_GOAL := $(KEYBOARD)-allsp-allkm
124 endif
125
126
127 # Compare the start of the RULE variable with the first argument($1)
128 # If the rules equals $1 or starts with $1-, RULE_FOUND is set to true
129 #     and $1 is removed from the RULE variable
130 # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
131 # The function is a bit tricky, since there's no built in $(startswith) function
132 define COMPARE_AND_REMOVE_FROM_RULE_HELPER
133     ifeq ($1,$$(RULE))
134         RULE:=
135         RULE_FOUND := true
136     else
137         STARTDASH_REMOVED=$$(subst START$1-,,START$$(RULE))
138         ifneq ($$(STARTDASH_REMOVED),START$$(RULE))
139             RULE_FOUND := true
140             RULE := $$(STARTDASH_REMOVED)
141         else
142             RULE_FOUND := false
143         endif
144     endif
145 endef
146
147 # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
148 # a function that returns the value
149 COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
150
151
152 # Recursively try to find a match for the start of the rule to be checked
153 # $1 The list to be checked
154 # If a match is found, then RULE_FOUND is set to true
155 # and MATCHED_ITEM to the item that was matched
156 define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
157     ifneq ($1,)
158         ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true)
159             MATCHED_ITEM := $$(firstword $1)
160         else 
161             $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1)))
162         endif
163     endif
164 endef
165
166 # A recursive helper function for finding the longest match
167 # $1 The list to be checed
168 # It works by always removing the currently matched item from the list 
169 # and call itself recursively, until a match is found
170 define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
171     # Stop the recursion when the list is empty 
172     ifneq ($1,)
173         RULE_BEFORE := $$(RULE)
174         $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
175         # If a match is found in the current list, otherwise just return what we had before
176         ifeq ($$(RULE_FOUND),true)
177             # Save the best match so far and call itself recursivel
178             BEST_MATCH := $$(MATCHED_ITEM)
179             BEST_MATCH_RULE := $$(RULE)
180             RULE_FOUND := false
181             RULE := $$(RULE_BEFORE)
182             $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$$(filter-out $$(MATCHED_ITEM),$1)))
183         endif
184      endif
185 endef
186
187
188 # Recursively try to find the longest match for the start of the rule to be checked
189 # $1 The list to be checked
190 # If a match is found, then RULE_FOUND is set to true
191 # and MATCHED_ITEM to the item that was matched
192 define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
193     BEST_MATCH :=
194     $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$1))
195     ifneq ($$(BEST_MATCH),)
196         RULE_FOUND := true
197         RULE := $$(BEST_MATCH_RULE)
198         MATCHED_ITEM := $$(BEST_MATCH)
199     else
200         RULE_FOUND := false
201         MATCHED_ITEM :=
202     endif
203 endef
204
205 # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
206 TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
207
208 define ALL_IN_LIST_LOOP
209     OLD_RULE$1 := $$(RULE)
210     $$(eval $$(call $1,$$(ITEM$1)))
211     RULE := $$(OLD_RULE$1)
212 endef
213
214 define PARSE_ALL_IN_LIST
215     $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
216 endef
217
218 # The entry point for rule parsing
219 # parses a rule in the format <keyboard>-<subproject>-<keymap>-<target>
220 # but this particular function only deals with the first <keyboard> part
221 define PARSE_RULE
222     RULE := $1
223     COMMANDS :=
224     # If the rule starts with allkb, then continue the parsing from
225     # PARSE_ALL_KEYBOARDS
226     ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkb),true)
227         $$(eval $$(call PARSE_ALL_KEYBOARDS))
228     else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
229         $$(eval $$(call PARSE_TEST))
230     # If the rule starts with the name of a known keyboard, then continue
231     # the parsing from PARSE_KEYBOARD
232     else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYBOARDS)),true)
233         $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
234     # Otherwise use the KEYBOARD variable, which is determined either by
235     # the current directory you run make from, or passed in as an argument
236     else ifneq ($$(KEYBOARD),)
237         $$(eval $$(call PARSE_KEYBOARD,$$(KEYBOARD)))
238     else
239         $$(info make: *** No rule to make target '$1'. Stop.)
240         # Notice the tab instead of spaces below!
241                 exit 1
242     endif
243 endef
244
245 # $1 = Keyboard
246 # Parses a rule in the format <subproject>-<keymap>-<target>
247 # the keyboard is already known when entering this function
248 define PARSE_KEYBOARD
249     CURRENT_KB := $1
250     # A subproject is any keyboard subfolder with a makefile
251     SUBPROJECTS := $$(notdir $$(patsubst %/Makefile,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/*/Makefile)))
252     # if the rule starts with allsp, then continue with looping over all subprojects
253     ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allsp),true)
254         $$(eval $$(call PARSE_ALL_SUBPROJECTS))
255     # A special case for matching the defaultsp (default subproject)
256     else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,defaultsp),true)
257         $$(eval $$(call PARSE_SUBPROJECT,defaultsp))
258     # If the rule starts with the name of a known subproject
259     else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(SUBPROJECTS)),true)
260         $$(eval $$(call PARSE_SUBPROJECT,$$(MATCHED_ITEM)))
261     # Try to use the SUBPROJECT variable, which is either determined by the
262     # directory which invoked make, or passed as an argument to make
263     else ifneq ($$(SUBPROJECT),)
264         $$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT)))
265         # If there's no matching subproject, we assume it's the default
266         # This will allow you to leave the subproject part of the target out
267     else 
268         $$(eval $$(call PARSE_SUBPROJECT,))
269     endif
270 endef
271
272 # if we are going to compile all keyboards, match the rest of the rule
273 # for each of them
274 define PARSE_ALL_KEYBOARDS
275     $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(KEYBOARDS)))
276 endef
277
278 # $1 Subproject
279 # When entering this, the keyboard and subproject are known, so now we need
280 # to determine which keymaps are going to get compiled
281 define PARSE_SUBPROJECT
282     # If we want to compile the default subproject, then we need to 
283     # include the correct makefile to determine the actual name of it
284     CURRENT_SP := $1
285     ifeq ($$(CURRENT_SP),)
286         CURRENT_SP := defaultsp
287     endif
288     ifeq ($$(CURRENT_SP),defaultsp)
289         SUBPROJECT_DEFAULT=
290         $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/Makefile)
291         CURRENT_SP := $$(SUBPROJECT_DEFAULT)
292     endif
293     # If current subproject is empty (the default was not defined), and we have a list of subproject
294     # then make all of them
295     ifeq ($$(CURRENT_SP),)
296         ifneq ($$(SUBPROJECTS),)
297             CURRENT_SP := allsp
298          endif
299     endif
300     # The special allsp is handled later
301     ifneq ($$(CURRENT_SP),allsp) 
302         # get a list of all keymaps
303         KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/keymaps/*/.)))
304         ifneq ($$(CURRENT_SP),)
305             # if the subproject is defined, then also look for keymaps inside the subproject folder
306             SP_KEYMAPS := $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/$$(CURRENT_SP)/keymaps/*/.)))
307             KEYMAPS := $$(sort $$(KEYMAPS) $$(SP_KEYMAPS))
308         endif
309         # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
310         # compile all the keymaps
311         ifeq ($$(RULE),)
312             $$(eval $$(call PARSE_ALL_KEYMAPS))
313         # The same if allkm was specified
314         else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,allkm),true)
315             $$(eval $$(call PARSE_ALL_KEYMAPS))
316         # Try to match the specified keyamp with the list of known keymaps
317         else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
318             $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
319         # Otherwise try to match the keymap from the current folder, or arguments to the make command
320         else ifneq ($$(KEYMAP),)
321             $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
322         # No matching keymap found, so we assume that the rest of the rule is the target
323         # If we haven't been able to parse out a subproject, then make all of them
324         # This is consistent with running make without any arguments from the keyboard
325         # folder
326         else ifeq ($1,)
327             $$(eval $$(call PARSE_ALL_SUBPROJECTS))
328         # Otherwise, make all keymaps, again this is consistent with how it works without
329         # any arguments
330         else
331             $$(eval $$(call PARSE_ALL_KEYMAPS))
332         endif
333     else
334         # As earlier mentione,d when allsb is specified, we call our self recursively
335         # for all of the subprojects
336         $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$(SUBPROJECTS)))
337     endif
338 endef
339
340 # If we want to parse all subprojects, but the keyboard doesn't have any, 
341 # then use defaultsp instead
342 define PARSE_ALL_SUBPROJECTS
343     ifeq ($$(SUBPROJECTS),)
344         $$(eval $$(call PARSE_SUBPROJECT,defaultsp))
345     else
346         $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_SUBPROJECT,$$(SUBPROJECTS)))
347     endif
348 endef
349
350 # $1 Keymap
351 # This is the meat of compiling a keyboard, when entering this, everything is known
352 # keyboard, subproject, and keymap
353 # Note that we are not directly calling the command here, but instead building a list,
354 # which will later be processed
355 define PARSE_KEYMAP
356     CURRENT_KM = $1
357     # The rest of the rule is the target
358     # Remove the leading "-" from the target, as it acts as a separator
359     MAKE_TARGET := $$(patsubst -%,%,$$(RULE))
360     # We need to generate an unique indentifer to append to the COMMANDS list
361     COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB)_SUBPROJECT_$(CURRENT_SP)_KEYMAP_$$(CURRENT_KM)
362     # If we are compiling a keyboard without a subproject, we want to display just the name
363     # of the keyboard, otherwise keyboard/subproject
364     ifeq ($$(CURRENT_SP),)
365         KB_SP := $(CURRENT_KB)
366     else
367         KB_SP := $(CURRENT_KB)/$$(CURRENT_SP)
368     endif
369     # Format it in bold
370     KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
371     # Specify the variables that we are passing forward to submake
372     MAKE_VARS := KEYBOARD=$$(CURRENT_KB) SUBPROJECT=$$(CURRENT_SP) KEYMAP=$$(CURRENT_KM)
373     # And the first part of the make command
374     MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET)
375     # The message to display
376     MAKE_MSG := $$(MSG_MAKE_KB)
377     # We run the command differently, depending on if we want more output or not
378     # The true version for silent output and the false version otherwise
379     $$(eval $$(call BUILD))
380 endef
381
382 define BUILD
383     MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
384     COMMANDS += $$(COMMAND)
385     COMMAND_true_$$(COMMAND) := \
386         printf "$$(MAKE_MSG)" | \
387         $$(MAKE_MSG_FORMAT); \
388         LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
389         if [ $$$$? -gt 0 ]; \
390             then $$(PRINT_ERROR_PLAIN); \
391         elif [ "$$$$LOG" != "" ] ; \
392             then $$(PRINT_WARNING_PLAIN); \
393         else \
394             $$(PRINT_OK); \
395         fi;
396     COMMAND_false_$$(COMMAND) := \
397         printf "$$(MAKE_MSG)\n\n"; \
398         $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
399         if [ $$$$? -gt 0 ]; \
400             then error_occured=1; \
401         fi;
402 endef
403
404 # Just parse all the keymaps for a specifc keyboard
405 define PARSE_ALL_KEYMAPS
406     $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
407 endef
408
409 define BUILD_TEST
410     TEST_NAME := $1
411     MAKE_TARGET := $2
412     COMMAND := $1
413     MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
414     MAKE_VARS := TEST=$$(TEST_NAME)
415     MAKE_MSG := $$(MSG_MAKE_TEST)
416     $$(eval $$(call BUILD))
417     TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf
418     TESTS += $$(TEST_NAME)
419     TEST_MSG := $$(MSG_TEST)
420     $$(TEST_NAME)_COMMAND := \
421         printf "$$(TEST_MSG)\n"; \
422         $$(TEST_EXECUTABLE); \
423         if [ $$$$? -gt 0 ]; \
424             then error_occured=1; \
425         fi; \
426         printf "\n";
427 endef
428
429 define PARSE_TEST
430     TESTS :=
431     TEST_NAME := $$(firstword $$(subst -, ,$$(RULE)))
432     TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME)-,,$$(RULE)))
433     MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),))
434     $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
435 endef
436
437
438 # Set the silent mode depending on if we are trying to compile multiple keyboards or not
439 # By default it's on in that case, but it can be overriden by specifying silent=false 
440 # from the command line
441 define SET_SILENT_MODE
442     ifdef SUB_IS_SILENT
443         SILENT_MODE := $(SUB_IS_SILENT)
444     else ifeq ($$(words $$(COMMANDS)),1)
445         SILENT_MODE := false
446     else
447         SILENT_MODE := true
448     endif
449 endef
450
451 include $(ROOT_DIR)/message.mk
452
453 RUN_COMMAND = \
454 $(COMMAND_$(SILENT_MODE)_$(COMMAND))
455
456 # Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
457 SUBPROJECTS := $(notdir $(patsubst %/Makefile,%,$(wildcard ./*/Makefile)))
458 .PHONY: $(SUBPROJECTS)
459 $(SUBPROJECTS): %: %-allkm 
460
461 # Let's match everything, we handle all the rule parsing ourselves
462 .PHONY: %
463 %: 
464         # Check if we have the CMP tool installed
465         cmp --version >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
466         # Check if the submodules are dirty, and display a warning if they are
467         git submodule status --recursive 2>/dev/null | \
468         while IFS= read -r x; do \
469                 case "$$x" in \
470                         \ *) ;; \
471                         *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
472                 esac \
473         done
474         $(eval $(call PARSE_RULE,$@))
475         $(eval $(call SET_SILENT_MODE))
476         # Run all the commands in the same shell, notice the + at the first line
477         # it has to be there to allow parallel execution of the submake
478         # This always tries to compile everything, even if error occurs in the middle
479         # But we return the error code at the end, to trigger travis failures
480         +error_occured=0; \
481         $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND)) \
482         if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\
483         $(foreach TEST,$(TESTS),$($(TEST)_COMMAND)) \
484         if [ $$error_occured -gt 0 ]; then printf "$(MSG_ERRORS)" & exit $$error_occured; fi;\
485
486 # All should compile everything
487 .PHONY: all
488 all: all-keyboards 
489
490 # Define some shortcuts, mostly for compability with the old syntax
491 .PHONY: all-keyboards
492 all-keyboards: allkb-allsp-allkm
493
494 .PHONY: all-keyboards-defaults
495 all-keyboards-defaults: allkb-allsp-default
496
497
498 # Generate the version.h file
499 GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
500 BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S")
501 $(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
502 $(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
503
504 include $(ROOT_DIR)/testlist.mk