| 1 | # SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | # Optional target for regenerating integration documentation from metadata.yaml files. |
| 3 | # |
| 4 | # Usage: |
| 5 | # ninja -C build render-docs |
| 6 | # |
| 7 | # This target is never part of ALL, so it has zero impact on normal builds. |
| 8 | # On first invocation it creates a Python venv in the build directory and |
| 9 | # installs the required packages. Subsequent runs reuse the existing venv. |
| 10 | |
| 11 | include_guard() |
| 12 | |
| 13 | set(_render_docs_venv_dir "${CMAKE_BINARY_DIR}/_render_docs_venv") |
| 14 | set(_render_docs_venv_stamp "${_render_docs_venv_dir}/.stamp") |
| 15 | set(_render_docs_scripts_dir "${CMAKE_SOURCE_DIR}/integrations") |
| 16 | |
| 17 | add_custom_command( |
| 18 | OUTPUT "${_render_docs_venv_stamp}" |
| 19 | DEPENDS "${_render_docs_scripts_dir}/pip.sh" |
| 20 | COMMAND python3 -m venv "${_render_docs_venv_dir}" |
| 21 | COMMAND "${_render_docs_venv_dir}/bin/pip" install -q jsonschema referencing jinja2 ruamel.yaml |
| 22 | COMMAND "${CMAKE_COMMAND}" -E touch "${_render_docs_venv_stamp}" |
| 23 | COMMENT "Creating Python venv for render-docs" |
| 24 | ) |
| 25 | |
| 26 | add_custom_target(render-docs |
| 27 | DEPENDS "${_render_docs_venv_stamp}" |
| 28 | COMMAND "${_render_docs_venv_dir}/bin/python3" "${_render_docs_scripts_dir}/gen_integrations.py" |
| 29 | COMMAND "${_render_docs_venv_dir}/bin/python3" "${_render_docs_scripts_dir}/gen_docs_integrations.py" |
| 30 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
| 31 | COMMENT "Generating integration documentation from metadata.yaml files" |
| 32 | ) |