]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
First version of rule parsing
authorFred Sundvik <fsundvik@gmail.com>
Wed, 3 Aug 2016 05:44:11 +0000 (08:44 +0300)
committerFred Sundvik <fsundvik@gmail.com>
Sat, 20 Aug 2016 00:24:40 +0000 (03:24 +0300)
Only handles allkb at the moment.

Makefile

index fcd57754b54efb810c81aee1728a4b5bf1299919..f0d5c05cccca54aa98e676b5a4b9bc5a4dcdd71f 100644 (file)
--- 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