From ffd30bd3d08bc1455c28bdfda8f3f17f1f9896e2 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Tue, 29 Sep 2020 11:13:55 +0200
Subject: [PATCH] scripts: Speed up uncrustify by running 4 jobs in parallel

There are some large files, and in most setups (including CI runners) we
have multiple cores available. Use xargs to run multiple parallel
uncrustify jobs rather than one large one. Just hardcode 4 jobs and 4
files at the same time for now.
---
 scripts/uncrustify.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/uncrustify.sh b/scripts/uncrustify.sh
index cb03906..b912695 100755
--- a/scripts/uncrustify.sh
+++ b/scripts/uncrustify.sh
@@ -12,8 +12,11 @@ case "$1" in
         ;;
 esac
 
+ARGS=4
+JOBS=4
+
 pushd "$SRCROOT"
-uncrustify -c "$CFG" $OPTS `git ls-tree --name-only -r HEAD | grep -E '.*\.[ch]$' | grep -v nbis | grep -v fpi-byte | grep -v build/`
+git ls-tree --name-only -r HEAD | grep -E '.*\.[ch]$' | grep -v nbis | grep -v fpi-byte | grep -v build/ | xargs -n$ARGS -P $JOBS uncrustify -c "$CFG" $OPTS
 RES=$?
 popd
-exit $RES
\ No newline at end of file
+exit $RES