keyboard stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove `DEFAULT_FOLDER` handling (#23281)

authored by

Joel Challis and committed by
GitHub
0326355e 94f1aade

+20 -58
+4 -4
Makefile
··· 115 115 TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND) 116 116 117 117 # As TRY_TO_MATCH_RULE_FROM_LIST_HELPER, but with additional 118 - # resolution of DEFAULT_FOLDER and keyboard_aliases.hjson for provided rule 118 + # resolution of keyboard_aliases.hjson for provided rule 119 119 define TRY_TO_MATCH_RULE_FROM_LIST_HELPER_KB 120 120 # Split on ":", padding with empty strings to avoid indexing issues 121 121 TOKEN1:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[0])" $$(RULE)) ··· 255 255 # if we are going to compile all keyboards, match the rest of the rule 256 256 # for each of them 257 257 define PARSE_ALL_KEYBOARDS 258 - $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell $(QMK_BIN) list-keyboards --no-resolve-defaults))) 258 + $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell $(QMK_BIN) list-keyboards))) 259 259 endef 260 260 261 261 # Prints a list of all known keymaps for the given keyboard ··· 447 447 448 448 .PHONY: list-keyboards 449 449 list-keyboards: 450 - $(QMK_BIN) list-keyboards --no-resolve-defaults | tr '\n' ' ' 450 + $(QMK_BIN) list-keyboards | tr '\n' ' ' 451 451 452 452 .PHONY: list-tests 453 453 list-tests: ··· 455 455 456 456 .PHONY: generate-keyboards-file 457 457 generate-keyboards-file: 458 - $(QMK_BIN) list-keyboards --no-resolve-defaults 458 + $(QMK_BIN) list-keyboards 459 459 460 460 .PHONY: clean 461 461 clean:
+1 -1
data/mappings/info_rules.hjson
··· 53 53 "WS2812_DRIVER": {"info_key": "ws2812.driver"}, 54 54 55 55 // Items we want flagged in lint 56 - "DEFAULT_FOLDER": {"info_key": "_deprecated.default_folder", "deprecated": true}, 57 56 "CTPC": {"info_key": "_invalid.ctpc", "invalid": true, "replace_with": "CONVERT_TO=proton_c"}, 58 57 "CONVERT_TO_PROTON_C": {"info_key": "_invalid.ctpc", "invalid": true, "replace_with": "CONVERT_TO=proton_c"}, 58 + "DEFAULT_FOLDER": {"info_key": "_invalid.default_folder", "invalid": true}, 59 59 "VIAL_ENABLE": {"info_key": "_invalid.vial", "invalid": true} 60 60 }
-2
docs/config_options.md
··· 364 364 365 365 ## Build Options 366 366 367 - * `DEFAULT_FOLDER` 368 - * Used to specify a default folder when a keyboard has more than one sub-folder. 369 367 * `FIRMWARE_FORMAT` 370 368 * Defines which format (bin, hex) is copied to the root `qmk_firmware` folder after building. 371 369 * `SRC`
+1 -5
lib/python/qmk/cli/ci/validate_aliases.py
··· 2 2 """ 3 3 from milc import cli 4 4 5 - from qmk.keyboard import resolve_keyboard, keyboard_folder, keyboard_alias_definitions 5 + from qmk.keyboard import keyboard_folder, keyboard_alias_definitions 6 6 7 7 8 8 def _safe_keyboard_folder(target): ··· 15 15 def _target_keyboard_exists(target): 16 16 # If there's no target, then we can't build it. 17 17 if not target: 18 - return False 19 - 20 - # If the target directory existed but there was no rules.mk or rules.mk was incorrectly parsed, then we can't build it. 21 - if not resolve_keyboard(target): 22 18 return False 23 19 24 20 # 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
··· 5 5 import qmk.keyboard 6 6 7 7 8 - @cli.argument('--no-resolve-defaults', arg_only=True, action='store_false', help='Ignore any "DEFAULT_FOLDER" within keyboards rules.mk') 9 8 @cli.subcommand("List the keyboards currently defined within QMK") 10 9 def list_keyboards(cli): 11 10 """List the keyboards currently defined within QMK 12 11 """ 13 - for keyboard_name in qmk.keyboard.list_keyboards(cli.args.no_resolve_defaults): 12 + for keyboard_name in qmk.keyboard.list_keyboards(): 14 13 print(keyboard_name)
+2 -2
lib/python/qmk/cli/migrate.py
··· 6 6 7 7 from milc import cli 8 8 9 - from qmk.keyboard import keyboard_completer, keyboard_folder, resolve_keyboard 9 + from qmk.keyboard import keyboard_completer, keyboard_folder 10 10 from qmk.info import info_json, find_info_json 11 11 from qmk.json_encoders import InfoJSONEncoder 12 12 from qmk.json_schema import json_load 13 13 14 14 15 15 def _candidate_files(keyboard): 16 - kb_dir = Path(resolve_keyboard(keyboard)) 16 + kb_dir = Path(keyboard) 17 17 18 18 cur_dir = Path('keyboards') 19 19 files = []
+1 -1
lib/python/qmk/cli/resolve_alias.py
··· 5 5 6 6 @cli.argument('--allow-unknown', arg_only=True, action='store_true', help="Return original if rule is not a valid keyboard.") 7 7 @cli.argument('keyboard', arg_only=True, help='The keyboard\'s name') 8 - @cli.subcommand('Resolve DEFAULT_FOLDER and any keyboard_aliases for provided rule') 8 + @cli.subcommand('Resolve any keyboard_aliases for provided rule') 9 9 def resolve_alias(cli): 10 10 try: 11 11 print(keyboard_folder(cli.args.keyboard))
-11
lib/python/qmk/info.py
··· 223 223 def info_json(keyboard, force_layout=None): 224 224 """Generate the info.json data for a specific keyboard. 225 225 """ 226 - cur_dir = Path('keyboards') 227 - root_rules_mk = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') 228 - 229 - if 'DEFAULT_FOLDER' in root_rules_mk: 230 - keyboard = root_rules_mk['DEFAULT_FOLDER'] 231 - 232 226 info_data = { 233 227 'keyboard_name': str(keyboard), 234 228 'keyboard_folder': str(keyboard), ··· 1004 998 keyboard_path = base_path / keyboard 1005 999 keyboard_parent = keyboard_path.parent 1006 1000 info_jsons = [keyboard_path / 'info.json', keyboard_path / 'keyboard.json'] 1007 - 1008 - # Add DEFAULT_FOLDER before parents, if present 1009 - rules = rules_mk(keyboard) 1010 - if 'DEFAULT_FOLDER' in rules: 1011 - info_jsons.append(Path(rules['DEFAULT_FOLDER']) / 'info.json') 1012 1001 1013 1002 # Add in parent folders for least specific 1014 1003 for _ in range(5):
+8 -26
lib/python/qmk/keyboard.py
··· 99 99 keymap_index = len(current_path.parts) - current_path.parts.index('keymaps') - 1 100 100 current_path = current_path.parents[keymap_index] 101 101 102 - current_path = resolve_keyboard(current_path) 103 - 104 102 if qmk.path.is_keyboard(current_path): 105 103 return str(current_path) 106 104 ··· 121 119 def keyboard_folder(keyboard): 122 120 """Returns the actual keyboard folder. 123 121 124 - This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. 122 + This checks aliases to resolve the actual path for a keyboard. 125 123 """ 126 124 aliases = keyboard_alias_definitions() 127 125 ··· 131 129 if keyboard == last_keyboard: 132 130 break 133 131 134 - keyboard = resolve_keyboard(keyboard) 135 - 136 132 if not qmk.path.is_keyboard(keyboard): 137 133 raise ValueError(f'Invalid keyboard: {keyboard}') 138 134 ··· 158 154 def keyboard_folder_or_all(keyboard): 159 155 """Returns the actual keyboard folder. 160 156 161 - This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. 157 + This checks aliases to resolve the actual path for a keyboard. 162 158 If the supplied argument is "all", it returns an AllKeyboards object. 163 159 """ 164 160 if keyboard == 'all': ··· 179 175 return list_keyboards() 180 176 181 177 182 - def list_keyboards(resolve_defaults=True): 183 - """Returns a list of all keyboards - optionally processing any DEFAULT_FOLDER. 178 + def list_keyboards(): 179 + """Returns a list of all keyboards 184 180 """ 185 181 # We avoid pathlib here because this is performance critical code. 186 - paths = [] 187 - for marker in ['rules.mk', 'keyboard.json']: 188 - kb_wildcard = os.path.join(base_path, "**", marker) 189 - paths += [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path] 182 + kb_wildcard = os.path.join(base_path, "**", 'keyboard.json') 183 + paths = [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path] 190 184 191 185 found = map(_find_name, paths) 192 - if resolve_defaults: 193 - found = map(resolve_keyboard, found) 194 186 195 187 return sorted(set(found)) 196 188 197 189 198 - @lru_cache(maxsize=None) 199 - def resolve_keyboard(keyboard): 200 - cur_dir = Path('keyboards') 201 - rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') 202 - while 'DEFAULT_FOLDER' in rules and keyboard != rules['DEFAULT_FOLDER']: 203 - keyboard = rules['DEFAULT_FOLDER'] 204 - rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') 205 - return keyboard 206 - 207 - 208 190 def config_h(keyboard): 209 191 """Parses all the config.h files for a keyboard. 210 192 ··· 216 198 """ 217 199 config = {} 218 200 cur_dir = Path('keyboards') 219 - keyboard = Path(resolve_keyboard(keyboard)) 201 + keyboard = Path(keyboard) 220 202 221 203 for dir in keyboard.parts: 222 204 cur_dir = cur_dir / dir ··· 235 217 a dictionary representing the content of the entire rules.mk tree for a keyboard 236 218 """ 237 219 cur_dir = Path('keyboards') 238 - keyboard = Path(resolve_keyboard(keyboard)) 220 + keyboard = Path(keyboard) 239 221 rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') 240 222 241 223 for i, dir in enumerate(keyboard.parts):
+2 -4
lib/python/qmk/path.py
··· 21 21 if Path(keyboard_name).is_absolute(): 22 22 return False 23 23 24 - keyboard_path = QMK_FIRMWARE / 'keyboards' / keyboard_name 25 - rules_mk = keyboard_path / 'rules.mk' 26 - keyboard_json = keyboard_path / 'keyboard.json' 24 + keyboard_json = QMK_FIRMWARE / 'keyboards' / keyboard_name / 'keyboard.json' 27 25 28 - return rules_mk.exists() or keyboard_json.exists() 26 + return keyboard_json.exists() 29 27 30 28 31 29 def under_qmk_firmware(path=Path(os.environ['ORIG_CWD'])):