@@ -38,7 +38,7 @@ ERROR_FILE := $(BUILD_DIR)/error_occured
38
38
39
39
MAKEFILE_INCLUDED =yes
40
40
41
- # Helper function to process the newt element of a space separated path
41
+ # Helper function to process the newt element of a space separated path
42
42
# It works a bit like the traditional functional head tail
43
43
# so the CURRENT_PATH_ELEMENT will beome the new head
44
44
# and the PATH_ELEMENTS are the rest that are still unprocessed
@@ -47,16 +47,16 @@ define NEXT_PATH_ELEMENT
47
47
$$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS ) ) )
48
48
endef
49
49
50
- # We change the / to spaces so that we more easily can work with the elements
50
+ # We change the / to spaces so that we more easily can work with the elements
51
51
# separately
52
52
PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR ) )
53
53
# Initialize the path elements list for further processing
54
54
$(eval $(call NEXT_PATH_ELEMENT))
55
55
56
- # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct
56
+ # This function sets the KEYBOARD; KEYMAP and SUBPROJECT to the correct
57
57
# variables depending on which directory you stand in.
58
- # It's really a very simple if else chain, if you squint enough,
59
- # but the makefile syntax makes it very verbose.
58
+ # It's really a very simple if else chain, if you squint enough,
59
+ # but the makefile syntax makes it very verbose.
60
60
# If we are in a subfolder of keyboards
61
61
ifeq ($(CURRENT_PATH_ELEMENT ) ,keyboards)
62
62
$(eval $(call NEXT_PATH_ELEMENT))
@@ -111,7 +111,7 @@ endif
111
111
.DEFAULT_GOAL := all
112
112
ifneq ($(KEYMAP ) ,)
113
113
ifeq ($(SUBPROJECT),)
114
- # Inside a keymap folder, just build the keymap, with the
114
+ # Inside a keymap folder, just build the keymap, with the
115
115
# default subproject
116
116
.DEFAULT_GOAL := $(KEYBOARD ) -$(KEYMAP )
117
117
else
@@ -163,18 +163,18 @@ define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
163
163
ifneq ($1,)
164
164
ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1) ) ,true)
165
165
MATCHED_ITEM := $$(firstword $1)
166
- else
166
+ else
167
167
$$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1) ) )
168
168
endif
169
169
endif
170
170
endef
171
171
172
172
# A recursive helper function for finding the longest match
173
173
# $1 The list to be checed
174
- # It works by always removing the currently matched item from the list
174
+ # It works by always removing the currently matched item from the list
175
175
# and call itself recursively, until a match is found
176
176
define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
177
- # Stop the recursion when the list is empty
177
+ # Stop the recursion when the list is empty
178
178
ifneq ($1,)
179
179
RULE_BEFORE := $$(RULE )
180
180
$$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1) )
@@ -270,7 +270,7 @@ define PARSE_KEYBOARD
270
270
$$(eval $$(call PARSE_SUBPROJECT,$$(SUBPROJECT ) ) )
271
271
# If there's no matching subproject, we assume it's the default
272
272
# This will allow you to leave the subproject part of the target out
273
- else
273
+ else
274
274
$$(eval $$(call PARSE_SUBPROJECT,) )
275
275
endif
276
276
endef
@@ -285,7 +285,7 @@ endef
285
285
# When entering this, the keyboard and subproject are known, so now we need
286
286
# to determine which keymaps are going to get compiled
287
287
define PARSE_SUBPROJECT
288
- # If we want to compile the default subproject, then we need to
288
+ # If we want to compile the default subproject, then we need to
289
289
# include the correct makefile to determine the actual name of it
290
290
CURRENT_SP := $1
291
291
ifeq ($$(CURRENT_SP ) ,)
@@ -304,7 +304,7 @@ define PARSE_SUBPROJECT
304
304
endif
305
305
endif
306
306
# The special allsp is handled later
307
- ifneq ($$(CURRENT_SP ) ,allsp)
307
+ ifneq ($$(CURRENT_SP ) ,allsp)
308
308
# get a list of all keymaps
309
309
KEYMAPS := $$(notdir $$(patsubst % /.,% ,$$(wildcard $(ROOT_DIR ) /keyboards/$$(CURRENT_KB ) /keymaps/* /.) ) )
310
310
ifneq ($$(CURRENT_SP ) ,)
@@ -343,7 +343,7 @@ define PARSE_SUBPROJECT
343
343
endif
344
344
endef
345
345
346
- # If we want to parse all subprojects, but the keyboard doesn't have any,
346
+ # If we want to parse all subprojects, but the keyboard doesn't have any,
347
347
# then use defaultsp instead
348
348
define PARSE_ALL_SUBPROJECTS
349
349
ifeq ($$(SUBPROJECTS ) ,)
@@ -448,7 +448,7 @@ endef
448
448
449
449
450
450
# Set the silent mode depending on if we are trying to compile multiple keyboards or not
451
- # By default it's on in that case, but it can be overriden by specifying silent=false
451
+ # By default it's on in that case, but it can be overriden by specifying silent=false
452
452
# from the command line
453
453
define SET_SILENT_MODE
454
454
ifdef SUB_IS_SILENT
@@ -481,11 +481,12 @@ endef
481
481
# Allow specifying just the subproject, in the keyboard directory, which will compile all keymaps
482
482
SUBPROJECTS := $(notdir $(patsubst % /Makefile,% ,$(wildcard ./* /Makefile) ) )
483
483
.PHONY : $(SUBPROJECTS )
484
- $(SUBPROJECTS ) : % : % -allkm
484
+ $(SUBPROJECTS ) : % : % -allkm
485
485
486
486
# Let's match everything, we handle all the rule parsing ourselves
487
487
.PHONY : %
488
- % :
488
+ ifndef SKIP_GIT
489
+ % :
489
490
# Check if we have the CMP tool installed
490
491
cmp --version > /dev/null 2>&1 ; if [ $$ ? -gt 0 ]; then printf " $( MSG_NO_CMP) " ; exit 1; fi ;
491
492
# Check if the submodules are dirty, and display a warning if they are
@@ -505,8 +506,24 @@ $(SUBPROJECTS): %: %-allkm
505
506
# But we return the error code at the end, to trigger travis failures
506
507
$(foreach COMMAND,$(COMMANDS ) ,$(RUN_COMMAND ) )
507
508
if [ -f $( ERROR_FILE) ]; then printf " $( MSG_ERRORS) " & exit 1; fi ;
508
- $(foreach TEST,$(TESTS ) ,$(RUN_TEST ) )
509
+ $(foreach TEST,$(TESTS ) ,$(RUN_TEST ) )
510
+ if [ -f $( ERROR_FILE) ]; then printf " $( MSG_ERRORS) " & exit 1; fi ;
511
+ else
512
+ % :
513
+ # Check if we have the CMP tool installed
514
+ cmp --version > /dev/null 2>&1 ; if [ $$ ? -gt 0 ]; then printf " $( MSG_NO_CMP) " ; exit 1; fi ;
515
+ rm -f $(ERROR_FILE ) > /dev/null 2>&1
516
+ $(eval $(call PARSE_RULE,$@ ) )
517
+ $(eval $(call SET_SILENT_MODE) )
518
+ # Run all the commands in the same shell, notice the + at the first line
519
+ # it has to be there to allow parallel execution of the submake
520
+ # This always tries to compile everything, even if error occurs in the middle
521
+ # But we return the error code at the end, to trigger travis failures
522
+ $(foreach COMMAND,$(COMMANDS ) ,$(RUN_COMMAND ) )
523
+ if [ -f $( ERROR_FILE) ]; then printf " $( MSG_ERRORS) " & exit 1; fi ;
524
+ $(foreach TEST,$(TESTS ) ,$(RUN_TEST ) )
509
525
if [ -f $( ERROR_FILE) ]; then printf " $( MSG_ERRORS) " & exit 1; fi ;
526
+ endif
510
527
511
528
# All should compile everything
512
529
.PHONY : all
@@ -526,7 +543,11 @@ test: test-all
526
543
test-clean : test-all-clean
527
544
528
545
# Generate the version.h file
529
- GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"% Y-% m-% d-% H:% M:% S")
546
+ ifndef SKIP_GIT
547
+ GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"% Y-% m-% d-% H:% M:% S")
548
+ else
549
+ GIT_VERSION := NA
550
+ endif
530
551
BUILD_DATE := $(shell date +"% Y-% m-% d-% H:% M:% S")
531
552
$(shell echo '# define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
532
553
$(shell echo '# define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
0 commit comments