@@ -82,20 +82,14 @@ if (LLVM_ENABLE_DOXYGEN)
8282endif ()
8383endif ()
8484
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 )
8686 if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${source} " )
8787 message (FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR} " )
8888 endif ()
8989 get_filename_component (TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /${source} " DIRECTORY )
9090 list (APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR} " )
9191 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} )
9993endfunction ()
10094
10195if (LLVM_ENABLE_SPHINX)
@@ -107,14 +101,22 @@ if (LLVM_ENABLE_SPHINX)
107101 # CLANG_TABLEGEN_EXE variable needs to be set for clang_tablegen to run without error
108102 find_program (CLANG_TABLEGEN_EXE "clang-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
109103
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)
112114
113115 if (${SPHINX_OUTPUT_HTML} )
114116 message (STATUS "Using index.md for html build" )
115117
116118 # 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
118120 # which is used for the HTML build.
119121 add_custom_target (copy-flang-src-docs-html
120122 COMMAND "${CMAKE_COMMAND} " -E copy_directory
@@ -141,26 +143,26 @@ if (LLVM_ENABLE_SPHINX)
141143 # MAN BUILD SETUP
142144 # ----------------------------
143145 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 " )
145147
146148 # Create minimal Source dir with ONLY the files needed for man build:
147149 # - conf.py (Sphinx config)
148150 # - index.rst (top-level man page)
149- # - FlangCommandLineReference .rst (generated reference)
151+ # - FlangCommandLineOptions .rst (generated reference)
150152 add_custom_target (copy-flang-src-docs-man
151153 COMMAND "${CMAKE_COMMAND} " -E make_directory
152154 "${FLANG_DOCS_MAN_DIR} "
153155 COMMAND "${CMAKE_COMMAND} " -E copy
154156 "${CMAKE_CURRENT_SOURCE_DIR} /conf.py"
155157 "${FLANG_DOCS_MAN_DIR} /conf.py"
156158 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"
159161 COMMAND "${CMAKE_COMMAND} " -E copy
160162 "${CMAKE_CURRENT_SOURCE_DIR} /CommandGuide/index.rst"
161163 "${FLANG_DOCS_MAN_DIR} /index.rst"
162- DEPENDS flang-doc gen-FlangCommandLineReference .rst)
163-
164+ DEPENDS flang-doc gen-FlangCommandLineOptions .rst)
165+
164166 add_sphinx_target(man flang SOURCE_DIR "${FLANG_DOCS_MAN_DIR} " )
165167 add_dependencies (docs-flang-man copy-flang-src-docs-man)
166168 endif ()
0 commit comments