Check that the string table does not include unused entries

This commit is contained in:
Michael Tautschnig 2018-04-21 11:59:37 +01:00
parent 61ca5dfbb8
commit f79b45345a
2 changed files with 37 additions and 0 deletions

View File

@ -38,6 +38,13 @@ jobs:
script: scripts/travis_lint.sh
before_cache:
- &string-table-check
stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="string-table"
install:
script: scripts/string_table_check.sh
before_cache:
- stage: Linter + Doxygen + non-debug Ubuntu/gcc-5 test
env: NAME="DOXYGEN-CHECK"
addons:

30
scripts/string_table_check.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
whitelist=" \
"
cleanup()
{
rm -f "$ids_file"
}
ids_file=$(mktemp)
trap cleanup EXIT
gcc -E -P -x c src/util/irep_ids.def \
-D'IREP_ID_ONE(x)=ID_ ## x' -D'IREP_ID_TWO(x,y)=ID_ ## x' > $ids_file
for w in $whitelist
do
perl -p -i -e "s/^$w\n//" $ids_file
done
for i in $(<$ids_file)
do
if ! git grep -w -q -c -F $i
then
echo "$i is never used"
exit 1
fi
done