From 253616de7e8fa4f410e294867abe3ca4cbafdb79 Mon Sep 17 00:00:00 2001 From: Jeff Bailey Date: Wed, 18 Mar 2026 16:51:13 +0000 Subject: [PATCH] [libc][docs] Generate configure.rst in the build directory (#187266) generate_config_doc() was writing configure.rst directly into the source tree, which fails when building from a read-only source directory (e.g. when the source is on a read-only filesystem or in a packaging environment). The Sphinx build in libc/docs/CMakeLists.txt already copies static .rst files from the source tree into the build tree so that generated docs don't pollute the source directory. Move configure.rst generation to follow this same pattern by writing to LIBC_BUILD_DIR/docs/ instead of LIBC_SOURCE_DIR/docs/. This also removes configure.rst from the checked-in source tree, since it was fully generated content that was being regenerated on every CMake configure anyway. --- libc/CMakeLists.txt | 2 +- libc/cmake/modules/LibcConfig.cmake | 2 + libc/docs/configure.rst | 80 ----------------------------- 3 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 libc/docs/configure.rst diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 2d474f08841c..7a5ed88ef054 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -216,7 +216,7 @@ foreach(opt IN LISTS global_config) message(STATUS "${opt_name}: ${opt_value}") set(${opt_name} ${opt_value}) endforeach() -generate_config_doc(${main_config_file} ${LIBC_SOURCE_DIR}/docs/configure.rst) +generate_config_doc(${main_config_file} ${LIBC_BUILD_DIR}/docs/configure.rst) # Load each target specific config. foreach(config_path IN LISTS LIBC_CONFIG_JSON_FILE_LIST) diff --git a/libc/cmake/modules/LibcConfig.cmake b/libc/cmake/modules/LibcConfig.cmake index da166dd6cc3f..19bdf44d96bf 100644 --- a/libc/cmake/modules/LibcConfig.cmake +++ b/libc/cmake/modules/LibcConfig.cmake @@ -139,6 +139,8 @@ function(generate_config_doc config_file doc_file) if(NOT EXISTS ${config_file}) message(FATAL_ERROR "${config_file} does not exist") endif() + get_filename_component(doc_dir ${doc_file} DIRECTORY) + file(MAKE_DIRECTORY ${doc_dir}) file(READ ${config_file} json_config) string(JSON group_count ERROR_VARIABLE json_error LENGTH ${json_config}) if(json_error) diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst deleted file mode 100644 index 06d20df261bc..000000000000 --- a/libc/docs/configure.rst +++ /dev/null @@ -1,80 +0,0 @@ -.. _configure: -.. - Do not edit this file directly. CMake will auto generate it. - If the changes are intended, add this file to your commit. - -========================== -Configure Options -========================== - -Below is the full set of options one can use to configure the libc build. -An option can be given an explicit value on the CMake command line using -the following syntax: - -.. code-block:: sh - - $> cmake -D=