-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcheck-symbols.sh
executable file
·51 lines (45 loc) · 1.1 KB
/
check-symbols.sh
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
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#/ Usage: check-symbols.sh {check,build}
#/ Commands:
#/
#/ build - Update the *.sym files at the root of this repository
#/ based on the *.so files that have been built.
#/ check - Compare the *.sym files against the symbols exposed in
#/ the *.so files that have been built.
#/
#/ By checking in the *.sym files and running `check-symbols.sh check`
#/ in the gate, we establish an auditable record of when symbols are
#/ added or removed from the various *.so files we produce.
set -e
get() {
nm --dynamic --defined-only $1 | cut -c18- | LC_COLLATE=C sort
}
check() {
if [ ! -e $2 ]; then
touch $2
fi
diff -u $2 <( get $1 )
}
build() {
get $1 > $2
}
case $1 in
check | build)
func=$1
;;
*)
grep '^#/' "$0" |cut -c4-
exit 1
esac
rc=0
for lib in $(find . -name '*.so') ; do
echo "${func}ing $( basename $lib )"
if ! $func $lib $( basename ${lib/%.so/.sym} ) ; then
rc=1
echo
fi
done
if [ $rc == 1 ]; then
echo "Symbols don't match! Try running '$0 build' before committing."
fi
exit $rc