Skip to content

Commit 047f6da

Browse files
committed
doc: Add vendor filter for hw feature generation
The hw feature generation takes a long time. The HW_FEATURES_TURBO_MODE option completely disables hw feature generation. Add a new option HW_FEATURES_VENDOR_FILTER to be able to selectively enable hw feature generation only for a given list of vendors. This option is useful when working on board documentation pages. Signed-off-by: Aksel Skauge Mellbye <[email protected]>
1 parent e55a505 commit 047f6da

File tree

7 files changed

+40
-5
lines changed

7 files changed

+40
-5
lines changed

doc/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set(SPHINXOPTS_EXTRA "" CACHE STRING "Extra Sphinx Options (added to defaults)")
1717
set(LATEXMKOPTS "-halt-on-error -no-shell-escape" CACHE STRING "Default latexmk options")
1818
set(DT_TURBO_MODE OFF CACHE BOOL "Enable DT turbo mode")
1919
set(HW_FEATURES_TURBO_MODE OFF CACHE BOOL "Enable HW features turbo mode")
20+
set(HW_FEATURES_VENDOR_FILTER "" CACHE BOOL "Vendor filter for HW features")
2021
set(DOC_TAG "development" CACHE STRING "Documentation tag")
2122
set(DTS_ROOTS "${ZEPHYR_BASE}" CACHE STRING "DT bindings root folders")
2223

@@ -160,6 +161,11 @@ foreach(tag ${SPHINX_TAGS})
160161
list(APPEND SPHINX_TAGS_ARGS "-t" "${tag}")
161162
endforeach()
162163

164+
if(HW_FEATURES_VENDOR_FILTER)
165+
list(JOIN HW_FEATURES_VENDOR_FILTER "," vendor_filter)
166+
list(APPEND SPHINXOPTS "-D" "zephyr_hw_features_vendor_filter=${vendor_filter}")
167+
endif()
168+
163169
add_doc_target(
164170
html
165171
COMMAND ${CMAKE_COMMAND} -E env ${SPHINX_ENV} OUTPUT_DIR=${DOCS_HTML_DIR}

doc/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SPHINXOPTS_EXTRA ?=
99
LATEXMKOPTS ?= -halt-on-error -no-shell-escape
1010
DT_TURBO_MODE ?= 0
1111
HW_FEATURES_TURBO_MODE ?= 0
12+
HW_FEATURES_VENDOR_FILTER ?=
1213

1314
# ------------------------------------------------------------------------------
1415
# Documentation targets
@@ -34,7 +35,8 @@ configure:
3435
-DSPHINXOPTS_EXTRA="${SPHINXOPTS_EXTRA}" \
3536
-DLATEXMKOPTS="${LATEXMKOPTS}" \
3637
-DDT_TURBO_MODE=${DT_TURBO_MODE} \
37-
-DHW_FEATURES_TURBO_MODE=${HW_FEATURES_TURBO_MODE}
38+
-DHW_FEATURES_TURBO_MODE=${HW_FEATURES_TURBO_MODE} \
39+
-DHW_FEATURES_VENDOR_FILTER=${HW_FEATURES_VENDOR_FILTER}
3840

3941
clean:
4042
cmake --build ${BUILDDIR} --target clean

doc/_extensions/zephyr/domain/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,8 @@ def load_board_catalog_into_domain(app: Sphinx) -> None:
13661366
board_catalog = get_catalog(
13671367
generate_hw_features=(
13681368
app.builder.format == "html" and app.config.zephyr_generate_hw_features
1369-
)
1369+
),
1370+
hw_features_vendor_filter=app.config.zephyr_hw_features_vendor_filter
13701371
)
13711372
app.env.domaindata["zephyr"]["boards"] = board_catalog["boards"]
13721373
app.env.domaindata["zephyr"]["vendors"] = board_catalog["vendors"]
@@ -1377,6 +1378,7 @@ def load_board_catalog_into_domain(app: Sphinx) -> None:
13771378
def setup(app):
13781379
app.add_config_value("zephyr_breathe_insert_related_samples", False, "env")
13791380
app.add_config_value("zephyr_generate_hw_features", False, "env")
1381+
app.add_config_value("zephyr_hw_features_vendor_filter", [], "env", types=[list[str]])
13801382

13811383
app.add_domain(ZephyrDomain)
13821384

doc/_scripts/gen_boards_catalog.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,12 @@ def gather_board_build_info(twister_out_dir):
185185
return board_devicetrees, board_runners
186186

187187

188-
def run_twister_cmake_only(outdir):
188+
def run_twister_cmake_only(outdir, vendor_filter):
189189
"""Run twister in cmake-only mode to generate build info files.
190190
191191
Args:
192192
outdir: Directory where twister should output its files
193+
vendor_filter: Limit build info to boards from listed vendors
193194
"""
194195
twister_cmd = [
195196
sys.executable,
@@ -203,6 +204,9 @@ def run_twister_cmake_only(outdir):
203204
"--outdir", str(outdir),
204205
]
205206

207+
for vendor in vendor_filter:
208+
twister_cmd += ["--vendor", vendor]
209+
206210
minimal_env = {
207211
'PATH': os.environ.get('PATH', ''),
208212
'ZEPHYR_BASE': str(ZEPHYR_BASE),
@@ -216,11 +220,13 @@ def run_twister_cmake_only(outdir):
216220
logger.warning(f"Failed to run Twister, list of hw features might be incomplete.\n{e}")
217221

218222

219-
def get_catalog(generate_hw_features=False):
223+
def get_catalog(generate_hw_features=False, hw_features_vendor_filter=[]):
220224
"""Get the board catalog.
221225
222226
Args:
223227
generate_hw_features: If True, run twister to generate hardware features information.
228+
hw_features_vendor_filter: If generate_hw_features is True, limit hardware feature
229+
information generation to boards from this list of vendors.
224230
"""
225231
import tempfile
226232

@@ -256,7 +262,7 @@ def get_catalog(generate_hw_features=False):
256262
if generate_hw_features:
257263
logger.info("Running twister in cmake-only mode to get Devicetree files for all boards")
258264
with tempfile.TemporaryDirectory() as tmp_dir:
259-
run_twister_cmake_only(tmp_dir)
265+
run_twister_cmake_only(tmp_dir, hw_features_vendor_filter)
260266
board_devicetrees, board_runners = gather_board_build_info(Path(tmp_dir))
261267
else:
262268
logger.info("Skipping generation of supported hardware features.")

doc/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@
327327

328328
zephyr_breathe_insert_related_samples = True
329329
zephyr_generate_hw_features = not tags.has("hw_features_turbo") # pylint: disable=undefined-variable # noqa: F821
330+
zephyr_hw_features_vendor_filter = []
330331

331332
# -- Options for sphinx.ext.graphviz --------------------------------------
332333

doc/contribute/documentation/generation.rst

+13
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,19 @@ without either of the aforementioned features::
268268
# and supported features index
269269
make html-fast
270270

271+
When working with documentation for boards from a specific vendor, it is also
272+
possible to limit generation of the list of supported features to subset of board
273+
vendors. This can be done by setting the following option when invoking cmake::
274+
275+
-DHW_FEATURES_VENDOR_FILTER=vendor1,vendor2
276+
277+
This option can also be used with the :command:`make` wrapper::
278+
279+
cd ~/zephyrproject/zephyr/doc
280+
281+
# To generate HTML output with supported features limited to a subset of vendors
282+
make html HW_FEATURES_VENDOR_FILTER=vendor1,vendor2
283+
271284
Viewing generated documentation locally
272285
***************************************
273286

doc/contribute/documentation/guidelines.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,11 @@ Boards
12811281
(``zephyr_generate_hw_features`` config option set to ``True``). If disabled, a warning message
12821282
will be shown instead of the hardware features tables.
12831283

1284+
It is possible to limit the hardware features generation to boards from a specific list of vendors
1285+
to speed up documentation builds without completely disabling the hardware features table. Set the
1286+
config option ``zephyr_hw_features_vendor_filter`` to the list of vendors to generate features for.
1287+
If the option is empty, hardware features are generated for all boards from all vendors.
1288+
12841289
.. rst:directive:: .. zephyr:board-supported-runners::
12851290
12861291
This directive is used to show the supported runners for the board documented in the current

0 commit comments

Comments
 (0)