| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
MODE=$1 |
| 4 |
PROJECT=$2 |
| 5 |
|
| 6 |
if [ "$MODE" == "" -o "$PROJECT" == "" ]; then |
| 7 |
echo -e "\n\tUsage: $0 mode path\n" |
| 8 |
echo -e "\tmode\torg or diff according to your needs" |
| 9 |
echo -e "\tpath\tyour project path\n" |
| 10 |
exit 1 |
| 11 |
fi |
| 12 |
|
| 13 |
SPATCHVER=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) .*|\1|"` |
| 14 |
WITHPYTHON=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) with Python support|yes|"` |
| 15 |
WITHPYTHON=`echo $WITHPYTHON | sed "s|spatch version \([^ ]*\) without Python support||"` |
| 16 |
|
| 17 |
echo "Using spatch version $SPATCHVER" |
| 18 |
#TODO: Add version check |
| 19 |
|
| 20 |
if [ "$WITHPYTHON" ] ; then |
| 21 |
echo "Your version has been build with Python support" |
| 22 |
else |
| 23 |
echo "Your version has no Python support" |
| 24 |
if [ "org" == "$MODE" ] ; then |
| 25 |
echo "org mode requires Python support." |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
fi |
| 29 |
echo |
| 30 |
|
| 31 |
echo "Using PREFIX="${PREFIX:=`pwd`} |
| 32 |
echo "Using PROJECT="${PROJECT:=$PREFIX/project} |
| 33 |
echo "Using COCCI="${COCCI:=$PREFIX/cocci} |
| 34 |
echo "Using RESULTS="${RESULTS:=$PREFIX/results} |
| 35 |
|
| 36 |
if [ "`which glimpse`" ]; then |
| 37 |
FLAGS=${SPFLAGS:="-timeout 60 -use_glimpse"} |
| 38 |
else |
| 39 |
FLAGS=${SPFLAGS:="-timeout 60"} |
| 40 |
fi |
| 41 |
SPFLAGS="$FLAGS -D $MODE" |
| 42 |
echo "Using SPFLAGS="$SPFLAGS |
| 43 |
|
| 44 |
echo -e "\nFor efficiency, run \`<coccinelle dir>/scripts/glimpseindex_cocci.sh\`" |
| 45 |
echo -e "in $PROJECT" |
| 46 |
echo -e "NB: glimpse is available at http://webglimpse.net/ but it is not under the GPL.\n" |
| 47 |
|
| 48 |
cat > Makefile <<EOF |
| 49 |
PREFIX?=${PREFIX} |
| 50 |
PROJECT?=${PROJECT} |
| 51 |
SPFLAGS?="${SPFLAGS}" |
| 52 |
|
| 53 |
COCCI?=${COCCI} |
| 54 |
RESULTS?=${RESULTS} |
| 55 |
|
| 56 |
.PHONY:: update viewlog viewfilteredlog viewres checkcocci |
| 57 |
.PHONY:: all clean distclean depend |
| 58 |
|
| 59 |
all: |
| 60 |
\$(MAKE) -C \$(RESULTS) |
| 61 |
|
| 62 |
update: |
| 63 |
./bin/update_result_tree \$(PREFIX) \$(PROJECT) \$(COCCI) \$(RESULTS) \$(SPFLAGS) |
| 64 |
|
| 65 |
viewlog: |
| 66 |
find \$(RESULTS) -name "*.log" | xargs cat | pager |
| 67 |
|
| 68 |
viewfilteredlog: |
| 69 |
find \$(RESULTS) -name "*.log" | xargs cat | \\ |
| 70 |
grep -ve "^\$\$" | \\ |
| 71 |
grep -v "HANDLING" | \\ |
| 72 |
grep -v "NOTE" | \\ |
| 73 |
grep -v "Unsupported form of #define" | \\ |
| 74 |
grep -v "no glimpse keyword inferred from snippet" | \\ |
| 75 |
grep -v "EXN:Common.Timeout" | \\ |
| 76 |
grep -v "FLOW: can't find exit or error exit:" | \\ |
| 77 |
grep -v "FLOW: deadcode detected:" | \\ |
| 78 |
grep -v "LEXER: identifier with dollar:" | \\ |
| 79 |
grep -v "LEXER: unrecognised symbol in char:" | \\ |
| 80 |
grep -v "LEXER: ZARB" | \\ |
| 81 |
grep -v "CFG: orphelin nodes, maybe something weird happened" | \\ |
| 82 |
grep -v "not worth trying" | \\ |
| 83 |
grep -v "MultiFound field:" | \\ |
| 84 |
grep -ve "(ONCE) warning: I consider .* as a constant" | \\ |
| 85 |
grep -ve "TYPE: header .* not found" |
| 86 |
|
| 87 |
viewres: |
| 88 |
find \$(RESULTS) -name "*.out" | xargs pager |
| 89 |
|
| 90 |
checkcocci: |
| 91 |
for c in \`find \$(COCCI) -name "*.cocci"\`; do spatch -parse_cocci \$\$c > /dev/null ; done |
| 92 |
|
| 93 |
clean: |
| 94 |
find \$(RESULTS) -name "*.out" -delete |
| 95 |
find \$(RESULTS) -name "*.log" -delete |
| 96 |
|
| 97 |
distclean: |
| 98 |
rm -rf \$(RESULTS) |
| 99 |
|
| 100 |
maintclean: distclean |
| 101 |
rm Makefile |
| 102 |
|
| 103 |
depend: update |
| 104 |
EOF |