annotate misc/run-clang-tidy.sh @ 2392:ab2d0fe8f0b7

Additions to Mac build scripting
author Chris Cannam
date Mon, 21 Oct 2019 13:07:02 +0100
parents 7c30a7f20c6a
children
rev   line source
Chris@2123 1 #!/bin/bash
Chris@2123 2
Chris@2123 3 usage() {
Chris@2123 4 echo
Chris@2123 5 echo " $0: run clang-tidy on a build with supplied arguments" 1>&2
Chris@2123 6 echo
Chris@2123 7 echo " Run this from the root of the source tree, on a Linux system." 1>&2
Chris@2123 8 echo " Assumes that \"./configure && make clean && make\" will produce a successful" 1>&2
Chris@2123 9 echo " build using g++." 1>&2
Chris@2123 10 echo " All arguments are passed to clang-tidy." 1>&2
Chris@2123 11 echo
Chris@2123 12 exit 2
Chris@2123 13 }
Chris@2123 14
Chris@2123 15 if [ t"$1" = "t" ]; then
Chris@2123 16 usage
Chris@2123 17 fi
Chris@2123 18
Chris@2123 19 ctargs="$@"
Chris@2123 20
Chris@2123 21 echo "clang-tidy args: $ctargs"
Chris@2123 22
Chris@2123 23 set -eu
Chris@2123 24
Chris@2123 25 tmpdir=$(mktemp -d)
Chris@2123 26 trap "rm -rf \$tmpdir\$" 0
Chris@2123 27
Chris@2123 28 #log="build.log"
Chris@2123 29
Chris@2123 30 log="$tmpdir/make.log"
Chris@2123 31 ./configure
Chris@2123 32 make clean
Chris@2123 33 make -j3 2>&1 | tee "$log"
Chris@2123 34
Chris@2123 35 list="$tmpdir/tidy.list"
Chris@2123 36
Chris@2123 37 grep '^g[+][+] ' "$log" | grep ' [-]c ' > "$list"
Chris@2123 38
Chris@2123 39 cat "$list" | while read line ; do
Chris@2123 40
Chris@2123 41 filename=${line##* }
Chris@2123 42 remainder=${line% *}
Chris@2123 43 cc=${remainder%% *}
Chris@2123 44 ccargs=${remainder#* }
Chris@2123 45
Chris@2123 46 ccargs=$(echo "$ccargs" | sed 's/-flto //')
Chris@2123 47
Chris@2123 48 echo
Chris@2123 49
Chris@2123 50 case "$filename" in
Chris@2123 51 bq*) echo "ignoring $filename" ;;
Chris@2123 52 o/*) echo "ignoring $filename" ;;
Chris@2123 53 vamp-*) echo "ignoring $filename" ;;
Chris@2123 54 dataquay/*) echo "ignoring $filename" ;;
Chris@2123 55 src/*) echo "ignoring $filename" ;;
Chris@2123 56 *) echo "not ignoring $filename"
Chris@2123 57 echo clang-tidy $ctargs "$filename" -- $ccargs ;
Chris@2123 58 clang-tidy $ctargs "$filename" -- $ccargs ;;
Chris@2123 59 esac
Chris@2123 60 done
Chris@2123 61