2828import subprocess
2929import sys
3030
31+ from concurrent .futures import ThreadPoolExecutor
3132
3233SUPPORTED_PORTS = ['atmel-samd' , 'esp32s2' , 'litex' , 'mimxrt10xx' , 'nrf' , 'stm' ]
3334
@@ -42,7 +43,7 @@ def get_circuitpython_root_dir():
4243def get_shared_bindings ():
4344 """ Get a list of modules in shared-bindings based on folder names
4445 """
45- shared_bindings_dir = get_circuitpython_root_dir () / "shared-bindings "
46+ shared_bindings_dir = get_circuitpython_root_dir () / "circuitpython-stubs "
4647 return [item .name for item in shared_bindings_dir .iterdir ()]
4748
4849
@@ -131,38 +132,44 @@ def lookup_setting(settings, key, default=''):
131132 key = value [2 :- 1 ]
132133 return value
133134
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+
134144def support_matrix_by_board (use_branded_name = True ):
135145 """ Compiles a list of the available core modules available for each
136146 board.
137147 """
138148 base = build_module_map ()
139149
140- boards = dict ()
141- for port in SUPPORTED_PORTS :
142-
150+ def support_matrix (arg ):
151+ port , entry = arg
143152 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 ())))
166173
167174 #print(json.dumps(boards, indent=2))
168175 return boards
0 commit comments