···115115TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
116116117117# As TRY_TO_MATCH_RULE_FROM_LIST_HELPER, but with additional
118118-# resolution of DEFAULT_FOLDER and keyboard_aliases.hjson for provided rule
118118+# resolution of keyboard_aliases.hjson for provided rule
119119define TRY_TO_MATCH_RULE_FROM_LIST_HELPER_KB
120120 # Split on ":", padding with empty strings to avoid indexing issues
121121 TOKEN1:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[0])" $$(RULE))
···255255# if we are going to compile all keyboards, match the rest of the rule
256256# for each of them
257257define PARSE_ALL_KEYBOARDS
258258- $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell $(QMK_BIN) list-keyboards --no-resolve-defaults)))
258258+ $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell $(QMK_BIN) list-keyboards)))
259259endef
260260261261# Prints a list of all known keymaps for the given keyboard
···447447448448.PHONY: list-keyboards
449449list-keyboards:
450450- $(QMK_BIN) list-keyboards --no-resolve-defaults | tr '\n' ' '
450450+ $(QMK_BIN) list-keyboards | tr '\n' ' '
451451452452.PHONY: list-tests
453453list-tests:
···455455456456.PHONY: generate-keyboards-file
457457generate-keyboards-file:
458458- $(QMK_BIN) list-keyboards --no-resolve-defaults
458458+ $(QMK_BIN) list-keyboards
459459460460.PHONY: clean
461461clean:
···364364365365## Build Options
366366367367-* `DEFAULT_FOLDER`
368368- * Used to specify a default folder when a keyboard has more than one sub-folder.
369367* `FIRMWARE_FORMAT`
370368 * Defines which format (bin, hex) is copied to the root `qmk_firmware` folder after building.
371369* `SRC`
+1-5
lib/python/qmk/cli/ci/validate_aliases.py
···22"""
33from milc import cli
4455-from qmk.keyboard import resolve_keyboard, keyboard_folder, keyboard_alias_definitions
55+from qmk.keyboard import keyboard_folder, keyboard_alias_definitions
667788def _safe_keyboard_folder(target):
···1515def _target_keyboard_exists(target):
1616 # If there's no target, then we can't build it.
1717 if not target:
1818- return False
1919-2020- # If the target directory existed but there was no rules.mk or rules.mk was incorrectly parsed, then we can't build it.
2121- if not resolve_keyboard(target):
2218 return False
23192420 # If the target directory exists but it itself has an invalid alias or invalid rules.mk, then we can't build it either.
+1-2
lib/python/qmk/cli/list/keyboards.py
···55import qmk.keyboard
667788-@cli.argument('--no-resolve-defaults', arg_only=True, action='store_false', help='Ignore any "DEFAULT_FOLDER" within keyboards rules.mk')
98@cli.subcommand("List the keyboards currently defined within QMK")
109def list_keyboards(cli):
1110 """List the keyboards currently defined within QMK
1211 """
1313- for keyboard_name in qmk.keyboard.list_keyboards(cli.args.no_resolve_defaults):
1212+ for keyboard_name in qmk.keyboard.list_keyboards():
1413 print(keyboard_name)
···5566@cli.argument('--allow-unknown', arg_only=True, action='store_true', help="Return original if rule is not a valid keyboard.")
77@cli.argument('keyboard', arg_only=True, help='The keyboard\'s name')
88-@cli.subcommand('Resolve DEFAULT_FOLDER and any keyboard_aliases for provided rule')
88+@cli.subcommand('Resolve any keyboard_aliases for provided rule')
99def resolve_alias(cli):
1010 try:
1111 print(keyboard_folder(cli.args.keyboard))
-11
lib/python/qmk/info.py
···223223def info_json(keyboard, force_layout=None):
224224 """Generate the info.json data for a specific keyboard.
225225 """
226226- cur_dir = Path('keyboards')
227227- root_rules_mk = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
228228-229229- if 'DEFAULT_FOLDER' in root_rules_mk:
230230- keyboard = root_rules_mk['DEFAULT_FOLDER']
231231-232226 info_data = {
233227 'keyboard_name': str(keyboard),
234228 'keyboard_folder': str(keyboard),
···1004998 keyboard_path = base_path / keyboard
1005999 keyboard_parent = keyboard_path.parent
10061000 info_jsons = [keyboard_path / 'info.json', keyboard_path / 'keyboard.json']
10071007-10081008- # Add DEFAULT_FOLDER before parents, if present
10091009- rules = rules_mk(keyboard)
10101010- if 'DEFAULT_FOLDER' in rules:
10111011- info_jsons.append(Path(rules['DEFAULT_FOLDER']) / 'info.json')
1012100110131002 # Add in parent folders for least specific
10141003 for _ in range(5):
+8-26
lib/python/qmk/keyboard.py
···9999 keymap_index = len(current_path.parts) - current_path.parts.index('keymaps') - 1
100100 current_path = current_path.parents[keymap_index]
101101102102- current_path = resolve_keyboard(current_path)
103103-104102 if qmk.path.is_keyboard(current_path):
105103 return str(current_path)
106104···121119def keyboard_folder(keyboard):
122120 """Returns the actual keyboard folder.
123121124124- This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
122122+ This checks aliases to resolve the actual path for a keyboard.
125123 """
126124 aliases = keyboard_alias_definitions()
127125···131129 if keyboard == last_keyboard:
132130 break
133131134134- keyboard = resolve_keyboard(keyboard)
135135-136132 if not qmk.path.is_keyboard(keyboard):
137133 raise ValueError(f'Invalid keyboard: {keyboard}')
138134···158154def keyboard_folder_or_all(keyboard):
159155 """Returns the actual keyboard folder.
160156161161- This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
157157+ This checks aliases to resolve the actual path for a keyboard.
162158 If the supplied argument is "all", it returns an AllKeyboards object.
163159 """
164160 if keyboard == 'all':
···179175 return list_keyboards()
180176181177182182-def list_keyboards(resolve_defaults=True):
183183- """Returns a list of all keyboards - optionally processing any DEFAULT_FOLDER.
178178+def list_keyboards():
179179+ """Returns a list of all keyboards
184180 """
185181 # We avoid pathlib here because this is performance critical code.
186186- paths = []
187187- for marker in ['rules.mk', 'keyboard.json']:
188188- kb_wildcard = os.path.join(base_path, "**", marker)
189189- paths += [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path]
182182+ kb_wildcard = os.path.join(base_path, "**", 'keyboard.json')
183183+ paths = [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path]
190184191185 found = map(_find_name, paths)
192192- if resolve_defaults:
193193- found = map(resolve_keyboard, found)
194186195187 return sorted(set(found))
196188197189198198-@lru_cache(maxsize=None)
199199-def resolve_keyboard(keyboard):
200200- cur_dir = Path('keyboards')
201201- rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
202202- while 'DEFAULT_FOLDER' in rules and keyboard != rules['DEFAULT_FOLDER']:
203203- keyboard = rules['DEFAULT_FOLDER']
204204- rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
205205- return keyboard
206206-207207-208190def config_h(keyboard):
209191 """Parses all the config.h files for a keyboard.
210192···216198 """
217199 config = {}
218200 cur_dir = Path('keyboards')
219219- keyboard = Path(resolve_keyboard(keyboard))
201201+ keyboard = Path(keyboard)
220202221203 for dir in keyboard.parts:
222204 cur_dir = cur_dir / dir
···235217 a dictionary representing the content of the entire rules.mk tree for a keyboard
236218 """
237219 cur_dir = Path('keyboards')
238238- keyboard = Path(resolve_keyboard(keyboard))
220220+ keyboard = Path(keyboard)
239221 rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
240222241223 for i, dir in enumerate(keyboard.parts):