|
28 | 28 | import subprocess
|
29 | 29 | import sys
|
30 | 30 |
|
| 31 | +from concurrent.futures import ThreadPoolExecutor |
31 | 32 |
|
32 | 33 | SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm']
|
33 | 34 |
|
@@ -131,38 +132,44 @@ def lookup_setting(settings, key, default=''):
|
131 | 132 | key = value[2:-1]
|
132 | 133 | return value
|
133 | 134 |
|
| 135 | +def all_ports_all_boards(ports=SUPPORTED_PORTS): |
| 136 | + for port in ports: |
| 137 | + |
| 138 | + port_dir = get_circuitpython_root_dir() / "ports" / port |
| 139 | + for entry in (port_dir / "boards").iterdir(): |
| 140 | + if not entry.is_dir(): |
| 141 | + continue |
| 142 | + yield (port, entry) |
| 143 | + |
134 | 144 | def support_matrix_by_board(use_branded_name=True):
|
135 | 145 | """ Compiles a list of the available core modules available for each
|
136 | 146 | board.
|
137 | 147 | """
|
138 | 148 | base = build_module_map()
|
139 | 149 |
|
140 |
| - boards = dict() |
141 |
| - for port in SUPPORTED_PORTS: |
142 |
| - |
| 150 | + def support_matrix(arg): |
| 151 | + port, entry = arg |
143 | 152 | port_dir = get_circuitpython_root_dir() / "ports" / port
|
144 |
| - for entry in (port_dir / "boards").iterdir(): |
145 |
| - if not entry.is_dir(): |
146 |
| - continue |
147 |
| - board_modules = [] |
148 |
| - board_name = entry.name |
149 |
| - |
150 |
| - settings = get_settings_from_makefile(str(port_dir), entry.name) |
151 |
| - |
152 |
| - if use_branded_name: |
153 |
| - with open(entry / "mpconfigboard.h") as get_name: |
154 |
| - board_contents = get_name.read() |
155 |
| - board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", |
156 |
| - board_contents) |
157 |
| - if board_name_re: |
158 |
| - board_name = board_name_re.group(1).strip('"') |
159 |
| - |
160 |
| - board_modules = [] |
161 |
| - for module in base: |
162 |
| - key = f'CIRCUITPY_{module.upper()}' |
163 |
| - if int(lookup_setting(settings, key, '0')): |
164 |
| - board_modules.append(base[module]['name']) |
165 |
| - boards[board_name] = sorted(board_modules) |
| 153 | + settings = get_settings_from_makefile(str(port_dir), entry.name) |
| 154 | + |
| 155 | + if use_branded_name: |
| 156 | + with open(entry / "mpconfigboard.h") as get_name: |
| 157 | + board_contents = get_name.read() |
| 158 | + board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", |
| 159 | + board_contents) |
| 160 | + if board_name_re: |
| 161 | + board_name = board_name_re.group(1).strip('"') |
| 162 | + |
| 163 | + board_modules = [] |
| 164 | + for module in base: |
| 165 | + key = f'CIRCUITPY_{module.upper()}' |
| 166 | + if int(lookup_setting(settings, key, '0')): |
| 167 | + board_modules.append(base[module]['name']) |
| 168 | + |
| 169 | + return (board_name, sorted(board_modules)) |
| 170 | + |
| 171 | + executor = ThreadPoolExecutor(max_workers=os.cpu_count()) |
| 172 | + boards = dict(sorted(executor.map(support_matrix, all_ports_all_boards()))) |
166 | 173 |
|
167 | 174 | #print(json.dumps(boards, indent=2))
|
168 | 175 | return boards
|
|
0 commit comments