-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcppcheck.chevre
More file actions
40 lines (30 loc) · 1.04 KB
/
Copy pathcppcheck.chevre
File metadata and controls
40 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# cppcheck is slow, so a source that has not changed since it last passed is
# not checked again. What passed is remembered in a file of the plugin's own
# rather than in build/hashes: passing cppcheck is not the same thing as
# having been compiled, and the options cppcheck was given are part of what
# passed.
CHECKED=build/cppcheck
options="$(echo "$@" | jq -r .options | not is_null)"
# What passed last time, as long as it passed with the options in use now.
checked_before()
{
if [[ -f "$CHECKED" ]] && [[ "$(head -n 1 "$CHECKED")" == "$options" ]]; then
tail -n +2 "$CHECKED"
fi
}
hashes="$(all_sources | map generate_hash | sort)"
if [[ -z "$hashes" ]]; then
exit 0
fi
sources="$(echo "$hashes" | diff -u - <(checked_before | sort) | filter new_hash | map hash_name)"
if [[ -z "$sources" ]]; then
exit 0
fi
verbose cppcheck --error-exitcode=1 "$options" $sources
# Only once everything has passed. A source that failed is never recorded, so
# it is checked again on the next build.
{
echo "$options"
echo "$hashes"
} > "$CHECKED"