diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2016-08-03 08:28:47 +0200 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2016-08-20 02:24:40 +0200 |
commit | f97ae2b199df087f4b48c7019c2d887089d81614 (patch) | |
tree | aea6c3062fd065beb460d5aea61987d60603e550 /Makefile | |
parent | e6e675335dbaa6bd175be7aaee829c717e572488 (diff) | |
download | qmk_firmware-f97ae2b199df087f4b48c7019c2d887089d81614.tar.gz qmk_firmware-f97ae2b199df087f4b48c7019c2d887089d81614.tar.xz |
Rule parsing to match kebyoards
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1,5 +1,9 @@ STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST)) ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +ROOT_DIR := $(dir, $(ROOT_MAKEFILE)) +ifeq ($(ROOT_DIR),) + ROOT_DIR := . +endif ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE)) ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE)) ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE)) @@ -32,9 +36,14 @@ ifeq ($(CURRENT_PATH_ELEMENT),keyboards) endif endif +$(info $(ROOT_DIR)/keyboards) +KEYBOARDS := $(notdir $(patsubst %/.,%,$(wildcard $(ROOT_DIR)/keyboards/*/.))) + $(info Keyboard: $(KEYBOARD)) $(info Keymap: $(KEYMAP)) $(info Subproject: $(SUBPROJECT)) +$(info Keyboards: $(KEYBOARDS)) + # Compare the start of the RULE_VARIABLE with the first argument($1) # If the rules equals $1 or starts with $1-, RULE_FOUND is set to true @@ -62,12 +71,34 @@ define PARSE_ALL_KEYBOARDS COMMAND_allkb := "All keyboards with $$(RULE)" endef +define PARSE_KEYBOARD + COMMANDS += $1 + #$$(info $$(RULE)) + COMMAND_$1 := "Keyboard $1 with $$(RULE)" +endef + + +# Recursively try to find a matching keyboard +# During the first call $1 contains a list of all keyboards +# One keyboard is checked and removed at a time +define TRY_PARSE_KEYBOARD + CURRENT_KB := $$(firstword $1) + $$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,$$(CURRENT_KB))) + ifeq ($$(RULE_FOUND),true) + $$(eval $$(call PARSE_KEYBOARD,$$(CURRENT_KB))) + else ifneq ($1,) + $$(eval $$(call TRY_PARSE_KEYBOARD,$$(wordlist 2,9999,$1))) + endif +endef + define PARSE_RULE RULE := $1 COMMANDS := $$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allkb)) ifeq ($$(RULE_FOUND),true) $$(eval $$(call PARSE_ALL_KEYBOARDS)) + else + $$(eval $$(call TRY_PARSE_KEYBOARD,$(KEYBOARDS))) endif endef |