diff options
-rw-r--r-- | lib/python/qmk/info.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index de7632e37..c780a0ab2 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py | |||
@@ -9,12 +9,19 @@ from milc import cli | |||
9 | from qmk.constants import ARM_PROCESSORS, AVR_PROCESSORS, VUSB_PROCESSORS | 9 | from qmk.constants import ARM_PROCESSORS, AVR_PROCESSORS, VUSB_PROCESSORS |
10 | from qmk.c_parse import find_layouts | 10 | from qmk.c_parse import find_layouts |
11 | from qmk.keyboard import config_h, rules_mk | 11 | from qmk.keyboard import config_h, rules_mk |
12 | from qmk.makefile import parse_rules_mk_file | ||
12 | from qmk.math import compute | 13 | from qmk.math import compute |
13 | 14 | ||
14 | 15 | ||
15 | def info_json(keyboard): | 16 | def info_json(keyboard): |
16 | """Generate the info.json data for a specific keyboard. | 17 | """Generate the info.json data for a specific keyboard. |
17 | """ | 18 | """ |
19 | cur_dir = Path('keyboards') | ||
20 | rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') | ||
21 | if 'DEFAULT_FOLDER' in rules: | ||
22 | keyboard = rules['DEFAULT_FOLDER'] | ||
23 | rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk', rules) | ||
24 | |||
18 | info_data = { | 25 | info_data = { |
19 | 'keyboard_name': str(keyboard), | 26 | 'keyboard_name': str(keyboard), |
20 | 'keyboard_folder': str(keyboard), | 27 | 'keyboard_folder': str(keyboard), |
@@ -22,7 +29,7 @@ def info_json(keyboard): | |||
22 | 'maintainer': 'qmk', | 29 | 'maintainer': 'qmk', |
23 | } | 30 | } |
24 | 31 | ||
25 | for layout_name, layout_json in _find_all_layouts(keyboard).items(): | 32 | for layout_name, layout_json in _find_all_layouts(keyboard, rules).items(): |
26 | if not layout_name.startswith('LAYOUT_kc'): | 33 | if not layout_name.startswith('LAYOUT_kc'): |
27 | info_data['layouts'][layout_name] = layout_json | 34 | info_data['layouts'][layout_name] = layout_json |
28 | 35 | ||
@@ -99,22 +106,24 @@ def _extract_rules_mk(info_data): | |||
99 | return info_data | 106 | return info_data |
100 | 107 | ||
101 | 108 | ||
102 | def _find_all_layouts(keyboard): | 109 | def _search_keyboard_h(path): |
103 | """Looks for layout macros associated with this keyboard. | ||
104 | """ | ||
105 | layouts = {} | ||
106 | rules = rules_mk(keyboard) | ||
107 | keyboard_path = Path(rules.get('DEFAULT_FOLDER', keyboard)) | ||
108 | |||
109 | # Pull in all layouts defined in the standard files | ||
110 | current_path = Path('keyboards/') | 110 | current_path = Path('keyboards/') |
111 | for directory in keyboard_path.parts: | 111 | layouts = {} |
112 | for directory in path.parts: | ||
112 | current_path = current_path / directory | 113 | current_path = current_path / directory |
113 | keyboard_h = '%s.h' % (directory,) | 114 | keyboard_h = '%s.h' % (directory,) |
114 | keyboard_h_path = current_path / keyboard_h | 115 | keyboard_h_path = current_path / keyboard_h |
115 | if keyboard_h_path.exists(): | 116 | if keyboard_h_path.exists(): |
116 | layouts.update(find_layouts(keyboard_h_path)) | 117 | layouts.update(find_layouts(keyboard_h_path)) |
117 | 118 | ||
119 | return layouts | ||
120 | |||
121 | |||
122 | def _find_all_layouts(keyboard, rules): | ||
123 | """Looks for layout macros associated with this keyboard. | ||
124 | """ | ||
125 | layouts = _search_keyboard_h(Path(keyboard)) | ||
126 | |||
118 | if not layouts: | 127 | if not layouts: |
119 | # If we didn't find any layouts above we widen our search. This is error | 128 | # If we didn't find any layouts above we widen our search. This is error |
120 | # prone which is why we want to encourage people to follow the standard above. | 129 | # prone which is why we want to encourage people to follow the standard above. |