From: Philippe Proulx Date: Wed, 3 May 2023 19:28:41 +0000 (-0400) Subject: tools/format-cpp: run `xargs` with `-P$(nproc)` (format in parallel) X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=66c3bce11973e6e96a3791c378a9e5f98ddaa280 tools/format-cpp: run `xargs` with `-P$(nproc)` (format in parallel) This saves many seconds per run. Note that some implementations of xargs might not accept the `-P` option, therefore `tools/format-cpp` now requires something like GNU xargs. `nproc` is also a GNU (Coreutils) thing. Signed-off-by: Philippe Proulx Change-Id: Ie7113dae32cff506b716c3b590bbe58eac5f1586 Reviewed-on: https://review.lttng.org/c/babeltrace/+/9950 Reviewed-by: Simon Marchi Reviewed-by: Michael Jeanson --- diff --git a/tools/format-cpp b/tools/format-cpp index 98e901aa..0a165a8f 100755 --- a/tools/format-cpp +++ b/tools/format-cpp @@ -39,7 +39,7 @@ format_cpp() { find "$root_dir" \( -name '*.cpp' -o -name '*.hpp' \) \ ! -wholename '*/cpp-common/optional.hpp' \ ! -wholename '*/cpp-common/string_view.hpp' \ - -print0 | xargs -n1 -0 $formatter + -print0 | xargs -P$(nproc) -n1 -0 $formatter } if [[ -n "$FORMATTER" ]]; then