Release coccinelle-0.2.2-rc1
[bpt/coccinelle.git] / scripts / coccicheck / bin / update_result_tree
CommitLineData
951c7801
C
1#!/bin/bash
2
3echo "Using PREFIX="${PREFIX:=$1}
4echo "Using PROJECT="${PROJECT:=$2}
5echo "Using COCCI="${COCCI:=$3}
6echo "Using RESULTS="${RESULTS:=$4}
7echo "Using SPFLAGS="${SPFLAGS:=$5}
8
7f004419
C
9if [ "`which spatch.opt`" ] ; then
10 SPATCH=spatch.opt
11else
12 SPATCH=spatch
13fi
14echo "Using $SPATCH"
15
951c7801
C
16#echo "Using PREFIX="${PREFIX:=`pwd`}
17#echo "Using COCCI="${COCCI:=$PREFIX/cocci}
18#echo "Using PROJECT="${PROJECT:=$PREFIX/project}
19#echo "Using RESULTS="${RESULTS:=$PREFIX/results}
20
21SMPL=`find $COCCI -mindepth 1 -type f -name "*.cocci"| sed "s|$COCCI/||g"`
22
23PRJNAME=`basename $PROJECT`
24
25echo "Processing project \"$PRJNAME\""
26
27mkdir -p $RESULTS/
28
29for s in $SMPL;do
30
31 f=`basename $s .cocci`
32
33 # Produce bug report for a particular version and a particular bug pattern
34 echo "#!/bin/bash" > $RESULTS/$f.sh
35 echo "" >> $RESULTS/$f.sh
36 echo "FLAGS=\"`grep -E \"// +Options *:\" $COCCI/$s | cut -f2 -d\":\"`\"" >> $RESULTS/$f.sh
c3e37e97 37 echo "INC?=$PROJECT/include" >> $RESULTS/$f.sh
951c7801 38 echo "echo \"Applying $COCCI/$s with: '\$FLAGS'\"" >> $RESULTS/$f.sh
7f004419 39 echo "nice -19 $SPATCH $SPFLAGS \$FLAGS -I \$INC -cocci_file $COCCI/$s -dir $PROJECT/ $FLAGS \\" >> $RESULTS/$f.sh
951c7801
C
40 echo "> $f.out \\" >> $RESULTS/$f.sh
41 echo "2> $f.log" >> $RESULTS/$f.sh
42 echo "echo \"$f.out completed\"" >> $RESULTS/$f.sh
43 chmod u+x $RESULTS/$f.sh
44
45done # s in $SMPL
7f004419 46
951c7801
C
47
48#############################################
49# Fill the Makefile
50#############################################
51# Generation of a Makefile per project
52echo -e ".SUFFIXES: .out .sh\n" > $RESULTS/Makefile
53echo -e "all: out\n" >> $RESULTS/Makefile
54echo -e ".sh.out:" >> $RESULTS/Makefile
55echo -e "\t-@./\$<\n" >> $RESULTS/Makefile
7f004419 56
951c7801
C
57ALL_SMPL=`echo -n "out:"`
58
59for s in $SMPL;do
60 f=`basename $s .cocci`
61
62# echo "$f.out:" >> $RESULTS/Makefile
63# echo " -./$f.sh" >> $RESULTS/Makefile
64 ALL_SMPL="$ALL_SMPL $f.out"
7f004419 65
951c7801 66done # s
7f004419 67
951c7801
C
68echo "$ALL_SMPL" >> $RESULTS/Makefile
69
70#############################################
71
7f004419 72# Cleanup dead links
951c7801
C
73find -L $RESULTS -type l -delete
74# Cleanup empty dir.
75find results/ -depth -type d -empty -delete