summaryrefslogtreecommitdiff
path: root/lib/python/qmk/build_targets.py
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-11-28 07:53:43 +1100
committerGitHub <noreply@github.com>2023-11-28 07:53:43 +1100
commit5501e804ff8d41ce656061b91896c4ac8c681d78 (patch)
tree6a655fbceaeab67cf727dbe4318721407dd31824 /lib/python/qmk/build_targets.py
parent094357c40347e8a5db36578851f1af34a92e9f68 (diff)
QMK Userspace (#22222)
Co-authored-by: Duncan Sutherland <dunk2k_2000@hotmail.com>
Diffstat (limited to 'lib/python/qmk/build_targets.py')
-rw-r--r--lib/python/qmk/build_targets.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/python/qmk/build_targets.py b/lib/python/qmk/build_targets.py
index 16a7ef87a2..1ab489cec3 100644
--- a/lib/python/qmk/build_targets.py
+++ b/lib/python/qmk/build_targets.py
@@ -10,6 +10,8 @@ from qmk.constants import QMK_FIRMWARE, INTERMEDIATE_OUTPUT_PREFIX
from qmk.commands import find_make, get_make_parallel_args, parse_configurator_json
from qmk.keyboard import keyboard_folder
from qmk.info import keymap_json
+from qmk.keymap import locate_keymap
+from qmk.path import is_under_qmk_firmware, is_under_qmk_userspace
class BuildTarget:
@@ -158,6 +160,20 @@ class KeyboardKeymapBuildTarget(BuildTarget):
for key, value in env_vars.items():
compile_args.append(f'{key}={value}')
+ # Need to override the keymap path if the keymap is a userspace directory.
+ # This also ensures keyboard aliases as per `keyboard_aliases.hjson` still work if the userspace has the keymap
+ # in an equivalent historical location.
+ keymap_location = locate_keymap(self.keyboard, self.keymap)
+ if is_under_qmk_userspace(keymap_location) and not is_under_qmk_firmware(keymap_location):
+ keymap_directory = keymap_location.parent
+ compile_args.extend([
+ f'MAIN_KEYMAP_PATH_1={keymap_directory}',
+ f'MAIN_KEYMAP_PATH_2={keymap_directory}',
+ f'MAIN_KEYMAP_PATH_3={keymap_directory}',
+ f'MAIN_KEYMAP_PATH_4={keymap_directory}',
+ f'MAIN_KEYMAP_PATH_5={keymap_directory}',
+ ])
+
return compile_args