clang-format: ignore generated files
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 30 Aug 2024 19:52:37 +0000 (15:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 30 Aug 2024 20:35:36 +0000 (16:35 -0400)
Two auto-generated files cause clang-format < v17 to hang when
they are being formatted. I have not looked into the root-cause,
but formatting them is useless anyhow.

Adding them to .clang-format-ignore works around the problem for the
moment.

Since clang-format 14 does not support ignore files, their support is
crudely emulated here using grep to filter out find's results.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1cd10349ef1a66b1d595105b0ec1a4beef9dcc9a

.clang-format-ignore [new file with mode: 0644]
format-cpp

diff --git a/.clang-format-ignore b/.clang-format-ignore
new file mode 100644 (file)
index 0000000..d0ccb24
--- /dev/null
@@ -0,0 +1,2 @@
+extras/bindings/swig/python/lttng_wrap.c
+src/common/filter/filter-parser.cpp
index 17275de77c7f4ee7f0d004cab9f94558e9f2c511..a3943ae578d07552e0ce9219910a63511cbde7dd 100755 (executable)
@@ -6,6 +6,8 @@
 
 expected_formatter_major_version=14
 
+SCRIPT_DIR=$(dirname "$0")/
+
 # Runs the formatter, making sure it's the expected version.
 format_cpp() {
        local formatter=$1
@@ -35,10 +37,14 @@ format_cpp() {
        # Using xargs to fail as soon as the formatter fails (`-exec`
        # won't stop if its subprocess fails).
        #
+       # Since clang-format 14 does not support ignore files, their
+       # support is crudely emulated here.
+       #
        # shellcheck disable=SC2086
        find "$root_dir" -path './src/vendor' -prune \
                -o -type f \( -name '*\.h' -o -name '*\.hpp' -o -name '*\.c' -o -name '*\.cpp' \) \
-               -not -path '*/\.*' -print0 | xargs -P$(nproc) -n1 -0 $formatter -i --style=file --fallback-style=none
+               -not -path '*/\.*' -print0 | grep -zv -f "$SCRIPT_DIR"/.clang-format-ignore | \
+               xargs -P"$(nproc)" -n1 -0 $formatter -i --style=file --fallback-style=none
 }
 
 if [[ -n "$FORMATTER" ]]; then
This page took 0.025657 seconds and 4 git commands to generate.