Handle userspace xap.hjson spec files

This commit is contained in:
zvecr 2023-01-09 19:35:47 +00:00
parent f66dc2bafe
commit 8e9e6c3ea7
2 changed files with 21 additions and 1 deletions

View File

@ -20,6 +20,9 @@ endif
ifneq ("$(wildcard $(KEYMAP_PATH)/xap.hjson)","")
XAP_FILES += $(KEYMAP_PATH)/xap.hjson
endif
ifneq ("$(wildcard $(USER_NAME)/xap.hjson)","")
XAP_FILES += $(USER_NAME)/xap.hjson
endif
$(KEYMAP_OUTPUT)/src/config_blob_gz.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)

View File

@ -11,11 +11,13 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
import qmk.constants
from qmk.git import git_get_version
from qmk.json_schema import json_load, validate, merge_ordered_dicts
from qmk.makefile import parse_rules_mk_file
from qmk.decorators import lru_cache
from qmk.keymap import locate_keymap
from qmk.path import keyboard
from qmk.xap.jinja2_filters import attach_filters
USERSPACE_DIR = Path('users')
XAP_SPEC = 'xap.hjson'
@ -91,7 +93,22 @@ def _find_kb_spec(kb):
def _find_km_spec(kb, km):
return locate_keymap(kb, km).parent / XAP_SPEC
keymap_dir = locate_keymap(kb, km).parent
if not keymap_dir.exists():
return None
# Resolve any potential USER_NAME overrides - default back to keymap name
keymap_rules_mk = parse_rules_mk_file(keymap_dir / 'rules.mk')
username = keymap_rules_mk.get('USER_NAME', km)
keymap_spec = keymap_dir / XAP_SPEC
userspace_spec = USERSPACE_DIR / username / XAP_SPEC
print(keymap_spec.exists())
print(userspace_spec.exists())
# In the case of both userspace and keymap - keymap wins
return keymap_spec if keymap_spec.exists() else userspace_spec
def get_xap_definition_files():