]> git.ipfire.org Git - thirdparty/systemd.git/blob - coccinelle/run-coccinelle.sh
man: fix reference to sd_bus_add_fallback_vtable
[thirdparty/systemd.git] / coccinelle / run-coccinelle.sh
1 #!/bin/bash -e
2
3 # Exclude following paths from the Coccinelle transformations
4 EXCLUDED_PATHS=(
5 "src/boot/efi/*"
6 "src/shared/linux/*"
7 "src/basic/linux/*"
8 # Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
9 "src/libsystemd/sd-bus/test-bus-vtable.c"
10 )
11
12 top="$(git rev-parse --show-toplevel)"
13 iso_defs="$top/coccinelle/systemd-definitions.iso"
14 args=
15
16 # Create an array from files tracked by git...
17 mapfile -t files < <(git ls-files ':/*.[ch]')
18 # ...and filter everything that matches patterns from EXCLUDED_PATHS
19 for excl in "${EXCLUDED_PATHS[@]}"; do
20 files=(${files[@]//$excl})
21 done
22
23 case "$1" in
24 -i)
25 args="$args --in-place"
26 shift
27 ;;
28 esac
29
30 if ! parallel -h >/dev/null; then
31 echo 'Please install GNU parallel (package "parallel")'
32 exit 1
33 fi
34
35 for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do
36 echo "--x-- Processing $SCRIPT --x--"
37 TMPFILE=`mktemp`
38 echo "+ spatch --sp-file $SCRIPT $args ..."
39 parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
40 spatch --iso-file $iso_defs --sp-file $SCRIPT $args ::: "${files[@]}" \
41 2>"$TMPFILE" || cat "$TMPFILE"
42 echo -e "--x-- Processed $SCRIPT --x--\n"
43 done