Skip to content

Commit 8c6b2c8

Browse files
committed
doc: _extensions: boards: retrieve archs info dynamically
Rather than hardcoding the human readable full names of the archs in the board catalog, we now retrieve them dynamically from the archs.yml file. Signed-off-by: Benjamin Cabé <[email protected]>
1 parent a89c792 commit 8c6b2c8

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

doc/_extensions/zephyr/domain/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def run(self):
760760
"shields": domain_data["shields"],
761761
"vendors": domain_data["vendors"],
762762
"socs": domain_data["socs"],
763+
"archs": domain_data["archs"],
763764
"hw_features_present": self.env.app.config.zephyr_generate_hw_features,
764765
},
765766
)
@@ -1385,6 +1386,7 @@ def load_board_catalog_into_domain(app: Sphinx) -> None:
13851386
app.env.domaindata["zephyr"]["shields"] = board_catalog["shields"]
13861387
app.env.domaindata["zephyr"]["vendors"] = board_catalog["vendors"]
13871388
app.env.domaindata["zephyr"]["socs"] = board_catalog["socs"]
1389+
app.env.domaindata["zephyr"]["archs"] = board_catalog["archs"]
13881390
app.env.domaindata["zephyr"]["runners"] = board_catalog["runners"]
13891391

13901392

doc/_extensions/zephyr/domain/templates/board-catalog.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,9 @@
3737
<div class="select-container">
3838
<select id="arch">
3939
<option value="" disabled selected>Select an architecture</option>
40-
<option value="arm">ARM</option>
41-
<option value="arm64">ARM 64</option>
42-
<option value="mips">MIPS</option>
43-
<option value="posix">POSIX</option>
44-
<option value="riscv">RISC-V</option>
45-
<option value="sparc">SPARC</option>
46-
<option value="arc">Synopsys DesignWare ARC</option>
47-
<option value="x86">x86</option>
48-
<option value="xtensa">Xtensa</option>
40+
{% for arch_name, arch in archs | items | sort(attribute='1.full_name') -%}
41+
<option value="{{ arch_name }}">{{ arch.full_name }}</option>
42+
{% endfor %}
4943
</select>
5044
</div>
5145
</div>

doc/_scripts/gen_boards_catalog.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
ZEPHYR_BINDINGS = ZEPHYR_BASE / "dts/bindings"
2323
EDT_PICKLE_PATHS = [
2424
"zephyr/edt.pickle",
25-
"hello_world/zephyr/edt.pickle" # for board targets using sysbuild
25+
"hello_world/zephyr/edt.pickle", # for board targets using sysbuild
2626
]
2727
RUNNERS_YAML_PATHS = [
2828
"zephyr/runners.yaml",
29-
"hello_world/zephyr/runners.yaml" # for board targets using sysbuild
29+
"hello_world/zephyr/runners.yaml", # for board targets using sysbuild
3030
]
3131

3232
logger = logging.getLogger(__name__)
@@ -73,8 +73,7 @@ def get_cached_description(cls, node):
7373
The cached description for the node's compatible, creating it if needed.
7474
"""
7575
return cls._compat_description_cache.setdefault(
76-
node.matching_compat,
77-
cls.get_first_sentence(node.description)
76+
node.matching_compat, cls.get_first_sentence(node.description)
7877
)
7978

8079

@@ -176,9 +175,7 @@ def gather_board_build_info(twister_out_dir):
176175
if runners_yaml_file:
177176
with open(runners_yaml_file) as f:
178177
runners_yaml = yaml.safe_load(f)
179-
board_runners.setdefault(board_name, {})[board_target] = (
180-
runners_yaml
181-
)
178+
board_runners.setdefault(board_name, {})[board_target] = runners_yaml
182179

183180
except Exception as e:
184181
logger.error(f"Error processing build info file {build_info_file}: {e}")
@@ -196,12 +193,14 @@ def run_twister_cmake_only(outdir, vendor_filter):
196193
twister_cmd = [
197194
sys.executable,
198195
f"{ZEPHYR_BASE}/scripts/twister",
199-
"-T", "samples/hello_world/",
196+
"-T",
197+
"samples/hello_world/",
200198
"-M",
201199
*[arg for path in EDT_PICKLE_PATHS for arg in ('--keep-artifacts', path)],
202200
*[arg for path in RUNNERS_YAML_PATHS for arg in ('--keep-artifacts', path)],
203201
"--cmake-only",
204-
"--outdir", str(outdir),
202+
"--outdir",
203+
str(outdir),
205204
]
206205

207206
if vendor_filter:
@@ -214,7 +213,7 @@ def run_twister_cmake_only(outdir, vendor_filter):
214213
'PATH': os.environ.get('PATH', ''),
215214
'ZEPHYR_BASE': str(ZEPHYR_BASE),
216215
'HOME': os.environ.get('HOME', ''),
217-
'PYTHONPATH': os.environ.get('PYTHONPATH', '')
216+
'PYTHONPATH': os.environ.get('PYTHONPATH', ''),
218217
}
219218

220219
try:
@@ -247,18 +246,22 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
247246
if root is not None:
248247
module_settings[key].append(Path(module.project) / root)
249248

250-
Args = namedtuple("args", ["arch_roots", "board_roots", "soc_roots", "board_dir", "board"])
249+
Args = namedtuple(
250+
"args", ["arch_roots", "board_roots", "soc_roots", "board_dir", "board", "arch"]
251+
)
251252
args_find_boards = Args(
252253
arch_roots=module_settings["arch_root"],
253254
board_roots=module_settings["board_root"],
254255
soc_roots=module_settings["soc_root"],
255256
board_dir=[],
256257
board=None,
258+
arch=None,
257259
)
258260

259261
boards = list_boards.find_v2_boards(args_find_boards)
260262
shields = list_shields.find_shields(args_find_boards)
261263
systems = list_hardware.find_v2_systems(args_find_boards)
264+
archs = list_hardware.find_v2_archs(args_find_boards)
262265
board_catalog = {}
263266
shield_catalog = {}
264267
board_devicetrees = {}
@@ -296,7 +299,6 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
296299
binding_type = "misc"
297300
is_custom_binding = True
298301

299-
300302
if node.matching_compat is None:
301303
continue
302304

@@ -316,9 +318,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
316318
else:
317319
locations.add("soc")
318320

319-
existing_feature = features.get(binding_type, {}).get(
320-
node.matching_compat
321-
)
321+
existing_feature = features.get(binding_type, {}).get(node.matching_compat)
322322

323323
node_info = {
324324
"filename": str(filename),
@@ -359,13 +359,13 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
359359

360360
# Grab all the twister files for this board and use them to figure out all the archs it
361361
# supports.
362-
archs = set()
362+
board_archs = set()
363363
pattern = f"{board.name}*.yaml"
364364
for twister_file in board.dir.glob(pattern):
365365
try:
366366
with open(twister_file) as f:
367367
board_data = yaml.safe_load(f)
368-
archs.add(board_data.get("arch"))
368+
board_archs.add(board_data.get("arch"))
369369
except Exception as e:
370370
logger.error(f"Error parsing twister file {twister_file}: {e}")
371371

@@ -379,7 +379,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
379379
"full_name": full_name,
380380
"doc_page": doc_page_path,
381381
"vendor": vendor,
382-
"archs": list(archs),
382+
"archs": list(board_archs),
383383
"socs": list(socs),
384384
"revision_default": board.revision_default,
385385
"supported_features": supported_features,
@@ -403,6 +403,14 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
403403
"commands": runner.capabilities().commands,
404404
}
405405

406+
arch_catalog = {
407+
arch['name']: {
408+
"name": arch['name'],
409+
"full_name": arch.get('full_name', arch['name']),
410+
}
411+
for arch in archs['archs']
412+
}
413+
406414
for shield in shields:
407415
doc_page = guess_doc_page(shield)
408416
if doc_page and doc_page.is_relative_to(ZEPHYR_BASE):
@@ -424,5 +432,6 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
424432
"shields": shield_catalog,
425433
"vendors": {**vnd_lookup.vnd2vendor, "others": "Other/Unknown"},
426434
"socs": socs_hierarchy,
435+
"archs": arch_catalog,
427436
"runners": available_runners,
428437
}

0 commit comments

Comments
 (0)