summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-08-03 07:44:11 +0200
committerFred Sundvik <fsundvik@gmail.com>2016-08-20 02:24:40 +0200
commite6e675335dbaa6bd175be7aaee829c717e572488 (patch)
tree8cae6efffad6f68a7cf5f465267e6fe4bbdf70e0 /Makefile
parent86706de036cf7ad52b679b259ca8f980057d0da5 (diff)
downloadqmk_firmware-e6e675335dbaa6bd175be7aaee829c717e572488.tar.gz
qmk_firmware-e6e675335dbaa6bd175be7aaee829c717e572488.tar.xz
First version of rule parsing
Only handles allkb at the moment.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 48 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index fcd57754b..f0d5c05cc 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,54 @@ $(info Keyboard: $(KEYBOARD))
$(info Keymap: $(KEYMAP))
$(info Subproject: $(SUBPROJECT))
+# 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
+# and $1 is removed from the RULE variable
+# Otherwise the RULE_FOUND variable is set to false
+# The function is a bit tricky, since there's no built in $(startswith) function
+define COMPARE_AND_REMOVE_FROM_RULE
+ ifeq ($1,$$(RULE))
+ RULE:=
+ RULE_FOUND := true
+ else
+ STARTDASH_REMOVED=$$(subst START$1-,,START$$(RULE))
+ ifneq ($$(STARTDASH_REMOVED),START$$(RULE))
+ RULE_FOUND := true
+ RULE := $$(STARTDASH_REMOVED)
+ else
+ RULE_FOUND := false
+ endif
+ endif
+endef
+
+define PARSE_ALL_KEYBOARDS
+ COMMANDS += allkb
+ #$$(info $$(RULE))
+ COMMAND_allkb := "All keyboards with $$(RULE)"
+endef
+
+define PARSE_RULE
+ RULE := $1
+ COMMANDS :=
+ $$(eval $$(call COMPARE_AND_REMOVE_FROM_RULE,allkb))
+ ifeq ($$(RULE_FOUND),true)
+ $$(eval $$(call PARSE_ALL_KEYBOARDS))
+ endif
+endef
+
+RUN_COMMAND = echo "Running": $(COMMAND_$(COMMAND));
+
+.PHONY: %
+%:
+ $(eval $(call PARSE_RULE,$@))
+ $(foreach COMMAND,$(COMMANDS),$(RUN_COMMAND))
+
+.PHONY: all-keyboards
+all-keyboards: allkb
+
+.PHONY: all-keyboards-defaults
+all-keyboards-defaults: allkb-default-default
+.PHONY: all
all:
echo "Compiling" \ No newline at end of file