1-
21if (LLVM_ENABLE_SPHINX)
32include (AddSphinxTarget)
43if (SPHINX_FOUND)
54 if (${SPHINX_OUTPUT_HTML} )
6- add_sphinx_target(html libc)
5+ # Similar to clang, we copy our static .rst files from libc/docs/ to the
6+ # $build_dir/libc/docs/. That way, we can have a mix of both static
7+ # (committed) .rst files, and dynamically generated .rst files. We don't
8+ # want the dynamically generated .rst files to pollute the source tree.
9+ add_custom_target (copy-libc-rst-docs
10+ COMMAND "${CMAKE_COMMAND} " -E copy_directory
11+ "${CMAKE_CURRENT_SOURCE_DIR} " "${CMAKE_CURRENT_BINARY_DIR} " )
12+
13+ # Change sphinx to build from $build_dir/libc/docs/ rather than
14+ # llvm-project/libc/docs/.
15+ add_sphinx_target(html libc SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
16+ # Depend on the copy target.
17+ add_dependencies (docs-libc-html copy-libc-rst-docs)
718
19+ # Maintain a list of headers for which we dynamically generate html docs
20+ # for via docgen. For more complex docs (such as per arch support, a la
21+ # math.h), those should be omitted and exist statically in
22+ # libc/docs/headers/.
823 list (APPEND docgen_list
924 assert
1025 ctype
@@ -26,9 +41,11 @@ if (SPHINX_FOUND)
2641 )
2742
2843 foreach (stem IN LISTS docgen_list)
44+ # docgen invocation.
2945 add_custom_target (${stem} _rst
3046 COMMAND ${CMAKE_CURRENT_SOURCE_DIR} /../utils/docgen/docgen.py ${stem} .h >
31- ${CMAKE_CURRENT_SOURCE_DIR} /headers/${stem} .rst)
47+ ${CMAKE_CURRENT_BINARY_DIR} /headers/${stem} .rst)
48+ # depend on the docgen invocation.
3249 add_dependencies (docs-libc-html ${stem} _rst)
3350 endforeach ()
3451 endif ()
0 commit comments