10000 Merge pull request #3087 from sommersoft/cpy_org_sptmtrx · kdb424/circuitpython@eec42d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit eec42d4

Browse files
authored
Merge pull request adafruit#3087 from sommersoft/cpy_org_sptmtrx
Release PRs To circuitpython.org: Include The Available Built-in Modules For Each Board
2 parents 4a21426 + c84c308 commit eec42d4

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

docs/shared_bindings_matrix.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,35 @@
2323

2424
import json
2525
import os
26+
import pathlib
2627
import re
2728
import subprocess
2829
import sys
2930

3031

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

34+
def get_circuitpython_root_dir():
35+
""" The path to the root './circuitpython' directory
36+
"""
37+
file_path = pathlib.Path(__file__).resolve()
38+
root_dir = file_path.parent.parent
39+
40+
return root_dir
41+
3342
def get_shared_bindings():
3443
""" Get a list of modules in shared-bindings based on folder names
3544
"""
36-
return [item for item in os.listdir("./shared-bindings")]
45+
shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings"
46+
return [item.name for item in shared_bindings_dir.iterdir()]
3747

3848

3949
def read_mpconfig():
4050
""" Open 'circuitpy_mpconfig.mk' and return the contents.
4151
"""
4252
configs = []
43-
with open("py/circuitpy_mpconfig.mk") as mpconfig:
53+
cpy_mpcfg = get_circuitpython_root_dir() / "py" / "circuitpy_mpconfig.mk"
54+
with open(cpy_mpcfg) as mpconfig:
4455
configs = mpconfig.read()
4556

4657
return configs
@@ -120,7 +131,7 @@ def lookup_setting(settings, key, default=''):
120131
key = value[2:-1]
121132
return value
122133

123-
def support_matrix_by_board():
134+
def support_matrix_by_board(use_branded_name=True):
124135
""" Compiles a list of the available core modules available for each
125136
board.
126137
"""
@@ -129,20 +140,22 @@ def support_matrix_by_board():
129140
boards = dict()
130141
for port in SUPPORTED_PORTS:
131142

132-
port_dir = "ports/{}/boards".format(port)
133-
for entry in os.scandir(port_dir):
143+
port_dir = get_circuitpython_root_dir() / "ports" / port
144+
for entry in (port_dir / "boards").iterdir():
134145
if not entry.is_dir():
135146
continue
136147
board_modules = []
148+
board_name = entry.name
137149

138-
settings = get_settings_from_makefile(f'ports/{port}', entry.name)
150+
settings = get_settings_from_makefile(str(port_dir), entry.name)
139151

140-
with open(os.path.join(entry.path, "mpconfigboard.h")) as get_name:
141-
board_contents = get_name.read()
142-
board_name_re = re.search("(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
143-
board_contents)
144-
if board_name_re:
145-
board_name = board_name_re.group(1).strip('"')
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('"')
146159

147160
board_modules = []
148161
for module in base:

tools/build_board_info.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from datetime import date
1010
from sh.contrib import git
1111

12+
sys.path.append("../docs")
13+
import shared_bindings_matrix
14+
1215
sys.path.append("adabot")
1316
import adabot.github_requests as github
1417

@@ -246,6 +249,10 @@ def generate_download_info():
246249

247250
languages = get_languages()
248251

252+
support_matrix = shared_bindings_matrix.support_matrix_by_board(
253+
use_branded_name=False
254+
)
255+
249256
new_stable = "-" not in new_tag
250257

251258
previous_releases = set()
@@ -283,6 +290,7 @@ def generate_download_info():
283290
new_version = {
284291
"stable": new_stable,
285292
"version": new_tag,
293+
"modules": support_matrix.get(alias, "[]"),
286294
"files": {}
287295
}
288296
for language in languages:

0 commit comments

Comments
 (0)
0