From: Jérémie Galarneau Date: Fri, 30 Aug 2024 19:52:37 +0000 (-0400) Subject: clang-format: ignore generated files X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9bfa2aa7c7054496ad2efffdcd3882e288b9388b;p=lttng-tools.git clang-format: ignore generated files 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 Change-Id: I1cd10349ef1a66b1d595105b0ec1a4beef9dcc9a --- diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 000000000..d0ccb24fe --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1,2 @@ +extras/bindings/swig/python/lttng_wrap.c +src/common/filter/filter-parser.cpp diff --git a/format-cpp b/format-cpp index 17275de77..a3943ae57 100755 --- a/format-cpp +++ b/format-cpp @@ -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