Skip to content

Shared bindings matrix ulab #3332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions docs/shared_bindings_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import subprocess
import sys

from concurrent.futures import ThreadPoolExecutor

SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm']

Expand All @@ -42,7 +43,7 @@ def get_circuitpython_root_dir():
def get_shared_bindings():
""" Get a list of modules in shared-bindings based on folder names
"""
shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings"
shared_bindings_dir = get_circuitpython_root_dir() / "circuitpython-stubs"
return [item.name for item in shared_bindings_dir.iterdir()]


Expand Down Expand Up @@ -131,38 +132,44 @@ def lookup_setting(settings, key, default=''):
key = value[2:-1]
return value

def all_ports_all_boards(ports=SUPPORTED_PORTS):
for port in ports:

port_dir = get_circuitpython_root_dir() / "ports" / port
for entry in (port_dir / "boards").iterdir():
if not entry.is_dir():
continue
yield (port, entry)

def support_matrix_by_board(use_branded_name=True):
""" Compiles a list of the available core modules available for each
board.
"""
base = build_module_map()

boards = dict()
for port in SUPPORTED_PORTS:

def support_matrix(arg):
port, entry = arg
port_dir = get_circuitpython_root_dir() / "ports" / port
for entry in (port_dir / "boards").iterdir():
if not entry.is_dir():
continue
board_modules = []
board_name = entry.name

settings = get_settings_from_makefile(str(port_dir), entry.name)

if use_branded_name:
with open(entry / "mpconfigboard.h") as get_name:
board_contents = get_name.read()
board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
board_contents)
if board_name_re:
board_name = board_name_re.group(1).strip('"')

board_modules = []
for module in base:
key = f'CIRCUITPY_{module.upper()}'
if int(lookup_setting(settings, key, '0')):
board_modules.append(base[module]['name'])
boards[board_name] = sorted(board_modules)
settings = get_settings_from_makefile(str(port_dir), entry.name)

if use_branded_name:
with open(entry / "mpconfigboard.h") as get_name:
board_contents = get_name.read()
board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
board_contents)
if board_name_re:
board_name = board_name_re.group(1).strip('"')

board_modules = []
for module in base:
key = f'CIRCUITPY_{module.upper()}'
if int(lookup_setting(settings, key, '0')):
board_modules.append(base[module]['name'])

return (board_name, sorted(board_modules))

executor = ThreadPoolExecutor(max_workers=os.cpu_count())
boards = dict(sorted(executor.map(support_matrix, all_ports_all_boards())))

#print(json.dumps(boards, indent=2))
return boards
Expand Down