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é <benjamin@zephyrproject.org>
This commit is contained in:
parent
a89c79275f
commit
8c6b2c8c88
@ -760,6 +760,7 @@ class BoardCatalogDirective(SphinxDirective):
|
|||||||
"shields": domain_data["shields"],
|
"shields": domain_data["shields"],
|
||||||
"vendors": domain_data["vendors"],
|
"vendors": domain_data["vendors"],
|
||||||
"socs": domain_data["socs"],
|
"socs": domain_data["socs"],
|
||||||
|
"archs": domain_data["archs"],
|
||||||
"hw_features_present": self.env.app.config.zephyr_generate_hw_features,
|
"hw_features_present": self.env.app.config.zephyr_generate_hw_features,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -1385,6 +1386,7 @@ def load_board_catalog_into_domain(app: Sphinx) -> None:
|
|||||||
app.env.domaindata["zephyr"]["shields"] = board_catalog["shields"]
|
app.env.domaindata["zephyr"]["shields"] = board_catalog["shields"]
|
||||||
app.env.domaindata["zephyr"]["vendors"] = board_catalog["vendors"]
|
app.env.domaindata["zephyr"]["vendors"] = board_catalog["vendors"]
|
||||||
app.env.domaindata["zephyr"]["socs"] = board_catalog["socs"]
|
app.env.domaindata["zephyr"]["socs"] = board_catalog["socs"]
|
||||||
|
app.env.domaindata["zephyr"]["archs"] = board_catalog["archs"]
|
||||||
app.env.domaindata["zephyr"]["runners"] = board_catalog["runners"]
|
app.env.domaindata["zephyr"]["runners"] = board_catalog["runners"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,15 +37,9 @@
|
|||||||
<div class="select-container">
|
<div class="select-container">
|
||||||
<select id="arch">
|
<select id="arch">
|
||||||
<option value="" disabled selected>Select an architecture</option>
|
<option value="" disabled selected>Select an architecture</option>
|
||||||
<option value="arm">ARM</option>
|
{% for arch_name, arch in archs | items | sort(attribute='1.full_name') -%}
|
||||||
<option value="arm64">ARM 64</option>
|
<option value="{{ arch_name }}">{{ arch.full_name }}</option>
|
||||||
<option value="mips">MIPS</option>
|
{% endfor %}
|
||||||
<option value="posix">POSIX</option>
|
|
||||||
<option value="riscv">RISC-V</option>
|
|
||||||
<option value="sparc">SPARC</option>
|
|
||||||
<option value="arc">Synopsys DesignWare ARC</option>
|
|
||||||
<option value="x86">x86</option>
|
|
||||||
<option value="xtensa">Xtensa</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -22,11 +22,11 @@ ZEPHYR_BASE = Path(__file__).parents[2]
|
|||||||
ZEPHYR_BINDINGS = ZEPHYR_BASE / "dts/bindings"
|
ZEPHYR_BINDINGS = ZEPHYR_BASE / "dts/bindings"
|
||||||
EDT_PICKLE_PATHS = [
|
EDT_PICKLE_PATHS = [
|
||||||
"zephyr/edt.pickle",
|
"zephyr/edt.pickle",
|
||||||
"hello_world/zephyr/edt.pickle" # for board targets using sysbuild
|
"hello_world/zephyr/edt.pickle", # for board targets using sysbuild
|
||||||
]
|
]
|
||||||
RUNNERS_YAML_PATHS = [
|
RUNNERS_YAML_PATHS = [
|
||||||
"zephyr/runners.yaml",
|
"zephyr/runners.yaml",
|
||||||
"hello_world/zephyr/runners.yaml" # for board targets using sysbuild
|
"hello_world/zephyr/runners.yaml", # for board targets using sysbuild
|
||||||
]
|
]
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -73,8 +73,7 @@ class DeviceTreeUtils:
|
|||||||
The cached description for the node's compatible, creating it if needed.
|
The cached description for the node's compatible, creating it if needed.
|
||||||
"""
|
"""
|
||||||
return cls._compat_description_cache.setdefault(
|
return cls._compat_description_cache.setdefault(
|
||||||
node.matching_compat,
|
node.matching_compat, cls.get_first_sentence(node.description)
|
||||||
cls.get_first_sentence(node.description)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -176,9 +175,7 @@ def gather_board_build_info(twister_out_dir):
|
|||||||
if runners_yaml_file:
|
if runners_yaml_file:
|
||||||
with open(runners_yaml_file) as f:
|
with open(runners_yaml_file) as f:
|
||||||
runners_yaml = yaml.safe_load(f)
|
runners_yaml = yaml.safe_load(f)
|
||||||
board_runners.setdefault(board_name, {})[board_target] = (
|
board_runners.setdefault(board_name, {})[board_target] = runners_yaml
|
||||||
runners_yaml
|
|
||||||
)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing build info file {build_info_file}: {e}")
|
logger.error(f"Error processing build info file {build_info_file}: {e}")
|
||||||
@ -196,12 +193,14 @@ def run_twister_cmake_only(outdir, vendor_filter):
|
|||||||
twister_cmd = [
|
twister_cmd = [
|
||||||
sys.executable,
|
sys.executable,
|
||||||
f"{ZEPHYR_BASE}/scripts/twister",
|
f"{ZEPHYR_BASE}/scripts/twister",
|
||||||
"-T", "samples/hello_world/",
|
"-T",
|
||||||
|
"samples/hello_world/",
|
||||||
"-M",
|
"-M",
|
||||||
*[arg for path in EDT_PICKLE_PATHS for arg in ('--keep-artifacts', path)],
|
*[arg for path in EDT_PICKLE_PATHS for arg in ('--keep-artifacts', path)],
|
||||||
*[arg for path in RUNNERS_YAML_PATHS for arg in ('--keep-artifacts', path)],
|
*[arg for path in RUNNERS_YAML_PATHS for arg in ('--keep-artifacts', path)],
|
||||||
"--cmake-only",
|
"--cmake-only",
|
||||||
"--outdir", str(outdir),
|
"--outdir",
|
||||||
|
str(outdir),
|
||||||
]
|
]
|
||||||
|
|
||||||
if vendor_filter:
|
if vendor_filter:
|
||||||
@ -214,7 +213,7 @@ def run_twister_cmake_only(outdir, vendor_filter):
|
|||||||
'PATH': os.environ.get('PATH', ''),
|
'PATH': os.environ.get('PATH', ''),
|
||||||
'ZEPHYR_BASE': str(ZEPHYR_BASE),
|
'ZEPHYR_BASE': str(ZEPHYR_BASE),
|
||||||
'HOME': os.environ.get('HOME', ''),
|
'HOME': os.environ.get('HOME', ''),
|
||||||
'PYTHONPATH': os.environ.get('PYTHONPATH', '')
|
'PYTHONPATH': os.environ.get('PYTHONPATH', ''),
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -247,18 +246,22 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
if root is not None:
|
if root is not None:
|
||||||
module_settings[key].append(Path(module.project) / root)
|
module_settings[key].append(Path(module.project) / root)
|
||||||
|
|
||||||
Args = namedtuple("args", ["arch_roots", "board_roots", "soc_roots", "board_dir", "board"])
|
Args = namedtuple(
|
||||||
|
"args", ["arch_roots", "board_roots", "soc_roots", "board_dir", "board", "arch"]
|
||||||
|
)
|
||||||
args_find_boards = Args(
|
args_find_boards = Args(
|
||||||
arch_roots=module_settings["arch_root"],
|
arch_roots=module_settings["arch_root"],
|
||||||
board_roots=module_settings["board_root"],
|
board_roots=module_settings["board_root"],
|
||||||
soc_roots=module_settings["soc_root"],
|
soc_roots=module_settings["soc_root"],
|
||||||
board_dir=[],
|
board_dir=[],
|
||||||
board=None,
|
board=None,
|
||||||
|
arch=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
boards = list_boards.find_v2_boards(args_find_boards)
|
boards = list_boards.find_v2_boards(args_find_boards)
|
||||||
shields = list_shields.find_shields(args_find_boards)
|
shields = list_shields.find_shields(args_find_boards)
|
||||||
systems = list_hardware.find_v2_systems(args_find_boards)
|
systems = list_hardware.find_v2_systems(args_find_boards)
|
||||||
|
archs = list_hardware.find_v2_archs(args_find_boards)
|
||||||
board_catalog = {}
|
board_catalog = {}
|
||||||
shield_catalog = {}
|
shield_catalog = {}
|
||||||
board_devicetrees = {}
|
board_devicetrees = {}
|
||||||
@ -296,7 +299,6 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
binding_type = "misc"
|
binding_type = "misc"
|
||||||
is_custom_binding = True
|
is_custom_binding = True
|
||||||
|
|
||||||
|
|
||||||
if node.matching_compat is None:
|
if node.matching_compat is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -316,9 +318,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
else:
|
else:
|
||||||
locations.add("soc")
|
locations.add("soc")
|
||||||
|
|
||||||
existing_feature = features.get(binding_type, {}).get(
|
existing_feature = features.get(binding_type, {}).get(node.matching_compat)
|
||||||
node.matching_compat
|
|
||||||
)
|
|
||||||
|
|
||||||
node_info = {
|
node_info = {
|
||||||
"filename": str(filename),
|
"filename": str(filename),
|
||||||
@ -359,13 +359,13 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
|
|
||||||
# Grab all the twister files for this board and use them to figure out all the archs it
|
# Grab all the twister files for this board and use them to figure out all the archs it
|
||||||
# supports.
|
# supports.
|
||||||
archs = set()
|
board_archs = set()
|
||||||
pattern = f"{board.name}*.yaml"
|
pattern = f"{board.name}*.yaml"
|
||||||
for twister_file in board.dir.glob(pattern):
|
for twister_file in board.dir.glob(pattern):
|
||||||
try:
|
try:
|
||||||
with open(twister_file) as f:
|
with open(twister_file) as f:
|
||||||
board_data = yaml.safe_load(f)
|
board_data = yaml.safe_load(f)
|
||||||
archs.add(board_data.get("arch"))
|
board_archs.add(board_data.get("arch"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error parsing twister file {twister_file}: {e}")
|
logger.error(f"Error parsing twister file {twister_file}: {e}")
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
"full_name": full_name,
|
"full_name": full_name,
|
||||||
"doc_page": doc_page_path,
|
"doc_page": doc_page_path,
|
||||||
"vendor": vendor,
|
"vendor": vendor,
|
||||||
"archs": list(archs),
|
"archs": list(board_archs),
|
||||||
"socs": list(socs),
|
"socs": list(socs),
|
||||||
"revision_default": board.revision_default,
|
"revision_default": board.revision_default,
|
||||||
"supported_features": supported_features,
|
"supported_features": supported_features,
|
||||||
@ -403,6 +403,14 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
|
|||||||
"commands": runner.capabilities().commands,
|
"commands": runner.capabilities().commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arch_catalog = {
|
||||||
|
arch['name']: {
|
||||||
|
"name": arch['name'],
|
||||||
|
"full_name": arch.get('full_name', arch['name']),
|
||||||
|
}
|
||||||
|
for arch in archs['archs']
|
||||||
|
}
|
||||||
|
|
||||||
for shield in shields:
|
for shield in shields:
|
||||||
doc_page = guess_doc_page(shield)
|
doc_page = guess_doc_page(shield)
|
||||||
if doc_page and doc_page.is_relative_to(ZEPHYR_BASE):
|
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):
|
|||||||
"shields": shield_catalog,
|
"shields": shield_catalog,
|
||||||
"vendors": {**vnd_lookup.vnd2vendor, "others": "Other/Unknown"},
|
"vendors": {**vnd_lookup.vnd2vendor, "others": "Other/Unknown"},
|
||||||
"socs": socs_hierarchy,
|
"socs": socs_hierarchy,
|
||||||
|
"archs": arch_catalog,
|
||||||
"runners": available_runners,
|
"runners": available_runners,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user