summaryrefslogtreecommitdiff
path: root/lib/python/qmk/build_targets.py
diff options
context:
space:
mode:
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
10from qmk.commands import find_make, get_make_parallel_args, parse_configurator_json 10from qmk.commands import find_make, get_make_parallel_args, parse_configurator_json
11from qmk.keyboard import keyboard_folder 11from qmk.keyboard import keyboard_folder
12from qmk.info import keymap_json 12from qmk.info import keymap_json
13from qmk.keymap import locate_keymap
14from qmk.path import is_under_qmk_firmware, is_under_qmk_userspace
13 15
14 16
15class BuildTarget: 17class BuildTarget:
@@ -158,6 +160,20 @@ class KeyboardKeymapBuildTarget(BuildTarget):
158 for key, value in env_vars.items(): 160 for key, value in env_vars.items():
159 compile_args.append(f'{key}={value}') 161 compile_args.append(f'{key}={value}')
160 162
163 # Need to override the keymap path if the keymap is a userspace directory.
164 # This also ensures keyboard aliases as per `keyboard_aliases.hjson` still work if the userspace has the keymap
165 # in an equivalent historical location.
166 keymap_location = locate_keymap(self.keyboard, self.keymap)
167 if is_under_qmk_userspace(keymap_location) and not is_under_qmk_firmware(keymap_location):
168 keymap_directory = keymap_location.parent
169 compile_args.extend([
170 f'MAIN_KEYMAP_PATH_1={keymap_directory}',
171 f'MAIN_KEYMAP_PATH_2={keymap_directory}',
172 f'MAIN_KEYMAP_PATH_3={keymap_directory}',
173 f'MAIN_KEYMAP_PATH_4={keymap_directory}',
174 f'MAIN_KEYMAP_PATH_5={keymap_directory}',
175 ])
176
161 return compile_args 177 return compile_args
162 178
163 179