1
-
2
1
if (LLVM_ENABLE_SPHINX )
3
2
include (AddSphinxTarget )
4
3
if (SPHINX_FOUND )
5
4
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 )
7
18
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/.
8
23
list (APPEND docgen_list
9
24
assert
10
25
ctype
@@ -26,9 +41,11 @@ if (SPHINX_FOUND)
26
41
)
27
42
28
43
foreach (stem IN LISTS docgen_list )
44
+ # docgen invocation.
29
45
add_custom_target (${stem} _rst
30
46
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.
32
49
add_dependencies (docs-libc-html ${stem} _rst )
33
50
endforeach ()
34
51
endif ()
0 commit comments