[PATCH] D149809: [Clang][Docs] Fix man page build
Aiden Grossman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 3 19:21:03 PDT 2023
aidengrossman created this revision.
Herald added a project: All.
aidengrossman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch fixes the man page build. It currently doesn't work as
SOURCE_DIR isn't set correctly (just undefined) within the
add_sphinx_target function. This patch also moves around the creation of
targets for autogenerated rst files so that both the man page and html
build can depend upon them as before only the html build depended on
them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149809
Files:
clang/docs/CMakeLists.txt
Index: clang/docs/CMakeLists.txt
===================================================================
--- clang/docs/CMakeLists.txt
+++ clang/docs/CMakeLists.txt
@@ -90,50 +90,59 @@
endif()
endif()
-function (gen_rst_file_from_td output_file td_option source docs_target)
+function (gen_rst_file_from_td output_file td_option source)
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
message(FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR}")
endif()
get_filename_component(TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${source}" DIRECTORY)
list(APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR}")
clang_tablegen(${output_file} ${td_option} SOURCE ${source} TARGET "gen-${output_file}")
- add_dependencies(${docs_target} "gen-${output_file}")
+endfunction()
+
+function (gen_docs_depends docs_target)
+ add_dependencies(${docs_target} copy-clang-rst-docs)
+
+ add_dependencies(${docs_target} "gen-AttributeReference.rst")
+ add_dependencies(${docs_target} "gen-DiagnosticsReference.rst")
+ add_dependencies(${docs_target} "gen-ClangCommandLineReference.rst")
endfunction()
if (LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
- if (SPHINX_FOUND)
+ if (SPHINX_FOUND AND (${SPHINX_OUTPUT_HTML} OR ${SPHINX_OUTPUT_MAN}))
+ # Copy rst files to build directory before generating the html
+ # documentation. Some of the rst files are generated, so they
+ # only exist in the build directory. Sphinx needs all files in
+ # the same directory in order to generate the html, so we need to
+ # copy all the non-gnerated rst files from the source to the build
+ # directory before we run sphinx.
+ add_custom_target(copy-clang-rst-docs
+ COMMAND "${CMAKE_COMMAND}" -E copy_directory
+ "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
+
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different
+ "${CMAKE_CURRENT_SOURCE_DIR}/../CodeOwners.rst"
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ )
+
+ # Generated files
+ gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td)
+ gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td)
+ gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td)
+
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- # Copy rst files to build directory before generating the html
- # documentation. Some of the rst files are generated, so they
- # only exist in the build directory. Sphinx needs all files in
- # the same directory in order to generate the html, so we need to
- # copy all the non-gnerated rst files from the source to the build
- # directory before we run sphinx.
- add_custom_target(copy-clang-rst-docs
- COMMAND "${CMAKE_COMMAND}" -E copy_directory
- "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
-
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different
- "${CMAKE_CURRENT_SOURCE_DIR}/../CodeOwners.rst"
- "${CMAKE_CURRENT_BINARY_DIR}"
- )
- add_dependencies(docs-clang-html copy-clang-rst-docs)
-
add_custom_command(TARGET docs-clang-html POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/LibASTMatchersReference.html"
"${CMAKE_CURRENT_BINARY_DIR}/html/LibASTMatchersReference.html")
- # Generated files
- gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td docs-clang-html)
- gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td docs-clang-html)
- gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td docs-clang-html)
+ gen_docs_depends(docs-clang-html)
endif()
if (${SPHINX_OUTPUT_MAN})
- add_sphinx_target(man clang)
+ add_sphinx_target(man clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ gen_docs_depends(docs-clang-man)
endif()
endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149809.519335.patch
Type: text/x-patch
Size: 4160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230504/4b3a6e02/attachment.bin>
More information about the cfe-commits
mailing list