]>
Commit | Line | Data |
---|---|---|
2d0bc684 LP |
1 | #!/bin/bash -e |
2 | ||
4a4eaade FS |
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 | ||
12b74c38 | 12 | top="$(git rev-parse --show-toplevel)" |
b3fd7b53 | 13 | iso_defs="$top/coccinelle/systemd-definitions.iso" |
00bfe67f ZJS |
14 | args= |
15 | ||
4a4eaade FS |
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 | ||
00bfe67f | 23 | case "$1" in |
cc5549ca ZJS |
24 | -i) |
25 | args="$args --in-place" | |
26 | shift | |
27 | ;; | |
00bfe67f | 28 | esac |
31d31f20 | 29 | |
3b253ad6 | 30 | if ! parallel -h >/dev/null; then |
cc5549ca ZJS |
31 | echo 'Please install GNU parallel (package "parallel")' |
32 | exit 1 | |
3b253ad6 ZJS |
33 | fi |
34 | ||
12b74c38 | 35 | for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do |
cc5549ca ZJS |
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 \ | |
4a4eaade | 40 | spatch --iso-file $iso_defs --sp-file $SCRIPT $args ::: "${files[@]}" \ |
cc5549ca ZJS |
41 | 2>"$TMPFILE" || cat "$TMPFILE" |
42 | echo -e "--x-- Processed $SCRIPT --x--\n" | |
2d0bc684 | 43 | done |