@@ -82,20 +82,14 @@ if (LLVM_ENABLE_DOXYGEN)
82
82
endif ()
83
83
endif ()
84
84
85
- function (gen_rst_file_from_td output_file td_option source )
85
+ function (gen_rst_file_from_td output_file td_option source target )
86
86
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${source} " )
87
87
message (FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR} " )
88
88
endif ()
89
89
get_filename_component (TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${source} " DIRECTORY )
90
90
list (APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR} " )
91
91
list (APPEND LLVM_TABLEGEN_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR} /../../clang/include/clang/Driver/" )
92
- clang_tablegen (Source /${output_file} ${td_option} SOURCE ${source} TARGET "gen-${output_file} " )
93
- # clang_tablegen() does not create the output directory automatically,
94
- # so we have to create it explicitly.
95
- add_custom_target (create-flang-rst-output-dir
96
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} /Source
97
- )
98
- add_dependencies ("gen-${output_file} " create-flang-rst-output-dir )
92
+ clang_tablegen (Source /${output_file} ${td_option} SOURCE ${source} TARGET ${target} )
99
93
endfunction ()
100
94
101
95
if (LLVM_ENABLE_SPHINX )
@@ -107,14 +101,22 @@ if (LLVM_ENABLE_SPHINX)
107
101
# CLANG_TABLEGEN_EXE variable needs to be set for clang_tablegen to run without error
108
102
find_program (CLANG_TABLEGEN_EXE "clang-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
109
103
110
- # Generate the RST file from TableGen (shared by both HTML and MAN builds)
111
- gen_rst_file_from_td (FlangCommandLineReference.rst -gen-opt-docs FlangOptionsDocs.td )
104
+ # Generate the RST file from TableGen (for both HTML and MAN builds)
105
+ gen_rst_file_from_td (FlangCommandLineReference.rst -gen-opt-docs FlangOptionsDocs.td "gen-FlangCommandLineReference.rst" )
106
+ gen_rst_file_from_td (FlangCommandLineOptions.rst -gen-opt-docs FlangOptionsMan.td "gen-FlangCommandLineOptions.rst" )
107
+ # clang_tablegen() (called from gen_rst_file_from_td()) does not create the
108
+ # output directory automatically, so we have to create it explicitly.
109
+ add_custom_target (create-flang-rst-output-dir
110
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} /Source
111
+ )
112
+ add_dependencies ("gen-FlangCommandLineReference.rst" create-flang-rst-output-dir )
113
+ add_dependencies ("gen-FlangCommandLineOptions.rst" create-flang-rst-output-dir )
112
114
113
115
if (${SPHINX_OUTPUT_HTML} )
114
116
message (STATUS "Using index.md for html build" )
115
117
116
118
# Copy the entire flang/docs directory to the build Source dir,
117
- # then remove the index.rst file, to avoid clash with index.md
119
+ # then remove the index.rst file, to avoid clash with index.md
118
120
# which is used for the HTML build.
119
121
add_custom_target (copy-flang-src-docs-html
120
122
COMMAND "${CMAKE_COMMAND} " -E copy_directory
@@ -141,26 +143,26 @@ if (LLVM_ENABLE_SPHINX)
141
143
# MAN BUILD SETUP
142
144
# ----------------------------
143
145
if (${SPHINX_OUTPUT_MAN} )
144
- message (STATUS "NOTE: The Flang man page is currently a placeholder with a TODO. See docs/ CommandGuide/index.rst for details " )
146
+ message (STATUS "Using CommandGuide/index.rst for man build " )
145
147
146
148
# Create minimal Source dir with ONLY the files needed for man build:
147
149
# - conf.py (Sphinx config)
148
150
# - index.rst (top-level man page)
149
- # - FlangCommandLineReference .rst (generated reference)
151
+ # - FlangCommandLineOptions .rst (generated reference)
150
152
add_custom_target (copy-flang-src-docs-man
151
153
COMMAND "${CMAKE_COMMAND} " -E make_directory
152
154
"${FLANG_DOCS_MAN_DIR} "
153
155
COMMAND "${CMAKE_COMMAND} " -E copy
154
156
"${CMAKE_CURRENT_SOURCE_DIR} /conf.py"
155
157
"${FLANG_DOCS_MAN_DIR} /conf.py"
156
158
COMMAND "${CMAKE_COMMAND} " -E copy
157
- "${CMAKE_CURRENT_BINARY_DIR} /Source/FlangCommandLineReference .rst"
158
- "${FLANG_DOCS_MAN_DIR} /FlangCommandLineReference .rst"
159
+ "${CMAKE_CURRENT_BINARY_DIR} /Source/FlangCommandLineOptions .rst"
160
+ "${FLANG_DOCS_MAN_DIR} /FlangCommandLineOptions .rst"
159
161
COMMAND "${CMAKE_COMMAND} " -E copy
160
162
"${CMAKE_CURRENT_SOURCE_DIR} /CommandGuide/index.rst"
161
163
"${FLANG_DOCS_MAN_DIR} /index.rst"
162
- DEPENDS flang-doc gen-FlangCommandLineReference .rst )
163
-
164
+ DEPENDS flang-doc gen-FlangCommandLineOptions .rst )
165
+
164
166
add_sphinx_target (man flang SOURCE_DIR "${FLANG_DOCS_MAN_DIR} " )
165
167
add_dependencies (docs-flang-man copy-flang-src-docs-man )
166
168
endif ()
0 commit comments