This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Docs] Fix man page build
ClosedPublic

Authored by aidengrossman on May 3 2023, 7:21 PM.

Details

Summary

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.

Diff Detail

Event Timeline

aidengrossman created this revision.May 3 2023, 7:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 7:21 PM
aidengrossman requested review of this revision.May 3 2023, 7:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 7:21 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Posting this as when I was setting up a new dev environment with -DLLVM_ENABLE_SPHINX, it defaults to having SPHINX_OUTPUT_HTML and SPHINX_OUTPUT_MAN on, and the man build was broken so when I tried to build the default target, it failed. This patch fixes the clang man page build.

Not sure this is the ideal approach. I'd really like to remove the redundancy between the generated targets reference in gen_docs_depends and their values as specified in the calls to gen_rst_files_from_td, but CMake doesn't really seem to have appropriate data structures (a list of tuples or something similar) to accomplish this. Very open to suggestions here though since I'm not that familiar with CMake.

I think we could remove some of the duplication by making the docs_target parameter into a list and passing both docs-clang-html and docs-clang-man to it.

I think we could remove some of the duplication by making the docs_target parameter into a list and passing both docs-clang-html and docs-clang-man to it.

If I'm understanding things correctly we wouldn't be able to do this for either the gen_docs_depends or gen_rst_file_from_td functions because someone might have the HTML docs build turned on and the man pages build turned off or vice versa. We can only add dependencies to the target after it's created as far as I'm aware.

I think we could remove some of the duplication by making the docs_target parameter into a list and passing both docs-clang-html and docs-clang-man to it.

If I'm understanding things correctly we wouldn't be able to do this for either the gen_docs_depends or gen_rst_file_from_td functions because someone might have the HTML docs build turned on and the man pages build turned off or vice versa. We can only add dependencies to the target after it's created as far as I'm aware.

I tried to explain what I was thinking with the suggested edits. Does that make sense?

clang/docs/CMakeLists.txt
93
99
107–124
123–126
126
136–137
aidengrossman marked 6 inline comments as done.

Adjust based on reviewer suggestions.

Thank you very much for your patience and writing everything out. That makes a lot more sense. The resulting code definitely has a lot more desirable properties. I've updated the diff in accordance with your suggestions.

tstellar accepted this revision.May 11 2023, 3:34 PM

LGTM.

This revision is now accepted and ready to land.May 11 2023, 3:34 PM
This revision was automatically updated to reflect the committed changes.