summaryrefslogtreecommitdiffstats
path: root/builddefs/build_layout.mk
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-02-10 17:45:51 +0000
committerGitHub <noreply@github.com>2022-02-10 09:45:51 -0800
commitf7e7671f691cfd42f322198f04690727f6493d73 (patch)
tree9c705a6a1a594263ab273cba62affa3fa7e5d28e /builddefs/build_layout.mk
parent7a0fd646e37795aa843d369a5c80d99118cca868 (diff)
Migrate more makefile utilities to builddefs sub-directory (#16002)
Diffstat (limited to 'builddefs/build_layout.mk')
-rw-r--r--builddefs/build_layout.mk32
1 files changed, 32 insertions, 0 deletions
diff --git a/builddefs/build_layout.mk b/builddefs/build_layout.mk
new file mode 100644
index 0000000000..6166bd847c
--- /dev/null
+++ b/builddefs/build_layout.mk
@@ -0,0 +1,32 @@
+LAYOUTS_PATH := layouts
+LAYOUTS_REPOS := $(patsubst %/,%,$(sort $(dir $(wildcard $(LAYOUTS_PATH)/*/))))
+
+define SEARCH_LAYOUTS_REPO
+ LAYOUT_KEYMAP_PATH := $$(LAYOUTS_REPO)/$$(LAYOUT)/$$(KEYMAP)
+ LAYOUT_KEYMAP_JSON := $$(LAYOUT_KEYMAP_PATH)/keymap.json
+ LAYOUT_KEYMAP_C := $$(LAYOUT_KEYMAP_PATH)/keymap.c
+ ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_JSON))","")
+ -include $$(LAYOUT_KEYMAP_PATH)/rules.mk
+ KEYMAP_JSON := $$(LAYOUT_KEYMAP_JSON)
+ KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
+ else ifneq ("$$(wildcard $$(LAYOUT_KEYMAP_C))","")
+ -include $$(LAYOUT_KEYMAP_PATH)/rules.mk
+ KEYMAP_C := $$(LAYOUT_KEYMAP_C)
+ KEYMAP_PATH := $$(LAYOUT_KEYMAP_PATH)
+ endif
+endef
+
+define SEARCH_LAYOUTS
+ $$(foreach LAYOUTS_REPO,$$(LAYOUTS_REPOS),$$(eval $$(call SEARCH_LAYOUTS_REPO)))
+endef
+
+ifneq ($(FORCE_LAYOUT),)
+ ifneq (,$(findstring $(FORCE_LAYOUT),$(LAYOUTS)))
+ $(info Forcing layout: $(FORCE_LAYOUT))
+ LAYOUTS := $(FORCE_LAYOUT)
+ else
+ $(call CATASTROPHIC_ERROR,Invalid layout,Forced layout does not exist)
+ endif
+endif
+
+$(foreach LAYOUT,$(LAYOUTS),$(eval $(call SEARCH_LAYOUTS)))