[cmake][docs] Fix incremental docs builds under deletion and renames (#211411)
Currently clang, flang, and libc all copy documentation from the source
tree into the build tree in preparation to build it, usually to create a
combined tree that includes generated documentation files, like
AttributeReference.md. However, renaming a document and rebuilding
without cleaning the docs tree leaves behind stale documentation files
that can accumulate.
This patch fixes the problem with two build actions:
1. List source documentation files. Always out of date, always
regenerates on every doc build, but it's very cheap.
2. Copy all source documents to the output, and delete any file that
neither originates from the source directory nor is mentioned as a
generated source to preserve.
These actions are implemented as CMake script files (`cmake -P`) since
they do things not covered by the builtin tools (`cmake -E
copy_if_different`). They could be simplified if we were willing to
tolerate more process launch overhead, but for something that runs on
the critical path to every doc rebuild, I decided it was worth spending
lines of CMake script on it.
Assisted-by: a coding tool
GitOrigin-RevId: 263280e39e6d968c9d610df8160dc49b4b62599f
1 file changed