@@ -10,6 +10,17 @@ if (SPHINX_FOUND)
10
10
COMMAND "${CMAKE_COMMAND} " -E copy_directory
11
11
"${CMAKE_CURRENT_SOURCE_DIR} " "${CMAKE_CURRENT_BINARY_DIR} " )
12
12
13
+ # For headers that are nested in directories, we need to
14
+ # `mkdir $build_dir/libc/docs/headers/$dir` since the above copy_directory
15
+ # command does not create such copies. Otherwise, the invocation of docgen
16
+ # below will fail since the output file would be placed in a directory that
17
+ # does not exist, leading to a `No such file or directory` error from the
18
+ # shell.
19
+ file (MAKE_DIRECTORY
20
+ "${CMAKE_CURRENT_BINARY_DIR} /headers/arpa/"
21
+ "${CMAKE_CURRENT_BINARY_DIR} /headers/sys/"
22
+ )
23
+
13
24
# Change sphinx to build from $build_dir/libc/docs/ rather than
14
25
# llvm-project/libc/docs/.
15
26
add_sphinx_target (html libc SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
@@ -21,6 +32,7 @@ if (SPHINX_FOUND)
21
32
# math.h), those should be omitted and exist statically in
22
33
# libc/docs/headers/.
23
34
list (APPEND docgen_list
35
+ arpa/inet
24
36
assert
25
37
ctype
26
38
errno
@@ -34,19 +46,25 @@ if (SPHINX_FOUND)
34
46
stdlib
35
47
string
36
48
strings
49
+ sys/mman
37
50
threads
38
51
uchar
39
52
wchar
40
53
wctype
41
54
)
42
55
43
56
foreach (stem IN LISTS docgen_list )
57
+ # It is an error in cmake to have a target name that contains a "/", but
58
+ # docgen relies on the "/" to find headers nested under directories.
59
+ # Replace with underscore.
60
+ string (REPLACE "/" "_" stem_rst ${stem} )
61
+
44
62
# docgen invocation.
45
- add_custom_target (${stem} _rst
63
+ add_custom_target (${stem_rst}
46
64
COMMAND ${CMAKE_CURRENT_SOURCE_DIR} /../utils/docgen/docgen.py ${stem} .h >
47
65
${CMAKE_CURRENT_BINARY_DIR} /headers/${stem}.rst )
48
66
# depend on the docgen invocation.
49
- add_dependencies (docs-libc-html ${stem} _rst )
67
+ add_dependencies (docs-libc-html ${stem_rst} )
50
68
endforeach ()
51
69
endif ()
52
70
endif ()
0 commit comments