2019-04-06 15:08:09 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-12-11 16:33:23 +01:00
|
|
|
cmake_minimum_required(VERSION 3.13.1)
|
2019-01-04 09:13:07 +01:00
|
|
|
project(Zephyr-Kernel-Doc LANGUAGES)
|
2018-07-09 14:12:17 +02:00
|
|
|
|
2020-02-12 15:42:09 +01:00
|
|
|
set(NO_BOILERPLATE TRUE)
|
2020-05-29 06:54:50 +02:00
|
|
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} ..)
|
2020-02-12 15:42:09 +01:00
|
|
|
|
|
|
|
file(TO_CMAKE_PATH "${ZEPHYR_BASE}" ZEPHYR_BASE)
|
2018-07-09 14:12:17 +02:00
|
|
|
message(STATUS "Zephyr base: ${ZEPHYR_BASE}")
|
|
|
|
|
2021-06-16 21:19:35 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Options
|
|
|
|
|
|
|
|
set(SPHINXOPTS "-j auto" CACHE STRING "Default Sphinx Options")
|
|
|
|
set(DOC_TAG "development" CACHE STRING "Documentation tag")
|
|
|
|
|
|
|
|
separate_arguments(SPHINXOPTS)
|
|
|
|
|
2021-06-16 21:12:36 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Dependencies
|
|
|
|
|
2018-07-09 14:12:17 +02:00
|
|
|
set(DOXYGEN_SKIP_DOT True)
|
|
|
|
find_package(Doxygen REQUIRED)
|
2021-06-16 21:12:36 +02:00
|
|
|
|
|
|
|
find_program(SPHINXBUILD sphinx-build)
|
|
|
|
if(NOT SPHINXBUILD)
|
|
|
|
message(FATAL_ERROR "The 'sphinx-build' command was not found")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(LATEX COMPONENTS PDFLATEX)
|
|
|
|
find_program(LATEXMK latexmk)
|
|
|
|
if(NOT LATEX_PDFLATEX_FOUND OR NOT LATEXMK)
|
|
|
|
message(WARNING "LaTeX components not found. PDF build will not be available.")
|
2018-07-09 14:12:17 +02:00
|
|
|
endif()
|
|
|
|
|
2021-06-16 21:12:36 +02:00
|
|
|
include(${ZEPHYR_BASE}/cmake/python.cmake)
|
|
|
|
|
2021-06-16 20:21:08 +02:00
|
|
|
# Find west to (optionally) process modules for Kconfig
|
|
|
|
find_program(WEST west)
|
|
|
|
|
2021-06-16 23:14:29 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Environment & Paths
|
|
|
|
|
|
|
|
set(SPHINX_ENV
|
|
|
|
ZEPHYR_BASE=${ZEPHYR_BASE}
|
|
|
|
ZEPHYR_BUILD=${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(DOCS_CFG_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
set(DOCS_DOCTREE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doctrees)
|
|
|
|
set(DOCS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(DOCS_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/src)
|
|
|
|
set(DOCS_HTML_DIR ${CMAKE_CURRENT_BINARY_DIR}/html)
|
|
|
|
set(DOCS_LATEX_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Functions
|
|
|
|
|
|
|
|
# Create a custom doc target.
|
|
|
|
#
|
|
|
|
# This function has the same signature as `add_custom_target()`
|
|
|
|
#
|
|
|
|
# The function will create two targets for the doc build system.
|
|
|
|
# - Target 1 named: `<name>`
|
|
|
|
# - Target 2 named: `<name>-nodeps`
|
|
|
|
#
|
|
|
|
# Both targets will produce same result, but target 2 must have no dependencies.
|
|
|
|
# This is useful to, e.g. re-run the Sphinx build without dependencies such as
|
|
|
|
# devicetree or Kconfig generators.
|
|
|
|
#
|
|
|
|
function(add_doc_target name)
|
|
|
|
add_custom_target(${name} ${ARGN})
|
|
|
|
add_custom_target(${name}-nodeps ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
2021-06-16 22:43:15 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Doxygen (standalone)
|
|
|
|
|
|
|
|
set(DOXY_OUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
|
2018-07-16 19:05:05 +02:00
|
|
|
set(DOXYFILE_IN ${CMAKE_CURRENT_LIST_DIR}/zephyr.doxyfile.in)
|
|
|
|
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/zephyr.doxyfile)
|
2018-07-09 14:12:17 +02:00
|
|
|
|
2018-07-16 19:05:05 +02:00
|
|
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
2018-07-09 14:12:17 +02:00
|
|
|
|
2019-02-07 22:39:59 +01:00
|
|
|
add_custom_target(
|
2021-04-16 10:47:43 +02:00
|
|
|
doxygen
|
2021-06-16 22:43:15 +02:00
|
|
|
COMMAND
|
|
|
|
${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
2019-02-07 22:39:59 +01:00
|
|
|
)
|
|
|
|
|
2018-07-09 14:12:17 +02:00
|
|
|
add_custom_target(
|
|
|
|
pristine
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${ZEPHYR_BASE}/cmake/pristine.cmake
|
|
|
|
)
|
|
|
|
|
2021-06-16 23:24:51 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# kconfig
|
2018-07-09 14:12:17 +02:00
|
|
|
|
2021-06-16 23:24:51 +02:00
|
|
|
set(KCONFIG_BINARY_DIR ${CMAKE_BINARY_DIR}/Kconfig)
|
|
|
|
list(INSERT MODULE_EXT_ROOT 0 ${ZEPHYR_BASE})
|
|
|
|
file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR})
|
|
|
|
|
|
|
|
include(${ZEPHYR_BASE}/cmake/extensions.cmake)
|
|
|
|
include(${ZEPHYR_BASE}/cmake/zephyr_module.cmake)
|
2020-10-12 20:02:46 +02:00
|
|
|
|
2021-01-22 14:08:41 +01:00
|
|
|
foreach(module_name ${ZEPHYR_MODULE_NAMES})
|
|
|
|
zephyr_string(SANITIZE TOUPPER MODULE_NAME_UPPER ${module_name})
|
|
|
|
list(APPEND
|
|
|
|
ZEPHYR_KCONFIG_MODULES
|
|
|
|
"ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR=${ZEPHYR_${MODULE_NAME_UPPER}_MODULE_DIR}"
|
|
|
|
)
|
|
|
|
|
|
|
|
if(ZEPHYR_${MODULE_NAME_UPPER}_KCONFIG)
|
|
|
|
list(APPEND
|
|
|
|
ZEPHYR_KCONFIG_MODULES
|
|
|
|
"ZEPHYR_${MODULE_NAME_UPPER}_KCONFIG=${ZEPHYR_${MODULE_NAME_UPPER}_KCONFIG}"
|
2021-06-16 23:24:51 +02:00
|
|
|
)
|
2021-01-22 14:08:41 +01:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2021-06-16 23:24:51 +02:00
|
|
|
if(WIN32)
|
|
|
|
set(SEP $<SEMICOLON>)
|
|
|
|
else()
|
|
|
|
set(SEP :)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(GEN_KCONFIG_REST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/_scripts/gen_kconfig_rest.py)
|
|
|
|
|
2018-07-09 14:12:17 +02:00
|
|
|
add_custom_target(
|
|
|
|
kconfig
|
2021-06-16 23:17:23 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOCS_SRC_DIR}/reference/kconfig
|
2018-07-16 19:05:05 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env
|
2019-12-03 17:07:53 +01:00
|
|
|
PYTHONPATH=${ZEPHYR_BASE}/scripts/kconfig${SEP}$ENV{PYTHONPATH}
|
2019-05-10 12:23:23 +02:00
|
|
|
ZEPHYR_BASE=${ZEPHYR_BASE}
|
2018-07-09 14:12:17 +02:00
|
|
|
srctree=${ZEPHYR_BASE}
|
2019-10-21 20:20:18 +02:00
|
|
|
BOARD_DIR=boards/*/*
|
2018-09-05 12:58:05 +02:00
|
|
|
ARCH=*
|
2019-10-21 20:20:18 +02:00
|
|
|
ARCH_DIR=arch
|
|
|
|
SOC_DIR=soc
|
2020-07-06 12:53:39 +02:00
|
|
|
KCONFIG_BINARY_DIR=${KCONFIG_BINARY_DIR}
|
2019-03-28 17:51:39 +01:00
|
|
|
KCONFIG_WARN_UNDEF=y
|
2019-01-21 19:58:05 +01:00
|
|
|
KCONFIG_TURBO_MODE=${KCONFIG_TURBO_MODE}
|
2019-01-30 17:54:21 +01:00
|
|
|
KCONFIG_DOC_MODE=1
|
2021-01-22 14:08:41 +01:00
|
|
|
${ZEPHYR_KCONFIG_MODULES}
|
2021-06-16 23:24:51 +02:00
|
|
|
${PYTHON_EXECUTABLE} ${GEN_KCONFIG_REST_SCRIPT} ${DOCS_SRC_DIR}/reference/kconfig/
|
2019-12-10 15:11:01 +01:00
|
|
|
--separate-all-index
|
2019-11-21 19:37:58 +01:00
|
|
|
--keep-module-paths
|
2019-12-03 17:07:53 +01:00
|
|
|
--modules Architecture,arch,${ZEPHYR_BASE}/arch
|
|
|
|
Driver,drivers,${ZEPHYR_BASE}/drivers
|
|
|
|
Kernel,kernel,${ZEPHYR_BASE}/kernel
|
|
|
|
Library,lib,${ZEPHYR_BASE}/lib
|
|
|
|
Subsystem,subsys,${ZEPHYR_BASE}/subsys
|
|
|
|
"External Module,modules,${ZEPHYR_BASE}/modules"
|
|
|
|
|
|
|
|
VERBATIM
|
2018-07-09 14:12:17 +02:00
|
|
|
)
|
|
|
|
|
2021-06-16 23:24:51 +02:00
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${GEN_KCONFIG_REST_SCRIPT})
|
|
|
|
|
2020-10-12 20:02:46 +02:00
|
|
|
#
|
|
|
|
# Generated devicetree .rst documents
|
|
|
|
#
|
|
|
|
# The devicetree bindings discovered in ${DTS_ROOTS} are parsed and
|
|
|
|
# documentation for them is generated in the directory
|
|
|
|
# ${DTS_BINDINGS_RST_OUT}.
|
|
|
|
#
|
|
|
|
# The CMake variable GEN_DEVICETREE_REST_ZEPHYR_DOCSET will
|
|
|
|
# be passed to the script in the environment. This allows separating
|
|
|
|
# the bindings documentation into a standalone Sphinx docset that
|
|
|
|
# nonetheless can link to Zephyr documentation using intersphinx.
|
|
|
|
# If empty, the variable has no effect on the script.
|
|
|
|
#
|
|
|
|
# If not set, these are the default values for these variables:
|
|
|
|
#
|
|
|
|
# - DTS_ROOTS: ZEPHYR_BASE
|
2021-06-16 23:17:23 +02:00
|
|
|
# - DTS_BINDINGS_RST_OUT: ${DOCS_SRC_DIR}/reference/devicetree
|
2020-10-12 20:02:46 +02:00
|
|
|
#
|
|
|
|
|
2021-03-29 20:50:01 +02:00
|
|
|
set(GEN_DEVICETREE_REST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/_scripts/gen_devicetree_rest.py)
|
2020-10-12 20:02:46 +02:00
|
|
|
|
|
|
|
if(NOT DTS_ROOTS)
|
|
|
|
set(DTS_ROOTS ${ZEPHYR_BASE})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(DTS_ROOT_ARGS)
|
|
|
|
foreach(root ${DTS_ROOTS})
|
|
|
|
list(APPEND DTS_ROOT_ARGS --dts-root ${root})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(NOT DTS_BINDINGS_RST_OUT)
|
2021-06-16 23:17:23 +02:00
|
|
|
set(DTS_BINDINGS_RST_OUT ${DOCS_SRC_DIR}/reference/devicetree)
|
2020-10-12 20:02:46 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
devicetree
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env
|
2021-03-27 00:18:58 +01:00
|
|
|
PYTHONPATH=${ZEPHYR_BASE}/scripts/dts/python-devicetree/src${SEP}$ENV{PYTHONPATH}
|
2020-10-12 20:02:46 +02:00
|
|
|
ZEPHYR_BASE=${ZEPHYR_BASE}
|
|
|
|
GEN_DEVICETREE_REST_ZEPHYR_DOCSET=${GEN_DEVICETREE_REST_ZEPHYR_DOCSET}
|
|
|
|
${PYTHON_EXECUTABLE} ${GEN_DEVICETREE_REST_SCRIPT}
|
|
|
|
--vendor-prefixes ${ZEPHYR_BASE}/dts/bindings/vendor-prefixes.txt
|
|
|
|
${DTS_ROOT_ARGS} ${DTS_BINDINGS_RST_OUT}
|
|
|
|
VERBATIM
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
|
|
COMMENT "Running gen_devicetree_rest.py ${DTS_BINDINGS_RST_OUT}"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${GEN_DEVICETREE_REST_SCRIPT})
|
2018-07-09 14:12:17 +02:00
|
|
|
|
2021-06-16 22:30:23 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# html
|
|
|
|
|
|
|
|
add_doc_target(
|
2018-07-09 14:12:17 +02:00
|
|
|
html
|
2021-06-16 22:30:23 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env ${SPHINX_ENV}
|
|
|
|
${SPHINXBUILD}
|
|
|
|
-b html
|
|
|
|
-c ${DOCS_CFG_DIR}
|
|
|
|
-d ${DOCS_DOCTREE_DIR}
|
|
|
|
-w ${DOCS_BUILD_DIR}/html.log
|
|
|
|
-t ${DOC_TAG}
|
|
|
|
${SPHINXOPTS}
|
|
|
|
${DOCS_SRC_DIR}
|
|
|
|
${DOCS_HTML_DIR}
|
2021-05-10 18:29:04 +02:00
|
|
|
USES_TERMINAL
|
2018-08-23 20:11:11 +02:00
|
|
|
)
|
|
|
|
|
2021-06-16 22:30:23 +02:00
|
|
|
add_dependencies(html devicetree kconfig)
|
|
|
|
|
2021-06-16 23:10:30 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# pdf
|
2018-10-09 22:24:34 +02:00
|
|
|
|
2021-06-16 23:10:30 +02:00
|
|
|
set(FIX_TEX_SCRIPT ${ZEPHYR_BASE}/doc/_scripts/fix_tex.py)
|
2018-09-11 02:29:20 +02:00
|
|
|
|
2021-06-16 23:10:30 +02:00
|
|
|
add_doc_target(
|
2018-09-11 02:29:20 +02:00
|
|
|
latex
|
2021-06-16 23:10:30 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env ${SPHINX_ENV}
|
|
|
|
${SPHINXBUILD}
|
|
|
|
-b latex
|
|
|
|
-c ${DOCS_CFG_DIR}
|
|
|
|
-d ${DOCS_DOCTREE_DIR}
|
|
|
|
-w ${DOCS_BUILD_DIR}/latex.log
|
|
|
|
-t ${DOC_TAG}
|
|
|
|
-t svgconvert
|
|
|
|
${SPHINXOPTS}
|
|
|
|
${DOCS_SRC_DIR}
|
|
|
|
${DOCS_LATEX_DIR}
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${FIX_TEX_SCRIPT} ${DOCS_LATEX_DIR}/zephyr.tex
|
|
|
|
USES_TERMINAL
|
2018-08-23 20:11:11 +02:00
|
|
|
)
|
|
|
|
|
2021-05-10 19:11:14 +02:00
|
|
|
add_dependencies(latex kconfig devicetree)
|
2018-08-23 20:11:11 +02:00
|
|
|
|
2021-06-16 23:10:30 +02:00
|
|
|
if(LATEX_PDFLATEX_FOUND AND LATEXMK)
|
|
|
|
add_custom_target(
|
|
|
|
pdf
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env LATEXOPTS="-halt-on-error -no-shell-escape"
|
|
|
|
${LATEXMK} -quiet -pdf -dvi- -ps-
|
|
|
|
WORKING_DIRECTORY ${DOCS_LATEX_DIR}
|
|
|
|
)
|
2018-08-23 20:11:11 +02:00
|
|
|
|
2021-06-16 23:10:30 +02:00
|
|
|
add_dependencies(pdf latex)
|
2018-08-23 20:11:11 +02:00
|
|
|
endif()
|