[libc-commits] [libc] [libc][cmake] Indent hanging CMake lines by 4 spaces (PR #240832)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Tue Nov 10 05:56:28 PST 2026
https://github.com/kaladron updated https://github.com/llvm/llvm-project/pull/240832
>From ac885314501e6055fd984e965c625eba06d75a67 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Tue, 10 Nov 2026 13:16:12 +0000
Subject: [PATCH 1/2] [libc][cmake] Indent hanging CMake lines by 4 spaces
Indenting wrapped control-flow headers and header-line keyword lists by
2 spaces makes continuation lines visually indistinguishable from child
control blocks and sibling 2-space keyword sub-stanzas beneath them.
Updated cmake_format.py to indent wrapped control-flow headers and
header-line keyword items by 4 spaces when sibling keywords exist in
the command schema, while keeping positional arguments and
single-keyword property calls at 2 spaces. Corrected elseif base
indentation so wrapped conditions indent 4 spaces rather than 6, and
reformatted the libc CMake files.
Assisted-by: Automated tooling, human reviewed.
---
.../cmake/modules/LLVMLibCArchitectures.cmake | 2 +-
.../modules/LLVMLibCCompileOptionRules.cmake | 6 +-
libc/cmake/modules/LLVMLibCFlagRules.cmake | 4 +-
libc/cmake/modules/LLVMLibCLibraryRules.cmake | 2 +-
libc/cmake/modules/LLVMLibCTestRules.cmake | 18 +--
libc/cmake/modules/LibcParseArguments.cmake | 16 +--
.../modules/prepare_libc_gpu_build.cmake | 4 +-
libc/lib/CMakeLists.txt | 2 +-
libc/src/__support/File/CMakeLists.txt | 2 +-
libc/src/__support/time/CMakeLists.txt | 2 +-
libc/src/grp/CMakeLists.txt | 2 +-
libc/src/stdio/generic/CMakeLists.txt | 10 +-
libc/src/stdlib/CMakeLists.txt | 4 +-
libc/test/CMakeLists.txt | 2 +-
.../src/__support/threads/CMakeLists.txt | 2 +-
libc/test/src/__support/CMakeLists.txt | 2 +-
libc/test/src/fenv/CMakeLists.txt | 2 +-
libc/test/src/mathvec/CMakeLists.txt | 2 +-
libc/test/src/stdio/CMakeLists.txt | 2 +-
libc/test/src/stdio/scanf_core/CMakeLists.txt | 2 +-
libc/test/src/stdlib/CMakeLists.txt | 4 +-
.../src/string/memory_utils/CMakeLists.txt | 6 +-
libc/test/src/sys/prctl/linux/CMakeLists.txt | 4 +-
libc/test/utils/FPUtil/CMakeLists.txt | 2 +-
libc/utils/MPCWrapper/CMakeLists.txt | 6 +-
libc/utils/MPFRWrapper/CMakeLists.txt | 10 +-
libc/utils/cmake_format.py | 49 ++++---
libc/utils/cmake_format_test.py | 125 +++++++++++++++++-
28 files changed, 218 insertions(+), 76 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index e65ddff98269ef..57351cf4442bff 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -234,7 +234,7 @@ endif()
# if the compiler is clang. If the compiler is GCC we just error out as there
# is no equivalent of an option like --target.
if(explicit_target_triple AND
- (NOT (libc_compiler_triple STREQUAL explicit_target_triple)))
+ (NOT (libc_compiler_triple STREQUAL explicit_target_triple)))
set(LIBC_CROSSBUILD TRUE)
if(CMAKE_COMPILER_IS_GNUCXX)
message(FATAL_ERROR
diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index f4b9d29d27faec..b345add27f050d 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -87,7 +87,7 @@ function(_get_compile_options_from_flags output_var)
list(APPEND compile_options "-D__LIBC_USE_BUILTIN_FMAXF16_FMINF16")
endif()
if("FullFP16" IN_LIST LIBC_CPU_FEATURES AND
- CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
list(APPEND compile_options
"SHELL:-Xclang -target-feature -Xclang +fullfp16")
endif()
@@ -250,7 +250,7 @@ function(_get_common_compile_options_impl output_var)
# -ffreestanding, which in turn includes <stdlib.h>. Suppress it by
# defining its header guard.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
- (LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR LIBC_TARGET_ARCHITECTURE_IS_X86))
+ (LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR LIBC_TARGET_ARCHITECTURE_IS_X86))
list(APPEND compile_options "-D_MM_MALLOC_H_INCLUDED")
endif()
endif()
@@ -266,7 +266,7 @@ function(_get_common_compile_options_impl output_var)
endif()
# TODO: We should set this unconditionally on Linux.
if(LIBC_TARGET_OS_IS_LINUX AND
- (LIBC_CC_SUPPORTS_NOSTDLIBINC OR COMPILER_RESOURCE_DIR))
+ (LIBC_CC_SUPPORTS_NOSTDLIBINC OR COMPILER_RESOURCE_DIR))
# We use -idirafter to avoid preempting libc's own headers in case the
# directory (e.g. /usr/include) contains other headers.
foreach(path IN LISTS LIBC_KERNEL_HEADERS)
diff --git a/libc/cmake/modules/LLVMLibCFlagRules.cmake b/libc/cmake/modules/LLVMLibCFlagRules.cmake
index c658c077372eca..7a7a2a148d35ee 100644
--- a/libc/cmake/modules/LLVMLibCFlagRules.cmake
+++ b/libc/cmake/modules/LLVMLibCFlagRules.cmake
@@ -285,7 +285,7 @@ set(MISC_MATH_BASIC_OPS_OPT_FLAG "MISC_MATH_BASIC_OPS_OPT")
# Skip FMA_OPT flag for targets that don't support fma.
if(NOT DEFINED SKIP_FLAG_EXPANSION_FMA_OPT)
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86_64 AND (LIBC_CPU_FEATURES MATCHES "FMA")) OR
- LIBC_TARGET_ARCHITECTURE_IS_ANY_RISCV))
+ LIBC_TARGET_ARCHITECTURE_IS_ANY_RISCV))
set(SKIP_FLAG_EXPANSION_FMA_OPT TRUE)
endif()
endif()
@@ -303,7 +303,7 @@ endif()
# SSE4.2 support.
if(NOT DEFINED SKIP_FLAG_EXPANSION_ROUND_OPT)
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86_64 AND (LIBC_CPU_FEATURES MATCHES "SSE4_2")) OR
- LIBC_TARGET_ARCHITECTURE_IS_AARCH64 OR LIBC_TARGET_OS_IS_GPU))
+ LIBC_TARGET_ARCHITECTURE_IS_AARCH64 OR LIBC_TARGET_OS_IS_GPU))
set(SKIP_FLAG_EXPANSION_ROUND_OPT TRUE)
endif()
endif()
diff --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
index cdff1b907214bb..59fa869d472ef8 100644
--- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -54,7 +54,7 @@ function(get_all_object_file_deps result fq_deps_list)
foreach(dep ${fq_deps_list})
get_target_property(dep_type ${dep} "TARGET_TYPE")
if(NOT ((${dep_type} STREQUAL ${ENTRYPOINT_OBJ_TARGET_TYPE}) OR
- (${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE})))
+ (${dep_type} STREQUAL ${ENTRYPOINT_EXT_TARGET_TYPE})))
message(FATAL_ERROR "Dependency '${dep}' of 'add_entrypoint_collection' is "
"not an 'add_entrypoint_object' or 'add_entrypoint_external' target.")
endif()
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 09cf51a0b4ffc1..8300f19742f15c 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -64,7 +64,7 @@ function(_get_common_test_compile_options_impl output_var c_test)
# Only add -ffreestanding flag in full build mode.
list(APPEND compile_options "-ffreestanding")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
- (LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR LIBC_TARGET_ARCHITECTURE_IS_X86))
+ (LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR LIBC_TARGET_ARCHITECTURE_IS_X86))
list(APPEND compile_options "-D_MM_MALLOC_H_INCLUDED")
endif()
list(APPEND compile_options "-fno-exceptions")
@@ -312,8 +312,8 @@ function(get_object_files_for_test result skipped_entrypoints_list)
# object. External baremetal startup code can reference the public C exit
# symbol, so use the public-packaging object for exit in this configuration.
if(dep STREQUAL "libc.src.stdlib.exit" AND
- NOT LLVM_LIBC_HERMETIC_TEST_USE_INTERNAL_STARTUP AND
- LIBC_TARGET_OS_IS_BAREMETAL)
+ NOT LLVM_LIBC_HERMETIC_TEST_USE_INTERNAL_STARTUP AND
+ LIBC_TARGET_OS_IS_BAREMETAL)
string(REPLACE ".__internal__" "" object_file_raw ${object_file_raw})
endif()
list(APPEND dep_obj ${object_file_raw})
@@ -354,8 +354,8 @@ endif()
# that the driver selects the same multilib. GPU and UEFI targets do not link a
# compiler runtime.
if(LLVM_INCLUDE_TESTS AND LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU AND
- NOT LIBC_TARGET_OS_IS_UEFI AND
- NOT LIBC_TEST_BUILTINS_LIBRARY AND NOT LIBC_TEST_BUILTINS_TARGET)
+ NOT LIBC_TARGET_OS_IS_UEFI AND
+ NOT LIBC_TEST_BUILTINS_LIBRARY AND NOT LIBC_TEST_BUILTINS_TARGET)
separate_arguments(libc_cxx_flags NATIVE_COMMAND "${CMAKE_CXX_FLAGS}")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} ${libc_cxx_flags}
@@ -572,8 +572,8 @@ function(_link_libc_hermetic_test fq_target_name fq_build_target_name startup_ta
set(compiler_runtime "")
if(NOT LIBC_TARGET_ARCHITECTURE_IS_AMDGPU AND
- NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX AND
- NOT LIBC_CC_SUPPORTS_NOSTDLIBPP)
+ NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX AND
+ NOT LIBC_CC_SUPPORTS_NOSTDLIBPP)
list(APPEND compiler_runtime ${LIBGCC_S_LOCATION})
endif()
@@ -942,8 +942,8 @@ function(add_libc_fuzzer target_name)
target_include_directories(${fq_target_name} PRIVATE ${LIBC_SOURCE_DIR})
target_link_libraries(${fq_target_name} PRIVATE
- ${link_object_files}
- ${link_libraries}
+ ${link_object_files}
+ ${link_libraries}
)
set_target_properties(${fq_target_name}
diff --git a/libc/cmake/modules/LibcParseArguments.cmake b/libc/cmake/modules/LibcParseArguments.cmake
index f564865f4de5e8..5002657b6cd6c2 100644
--- a/libc/cmake/modules/LibcParseArguments.cmake
+++ b/libc/cmake/modules/LibcParseArguments.cmake
@@ -179,14 +179,14 @@ function(llvm_libc_parse_arguments name_prefix)
endforeach()
foreach(argument
- IN LISTS
- LLVM_LIBC_COMMON_OPTIONAL_ARGS
- LLVM_LIBC_OPTIONAL_ARGS
- LLVM_LIBC_SINGLE_VALUE_ARGS
- LLVM_LIBC_MULTI_VALUE_ARGS
- ITEMS
- UNPARSED_ARGUMENTS
- KEYWORDS_MISSING_VALUES
+ IN LISTS
+ LLVM_LIBC_COMMON_OPTIONAL_ARGS
+ LLVM_LIBC_OPTIONAL_ARGS
+ LLVM_LIBC_SINGLE_VALUE_ARGS
+ LLVM_LIBC_MULTI_VALUE_ARGS
+ ITEMS
+ UNPARSED_ARGUMENTS
+ KEYWORDS_MISSING_VALUES
)
set(${name_prefix}_${argument} "${ARG_${argument}}" PARENT_SCOPE)
endforeach()
diff --git a/libc/cmake/modules/prepare_libc_gpu_build.cmake b/libc/cmake/modules/prepare_libc_gpu_build.cmake
index 3bfa98b1dcba7a..c1e10418f06064 100644
--- a/libc/cmake/modules/prepare_libc_gpu_build.cmake
+++ b/libc/cmake/modules/prepare_libc_gpu_build.cmake
@@ -6,7 +6,7 @@ endif()
# Ensure the compiler is a valid clang when building the GPU target.
set(req_ver "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
if(LLVM_VERSION_MAJOR AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND
- ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${req_ver}"))
+ ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${req_ver}"))
message(WARNING "libc for GPU requires an up-to-date clang. CMake compiler "
"'${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' "
" is not 'Clang ${req_ver}'.")
@@ -43,7 +43,7 @@ endif()
set(gpu_test_architecture "")
if(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_AMDGPU
- AND NOT "AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
+ AND NOT "AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD)
set(LIBC_GPU_TESTS_DISABLED TRUE)
message(STATUS "AMDGPU backend is not available, tests will not be built")
elseif(DEFINED LLVM_TARGETS_TO_BUILD AND LIBC_TARGET_ARCHITECTURE_IS_NVPTX
diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index aa0b35e65a1a0b..b7947cace695e6 100644
--- a/libc/lib/CMakeLists.txt
+++ b/libc/lib/CMakeLists.txt
@@ -37,7 +37,7 @@ endif()
set(added_archive_targets "")
set(added_bitcode_targets "")
foreach(archive IN ZIP_LISTS
- libc_archive_names libc_archive_targets libc_archive_entrypoint_lists)
+ libc_archive_names libc_archive_targets libc_archive_entrypoint_lists)
if(NOT ${archive_2})
# If an entrypoint list is missing, then skip adding targets for it.
continue()
diff --git a/libc/src/__support/File/CMakeLists.txt b/libc/src/__support/File/CMakeLists.txt
index 691ada0fc99586..c65e5b7ee23dc5 100644
--- a/libc/src/__support/File/CMakeLists.txt
+++ b/libc/src/__support/File/CMakeLists.txt
@@ -5,7 +5,7 @@ add_header_library(
)
if(NOT (TARGET libc.src.__support.threads.mutex)
- OR LIBC_TARGET_OS_IS_GPU)
+ OR LIBC_TARGET_OS_IS_GPU)
# Not all platforms have a mutex implementation. If mutex is unvailable,
# we just skip everything about files.
return()
diff --git a/libc/src/__support/time/CMakeLists.txt b/libc/src/__support/time/CMakeLists.txt
index 00d7dba572fc7c..7cc1d1888ea5fe 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -8,7 +8,7 @@ add_header_library(
)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}
- AND TARGET libc.src.__support.OSUtil.osutil)
+ AND TARGET libc.src.__support.OSUtil.osutil)
add_subdirectory(${LIBC_TARGET_OS})
else()
message(STATUS "Skip libc.src.__support.time.* targets.")
diff --git a/libc/src/grp/CMakeLists.txt b/libc/src/grp/CMakeLists.txt
index d0c5b47d71eee1..398509182bae9c 100644
--- a/libc/src/grp/CMakeLists.txt
+++ b/libc/src/grp/CMakeLists.txt
@@ -1,5 +1,5 @@
if(NOT TARGET libc.src.__support.File.file OR
- NOT TARGET libc.src.__support.File.platform_file)
+ NOT TARGET libc.src.__support.File.platform_file)
return()
endif()
diff --git a/libc/src/stdio/generic/CMakeLists.txt b/libc/src/stdio/generic/CMakeLists.txt
index 58a0cefcf9356d..e05a9e1bd9be78 100644
--- a/libc/src/stdio/generic/CMakeLists.txt
+++ b/libc/src/stdio/generic/CMakeLists.txt
@@ -96,11 +96,11 @@ add_generic_entrypoint_object(
# since this isn't an entrypoint we need to do these checks manually.
if(NOT TARGET libc.src.stdio.${LIBC_TARGET_OS}.fflush_internal AND
- TARGET libc.src.__support.File.file AND
- TARGET libc.src.__support.File.platform_file AND
- "libc.src.stdio.stdin" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS AND
- "libc.src.stdio.stdout" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS AND
- "libc.src.stdio.stderr" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
+ TARGET libc.src.__support.File.file AND
+ TARGET libc.src.__support.File.platform_file AND
+ "libc.src.stdio.stdin" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS AND
+ "libc.src.stdio.stdout" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS AND
+ "libc.src.stdio.stderr" IN_LIST TARGET_LLVMLIBC_ENTRYPOINTS)
add_object_library(
fflush_internal
SRCS
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index a40e6bfa4d2c51..98e356244e87a5 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -81,8 +81,8 @@ add_entrypoint_object(
# GCC-12 crashed when building environ_internal during GIMPLE pass: waccess.
set(environ_internal_gcc12_workaround "")
if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND
- (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12") AND
- (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13"))
+ (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12") AND
+ (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13"))
set(environ_internal_gcc12_workaround "-Wno-stringop-overflow"
"-fdisable-tree-waccess1" "-fdisable-tree-waccess2"
"-fdisable-tree-waccess3")
diff --git a/libc/test/CMakeLists.txt b/libc/test/CMakeLists.txt
index ae9cd0e4b028f8..1342acfe68d683 100644
--- a/libc/test/CMakeLists.txt
+++ b/libc/test/CMakeLists.txt
@@ -52,7 +52,7 @@ endif()
add_subdirectory(include)
if(NOT ${LIBC_TARGET_OS} STREQUAL "linux" AND
- NOT ${LIBC_TARGET_OS} STREQUAL "gpu")
+ NOT ${LIBC_TARGET_OS} STREQUAL "gpu")
# Integration tests are currently only available for linux and the GPU.
return()
endif()
diff --git a/libc/test/integration/src/__support/threads/CMakeLists.txt b/libc/test/integration/src/__support/threads/CMakeLists.txt
index de5738c23c06e7..f4da964c4f7401 100644
--- a/libc/test/integration/src/__support/threads/CMakeLists.txt
+++ b/libc/test/integration/src/__support/threads/CMakeLists.txt
@@ -1,5 +1,5 @@
if(NOT (TARGET libc.src.__support.threads.thread AND
- TARGET libc.src.__support.threads.mutex))
+ TARGET libc.src.__support.threads.mutex))
return()
endif()
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index e4620f1c04d58f..ca2ea8eb799d83 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -312,7 +312,7 @@ add_libc_test(
)
if(LIBC_TARGET_OS_IS_BAREMETAL AND
- NOT LLVM_LIBC_HERMETIC_TEST_USE_INTERNAL_STARTUP)
+ NOT LLVM_LIBC_HERMETIC_TEST_USE_INTERNAL_STARTUP)
add_object_library(
minimal_external_crt1_for_test
SRCS
diff --git a/libc/test/src/fenv/CMakeLists.txt b/libc/test/src/fenv/CMakeLists.txt
index 911e162aa613ae..b944b4c510332c 100644
--- a/libc/test/src/fenv/CMakeLists.txt
+++ b/libc/test/src/fenv/CMakeLists.txt
@@ -96,7 +96,7 @@ add_libc_test(
)
if(NOT (LLVM_USE_SANITIZER OR (${LIBC_TARGET_OS} STREQUAL "windows")
- OR (${LIBC_TARGET_OS} STREQUAL "darwin")))
+ OR (${LIBC_TARGET_OS} STREQUAL "darwin")))
# Sanitizers don't like SIGFPE. So, we will run the
# tests which raise SIGFPE only in non-sanitizer builds.
# The tests are also disabled for Windows and MacOS as they fail currently.
diff --git a/libc/test/src/mathvec/CMakeLists.txt b/libc/test/src/mathvec/CMakeLists.txt
index 3a41ab0da9759f..6283304a0a3286 100644
--- a/libc/test/src/mathvec/CMakeLists.txt
+++ b/libc/test/src/mathvec/CMakeLists.txt
@@ -421,7 +421,7 @@ add_fp_unittest(
)
if(NOT LIBC_CONF_MATH_OPTIMIZATIONS MATCHES
- "LIBC_MATH_INTERMEDIATE_COMP_IN_FLOAT")
+ "LIBC_MATH_INTERMEDIATE_COMP_IN_FLOAT")
add_fp_unittest(
sinf_test
SUITE
diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt
index e20395737b2d1e..23acf2537a175f 100644
--- a/libc/test/src/stdio/CMakeLists.txt
+++ b/libc/test/src/stdio/CMakeLists.txt
@@ -200,7 +200,7 @@ if(LIBC_CONF_PRINTF_DISABLE_FLOAT)
libc_add_definition(sprintf_test_copts "LIBC_COPT_PRINTF_DISABLE_FLOAT")
endif()
if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_DYADIC_FLOAT OR
- LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320)
+ LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320)
libc_add_definition(sprintf_test_copts "LIBC_COPT_FLOAT_TO_STR_REDUCED_PRECISION")
endif()
if(LIBC_CONF_PRINTF_DISABLE_INDEX_MODE)
diff --git a/libc/test/src/stdio/scanf_core/CMakeLists.txt b/libc/test/src/stdio/scanf_core/CMakeLists.txt
index 46e99ffe56fe0d..72330662149a41 100644
--- a/libc/test/src/stdio/scanf_core/CMakeLists.txt
+++ b/libc/test/src/stdio/scanf_core/CMakeLists.txt
@@ -18,7 +18,7 @@ add_libc_test(
)
if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD AND
- (NOT LIBC_TARGET_OS_IS_GPU))
+ (NOT LIBC_TARGET_OS_IS_GPU))
# Not all platforms have a file implementation. If file is unvailable, and a
# full build is requested, then we must skip all file based scanf sections.
return()
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index a208ac4cdec41f..5e054cb430db31 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -169,7 +169,7 @@ add_libc_test(
)
if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_DYADIC_FLOAT OR
- LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320)
+ LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_FLOAT320)
libc_set_definition(strfrom_test_copts "LIBC_COPT_FLOAT_TO_STR_REDUCED_PRECISION")
endif()
@@ -677,7 +677,7 @@ endif()
# Only baremetal and GPU has an in-tree 'malloc' implementation.
if((LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU) AND
- NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
+ NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
add_libc_test(
malloc_test
SUITE
diff --git a/libc/test/src/string/memory_utils/CMakeLists.txt b/libc/test/src/string/memory_utils/CMakeLists.txt
index 0b94cd22df1aca..2dcb86a1f3dd48 100644
--- a/libc/test/src/string/memory_utils/CMakeLists.txt
+++ b/libc/test/src/string/memory_utils/CMakeLists.txt
@@ -1,8 +1,8 @@
# Targets with implemented src/string/memory_utils/op_XXX.h specializations.
if(LIBC_TARGET_ARCHITECTURE_IS_AARCH64 OR
- LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR
- LIBC_TARGET_ARCHITECTURE_IS_X86 OR
- LIBC_TARGET_ARCHITECTURE_IS_ANY_RISCV)
+ LIBC_TARGET_ARCHITECTURE_IS_X86_64 OR
+ LIBC_TARGET_ARCHITECTURE_IS_X86 OR
+ LIBC_TARGET_ARCHITECTURE_IS_ANY_RISCV)
add_libc_test(
utils_test
SUITE
diff --git a/libc/test/src/sys/prctl/linux/CMakeLists.txt b/libc/test/src/sys/prctl/linux/CMakeLists.txt
index 01e8c1a712ad4f..b08f02bb3864c5 100644
--- a/libc/test/src/sys/prctl/linux/CMakeLists.txt
+++ b/libc/test/src/sys/prctl/linux/CMakeLists.txt
@@ -3,8 +3,8 @@ add_libc_testsuite(libc-sys-prctl-tests)
# Temporarily disable this test while setting up arm and riscv buildbots
# using qemu, since PR_GET_THP_DISABLE is not supported on qemu.
if(NOT (LIBC_TARGET_ARCHITECTURE_IS_ARM OR
- LIBC_TARGET_ARCHITECTURE_IS_RISCV32 OR
- LIBC_TARGET_ARCHITECTURE_IS_RISCV64))
+ LIBC_TARGET_ARCHITECTURE_IS_RISCV32 OR
+ LIBC_TARGET_ARCHITECTURE_IS_RISCV64))
add_libc_test(
prctl_test
SUITE
diff --git a/libc/test/utils/FPUtil/CMakeLists.txt b/libc/test/utils/FPUtil/CMakeLists.txt
index e76f8ff783c867..dbd2270a7754af 100644
--- a/libc/test/utils/FPUtil/CMakeLists.txt
+++ b/libc/test/utils/FPUtil/CMakeLists.txt
@@ -1,5 +1,5 @@
if((${LIBC_TARGET_OS} STREQUAL "linux") AND ((${LIBC_TARGET_ARCHITECTURE_IS_X86})
- OR (${LIBC_TARGET_ARCHITECTURE_IS_X86_64})))
+ OR (${LIBC_TARGET_ARCHITECTURE_IS_X86_64})))
add_libc_test(
x86_long_double_test
SUITE
diff --git a/libc/utils/MPCWrapper/CMakeLists.txt b/libc/utils/MPCWrapper/CMakeLists.txt
index c982f2232088a3..fbb98dba2c1f97 100644
--- a/libc/utils/MPCWrapper/CMakeLists.txt
+++ b/libc/utils/MPCWrapper/CMakeLists.txt
@@ -1,8 +1,8 @@
if(LIBC_TESTS_CAN_USE_MPC)
add_library(libc.utils.MPCWrapper STATIC
- MPCUtils.cpp
- MPCUtils.h
- mpc_inc.h
+ MPCUtils.cpp
+ MPCUtils.h
+ mpc_inc.h
)
_get_common_test_compile_options(compile_options "" "")
list(REMOVE_ITEM compile_options "-ffreestanding")
diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt
index fe241c72d89c82..3c301180882a8e 100644
--- a/libc/utils/MPFRWrapper/CMakeLists.txt
+++ b/libc/utils/MPFRWrapper/CMakeLists.txt
@@ -1,8 +1,8 @@
if(LIBC_TESTS_CAN_USE_MPFR OR LIBC_TESTS_CAN_USE_MPC)
add_library(libc.utils.MPCommon STATIC
- MPCommon.cpp
- MPCommon.h
- mpfr_inc.h
+ MPCommon.cpp
+ MPCommon.h
+ mpfr_inc.h
)
_get_common_test_compile_options(compile_options "" "")
# mpfr/gmp headers do not work with -ffreestanding flag.
@@ -35,8 +35,8 @@ endif()
if(LIBC_TESTS_CAN_USE_MPFR)
add_library(libc.utils.MPFRWrapper STATIC
- MPFRUtils.cpp
- MPFRUtils.h
+ MPFRUtils.cpp
+ MPFRUtils.h
)
_get_common_test_compile_options(compile_options "" "")
# mpfr/gmp headers do not work with -ffreestanding flag.
diff --git a/libc/utils/cmake_format.py b/libc/utils/cmake_format.py
index 82129982f660a8..57a422ecf20a68 100755
--- a/libc/utils/cmake_format.py
+++ b/libc/utils/cmake_format.py
@@ -33,7 +33,7 @@
2. Single-Value Keywords (1 value): e.g. `RESULT_VARIABLE`, `OUTPUT_VARIABLE`, `TARGET`, `WORKING_DIRECTORY`, `ALIAS`, `SUITE`, `CACHE`, `DEPFILE`.
- After value is consumed, keyword closes and subsequent keywords/values align at top-level keyword indent (+2 spaces).
3. Multi-Value List Keywords (1+ values): e.g. `SRCS`, `HDRS`, `DEPENDS`, `FULL_BUILD_DEPENDS`, `COMPILE_OPTIONS`, `LINK_LIBRARIES`, `LOADER_ARGS`, `ARGS`, `ENV`, `PROPERTIES`, `OBJECT`, `STATIC`, `SHARED`, `MODULE`.
- - Keywords on the command header line (`cmd(KEYWORD...`) do NOT grant extra nesting to child lines (+2 spaces relative to call base).
+ - Keywords on the command header line (`cmd(KEYWORD...` or `cmd(arg KEYWORD...`) indent continuation items +4 spaces when sibling keywords can follow (so subsequent `+2` keywords don't collide), or +2 spaces when no remaining keywords exist (e.g. `set_target_properties(t PROPERTIES ...)`).
- Keywords on their own separate line (`\n KEYWORD...`) indent child list items +4 spaces (+2 relative to keyword line).
4. Dynamic Schema Learning:
- Automatically parses `cmake_parse_arguments(...)` calls in `function(...)` / `macro(...)` AST blocks.
@@ -45,7 +45,7 @@
3. Quoted String Immutability: Quoted arguments (`"..."`) and bracket arguments (`[=[...]=]`) are single immutable AST tokens. Multi-line quoted strings are preserved 100% untouched.
4. Empty Closures: `endif()`, `else()`, `endfunction()`, `endmacro()`, `endforeach()`, `endwhile()`. (Legacy CMake permitted repeating condition/block names in closing commands; modern CMake standardizes on empty parentheses).
5. Schema-Aware Keyword Casing: Keywords in command schema upper-cased; positional args, function parameters & file paths untouched.
- 6. Multi-line Argument Layout: Keywords and positional args indented +2 spaces relative to call base; multi-value list items indented +4 spaces; closing `)` at +0 spaces.
+ 6. Multi-line Argument Layout: Keywords and positional args indented +2 spaces relative to call base; multi-value list items indented +4 spaces (except header-line keywords with no sibling keywords, which indent +2 spaces); multi-line control-flow headers (`if`, `elseif`, `foreach`, `while`, `function`, `macro`) starting args on the opening `cmd(` line indent hanging lines +4 spaces; closing `)` at +0 spaces.
7. Control Block Indentation: 2-space indentation inside `if`/`foreach`/`function`/`macro`.
8. Comment Formatting: Line comments buffer and align with the indentation level of the code element immediately following them, unless separated by a blank line (standalone comments) or immediately preceding a closing parenthesis `)`.
9. Cleanliness: Trailing whitespace and leading blank lines stripped, consecutive blank lines collapsed to a single blank line, single trailing newline for non-empty files; empty files preserved 0-byte.
@@ -109,9 +109,11 @@ def __init__(self, msg: str, line: int, col: int) -> None:
INDENT_STR = " " * INDENT_WIDTH
# Indent levels relative to a command's base_indent:
# +1 level = keyword line or positional arg line (+2 spaces)
-# +2 levels = multi-value list item under a keyword on its own line (+4 spaces)
+# +2 levels = multi-value list item (+4 spaces)
+# +2 levels = hanging line in a control-flow header starting on the cmd( line (+4 spaces)
KEYWORD_INDENT_LEVELS = 1
LIST_ITEM_INDENT_LEVELS = 2
+HANGING_INDENT_LEVELS = 2
@dataclass
@@ -922,8 +924,10 @@ class CallState:
schema: Resolved CommandSchema providing options/one_value/multi_value sets.
active_kw: The currently open keyword (None if no keyword is active).
active_kw_type: ONE_VALUE, MULTI_VALUE, or None — governs indent of child lines.
- active_kw_on_cmd_line: True if active_kw was opened on the command line itself,
- which suppresses extra nesting for its child list items.
+ active_kw_on_cmd_line: True if active_kw was opened on the command line itself.
+ can_have_substanzas: True if unused sibling keywords exist in the command's schema
+ (excluding ``set``), allowing header-opened keywords to indent child items +4.
+ seen_keywords: Uppercased keywords matched while processing tokens.
one_value_count: Number of values consumed under the current ONE_VALUE keyword;
the keyword closes after the first value is seen.
"""
@@ -937,6 +941,8 @@ class CallState:
active_kw: str | None = None
active_kw_type: KeywordType | None = None
active_kw_on_cmd_line: bool = False
+ can_have_substanzas: bool = False
+ seen_keywords: set[str] = field(default_factory=set)
one_value_count: int = 0
last_line_was_keyword: bool = False
in_call: bool = True
@@ -988,6 +994,7 @@ def process_tokens(self, tokens: list[Token], is_cmd_line: bool = False) -> str:
self.reset_kw()
elif self.is_keyword_token(clean_word):
kw = clean_word.upper()
+ self.seen_keywords.add(kw)
formatted_tok = tok.value.replace(clean_word, kw, 1)
reconstructed_parts.append(formatted_tok)
if kw in self.schema.options:
@@ -1106,6 +1113,8 @@ def _process_call_continuation_line(
# Determine whether the first meaningful token on this line is a keyword or
# an argument-forwarding variable (${ARGN} etc.), as both affect indentation.
+ # Control-flow header continuations (if/elseif/foreach/while/function/macro)
+ # treat wrapped conditions/clauses as hanging lines rather than sub-stanzas.
first_unquoted: str | None = None
for tok in trimmed_line_toks:
if tok.type in (
@@ -1116,9 +1125,10 @@ def _process_call_continuation_line(
first_unquoted = tok.value
break
+ is_control_header = cs.cmd_name in (CONTROL_START_BLOCKS | CONTROL_MIDDLE_BLOCKS)
line_starts_new_keyword = False
is_arg_var_line = False
- if first_unquoted:
+ if first_unquoted and not is_control_header:
clean_first = first_unquoted.rstrip("),;").lstrip("(")
if RE_ARG_FORWARDING_VAR.match(clean_first):
is_arg_var_line = True
@@ -1128,10 +1138,12 @@ def _process_call_continuation_line(
cs.last_line_was_keyword = line_starts_new_keyword
# Compute indentation level for this continuation line.
- if line_starts_new_keyword or is_arg_var_line:
+ if is_control_header and not cs.first_arg_on_separate_line:
+ indent_str = INDENT_STR * (cs.base_indent + HANGING_INDENT_LEVELS)
+ elif line_starts_new_keyword or is_arg_var_line:
indent_str = INDENT_STR * (cs.base_indent + KEYWORD_INDENT_LEVELS)
elif cs.active_kw is not None:
- if cs.active_kw_on_cmd_line:
+ if cs.active_kw_on_cmd_line and not cs.can_have_substanzas:
indent_str = INDENT_STR * (cs.base_indent + KEYWORD_INDENT_LEVELS)
else:
indent_str = INDENT_STR * (cs.base_indent + LIST_ITEM_INDENT_LEVELS)
@@ -1206,14 +1218,15 @@ def _process_command_invocation_line(
line_paren_balance = 1 + lparens - rparens
is_single_line = line_paren_balance <= 0
- # Compute indent for this line, adjusting block level for end/middle commands.
+ # Compute base indent for this command, adjusting block level for end/middle commands.
if lower_cmd.startswith("end"):
state.block_indent_level = max(0, state.block_indent_level - 1)
- indent_str = INDENT_STR * state.block_indent_level
+ call_base_indent = state.block_indent_level
elif lower_cmd in CONTROL_MIDDLE_BLOCKS:
- indent_str = INDENT_STR * max(0, state.block_indent_level - 1)
+ call_base_indent = max(0, state.block_indent_level - 1)
else:
- indent_str = INDENT_STR * state.block_indent_level
+ call_base_indent = state.block_indent_level
+ indent_str = INDENT_STR * call_base_indent
cmd_schema = get_schema_for_cmd(lower_cmd, ctx=file_ctx)
rest_arg_count = sum(
@@ -1232,9 +1245,12 @@ def _process_command_invocation_line(
state.formatted_lines.append(reconstructed)
if not is_single_line:
+ can_have_substanzas = lower_cmd != "set" and bool(
+ cmd_schema.all_keywords - temp_state.seen_keywords
+ )
state.current_call_state = CallState(
cmd_name=lower_cmd,
- base_indent=state.block_indent_level,
+ base_indent=call_base_indent,
paren_balance=line_paren_balance,
schema=cmd_schema,
arg_count=rest_arg_count,
@@ -1242,6 +1258,8 @@ def _process_command_invocation_line(
active_kw=temp_state.active_kw,
active_kw_type=temp_state.active_kw_type,
active_kw_on_cmd_line=temp_state.active_kw_on_cmd_line,
+ can_have_substanzas=can_have_substanzas,
+ seen_keywords=temp_state.seen_keywords,
one_value_count=temp_state.one_value_count,
)
@@ -1253,8 +1271,9 @@ def format_cmake_content(content: str, ctx: FormatterContext | None = None) -> s
"""Formats CMake file content using AST token-stream parser.
Applies lowercasing for built-in commands, proper indent nesting for control blocks,
- schema-aware keyword upper-casing, multi-line argument indentation (+2 / +4 spaces),
- and lookahead comment buffering alignment.
+ schema-aware keyword upper-casing, multi-line argument indentation (+2 / +4 spaces,
+ with +4 hanging indent for wrapped control-flow headers and header-line keywords
+ when sibling keywords exist), and lookahead comment buffering alignment.
The function dispatches each source line to one of five handlers:
1. Empty line — flush buffered comments and emit at most one blank line.
diff --git a/libc/utils/cmake_format_test.py b/libc/utils/cmake_format_test.py
index 93eee15368b789..013cedd8ca33a5 100644
--- a/libc/utils/cmake_format_test.py
+++ b/libc/utils/cmake_format_test.py
@@ -131,11 +131,52 @@ def test_6_3a_multivalue_separate_line(self):
self.assertEqual(cmake_format.format_cmake_content(code), expected)
def test_6_3b_multivalue_header_line(self):
- """Rule 6.3b: Multi-value keyword on header line indents items +2 spaces relative to call base."""
+ """Rule 6.3b: Header-line keywords indent +4 when sibling keywords exist, else +2."""
code = "add_entrypoint_object(target SRCS s1.cpp s2.cpp)\n"
expected = "add_entrypoint_object(target SRCS s1.cpp s2.cpp)\n"
self.assertEqual(cmake_format.format_cmake_content(code), expected)
+ builtin_code = "add_library(target STATIC\n s1.c\n PRIVATE\n dep1\n)\n"
+ builtin_expected = (
+ "add_library(target STATIC\n s1.c\n PRIVATE\n dep1\n)\n"
+ )
+ self.assertEqual(
+ cmake_format.format_cmake_content(builtin_code), builtin_expected
+ )
+
+ ctx = cmake_format.FormatterContext()
+ cmake_format.scan_dynamic_schemas(
+ 'function(add_entrypoint_object name)\n'
+ ' cmake_parse_arguments("ARG" "ALIAS" "" "SRCS;DEPENDS" ${ARGN})\n'
+ 'endfunction()\n',
+ ctx=ctx,
+ )
+ sibling_code = (
+ "add_entrypoint_object(target SRCS\n s1.cpp\n DEPENDS\n dep1\n)\n"
+ )
+ sibling_expected = (
+ "add_entrypoint_object(target SRCS\n s1.cpp\n DEPENDS\n dep1\n)\n"
+ )
+ self.assertEqual(
+ cmake_format.format_cmake_content(sibling_code, ctx=ctx), sibling_expected
+ )
+
+ # Single-keyword command with header-line keyword stays at +2.
+ single_kw_code = "set_target_properties(tgt PROPERTIES\n PROP val\n)\n"
+ single_kw_expected = "set_target_properties(tgt PROPERTIES\n PROP val\n)\n"
+ self.assertEqual(
+ cmake_format.format_cmake_content(single_kw_code), single_kw_expected
+ )
+
+ # Standalone PROPERTIES line still indents child items +4 (+2 under PROPERTIES).
+ separate_kw_code = "set_target_properties(tgt\n PROPERTIES\n PROP val\n)\n"
+ separate_kw_expected = (
+ "set_target_properties(tgt\n PROPERTIES\n PROP val\n)\n"
+ )
+ self.assertEqual(
+ cmake_format.format_cmake_content(separate_kw_code), separate_kw_expected
+ )
+
def test_6_4_argument_forwarding_vars(self):
"""Rule 6.4: Argument forwarding variables (${ARGN}, ${ARGV}) align at +2 spaces and reset active keyword."""
code = "add_entrypoint_object(\n target\n DEPENDS\n dep1\n ${ARGN}\n)\n"
@@ -150,6 +191,32 @@ def test_6_5_closing_paren_indent(self):
expected = "add_entrypoint_object(\n target\n SRCS\n s1.cpp\n)\n"
self.assertEqual(cmake_format.format_cmake_content(code), expected)
+ def test_6_6_positional_args_stay_at_two(self):
+ """Rule 6.6: Positional arguments in non-control calls stay at +2 spaces."""
+ for code, expected in [
+ (
+ "cmake_language(CALL fn\n arg1\n DEPENDS dep1\n)\n",
+ "cmake_language(CALL fn\n arg1\n DEPENDS dep1\n)\n",
+ ),
+ (
+ 'message(WARNING\n "line 1"\n "line 2"\n)\n',
+ 'message(WARNING\n "line 1"\n "line 2"\n)\n',
+ ),
+ (
+ "set(VAR\n val\n)\n",
+ "set(VAR\n val\n)\n",
+ ),
+ (
+ "list(APPEND VAR\n item\n)\n",
+ "list(APPEND VAR\n item\n)\n",
+ ),
+ (
+ "add_executable(foo\n EXCLUDE_FROM_ALL\n main.cpp\n)\n",
+ "add_executable(foo\n EXCLUDE_FROM_ALL\n main.cpp\n)\n",
+ ),
+ ]:
+ self.assertEqual(cmake_format.format_cmake_content(code), expected)
+
class TestRule7_ControlBlockIndentation(unittest.TestCase):
"""Rule 7: Control Block Indentation."""
@@ -168,6 +235,62 @@ def test_7_2_middle_blocks(self):
)
self.assertEqual(cmake_format.format_cmake_content(code), expected)
+ def test_7_3_multiline_if_hanging(self):
+ """Rule 7.3: Multi-line if() headers indent hanging lines +4 spaces while keeping body at +2 and uppercasing operators."""
+ self.assertEqual(
+ cmake_format.format_cmake_content("if(A AND\n B)\n set(X 1)\nendif()\n"),
+ "if(A AND\n B)\n set(X 1)\nendif()\n",
+ )
+ self.assertEqual(
+ cmake_format.format_cmake_content("if(A\n and B)\n set(X 1)\nendif()\n"),
+ "if(A\n AND B)\n set(X 1)\nendif()\n",
+ )
+ nested = "if(OUTER)\n if(A\n and B)\n set(X 1)\n endif()\nendif()\n"
+ nested_expected = (
+ "if(OUTER)\n if(A\n AND B)\n set(X 1)\n endif()\nendif()\n"
+ )
+ self.assertEqual(cmake_format.format_cmake_content(nested), nested_expected)
+
+ def test_7_4_multiline_elseif_hanging(self):
+ """Rule 7.4: Multi-line elseif() headers indent hanging lines +4 relative to elseif and align standalone ')' with elseif."""
+ code = "if(A)\n set(X 1)\nelseif(B OR\n C)\n set(X 2)\nendif()\n"
+ expected = "if(A)\n set(X 1)\nelseif(B OR\n C)\n set(X 2)\nendif()\n"
+ self.assertEqual(cmake_format.format_cmake_content(code), expected)
+
+ nested = (
+ "if(OUTER)\n"
+ " if(A)\n"
+ " set(X 1)\n"
+ " elseif(B OR\n"
+ " C\n"
+ " )\n"
+ " set(X 2)\n"
+ " endif()\n"
+ "endif()\n"
+ )
+ nested_expected = (
+ "if(OUTER)\n"
+ " if(A)\n"
+ " set(X 1)\n"
+ " elseif(B OR\n"
+ " C\n"
+ " )\n"
+ " set(X 2)\n"
+ " endif()\n"
+ "endif()\n"
+ )
+ self.assertEqual(cmake_format.format_cmake_content(nested), nested_expected)
+
+ def test_7_5_multiline_foreach_hanging(self):
+ """Rule 7.5: Multi-line foreach() headers indent hanging lines +4 spaces and uppercase clauses."""
+ code1 = "foreach(x in zip_lists\n l1 l2)\n set(X 1)\nendforeach()\n"
+ expected1 = "foreach(x IN ZIP_LISTS\n l1 l2)\n set(X 1)\nendforeach()\n"
+ self.assertEqual(cmake_format.format_cmake_content(code1), expected1)
+
+ code2 = "foreach(arg\n in lists\n list1\n list2\n)\n set(X ${arg})\nendforeach()\n"
+ expected2 = "foreach(arg\n IN LISTS\n list1\n list2\n)\n set(X ${arg})\nendforeach()\n"
+ self.assertEqual(cmake_format.format_cmake_content(code2), expected2)
+
class TestRule8_CommentFormatting(unittest.TestCase):
"""Rule 8: Comment Formatting & Lookahead Buffering."""
>From 4b286a07ee031720872b27c366c115fa569f2a40 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Tue, 10 Nov 2026 13:56:11 +0000
Subject: [PATCH 2/2] [libc][NFC] Fix quote formatting in cmake_format_test.py
Assisted-by: Automated tooling, human reviewed.
---
libc/utils/cmake_format_test.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/utils/cmake_format_test.py b/libc/utils/cmake_format_test.py
index 013cedd8ca33a5..b8463fa56b57f8 100644
--- a/libc/utils/cmake_format_test.py
+++ b/libc/utils/cmake_format_test.py
@@ -146,9 +146,9 @@ def test_6_3b_multivalue_header_line(self):
ctx = cmake_format.FormatterContext()
cmake_format.scan_dynamic_schemas(
- 'function(add_entrypoint_object name)\n'
+ "function(add_entrypoint_object name)\n"
' cmake_parse_arguments("ARG" "ALIAS" "" "SRCS;DEPENDS" ${ARGN})\n'
- 'endfunction()\n',
+ "endfunction()\n",
ctx=ctx,
)
sibling_code = (
More information about the libc-commits
mailing list