Release coccinelle-0.2.2-rc1
[bpt/coccinelle.git] / scripts / coccicheck / bin / update_result_tree
1 #!/bin/bash
2
3 echo "Using PREFIX="${PREFIX:=$1}
4 echo "Using PROJECT="${PROJECT:=$2}
5 echo "Using COCCI="${COCCI:=$3}
6 echo "Using RESULTS="${RESULTS:=$4}
7 echo "Using SPFLAGS="${SPFLAGS:=$5}
8
9 if [ "`which spatch.opt`" ] ; then
10 SPATCH=spatch.opt
11 else
12 SPATCH=spatch
13 fi
14 echo "Using $SPATCH"
15
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
21 SMPL=`find $COCCI -mindepth 1 -type f -name "*.cocci"| sed "s|$COCCI/||g"`
22
23 PRJNAME=`basename $PROJECT`
24
25 echo "Processing project \"$PRJNAME\""
26
27 mkdir -p $RESULTS/
28
29 for 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
37 echo "INC?=$PROJECT/include" >> $RESULTS/$f.sh
38 echo "echo \"Applying $COCCI/$s with: '\$FLAGS'\"" >> $RESULTS/$f.sh
39 echo "nice -19 $SPATCH $SPFLAGS \$FLAGS -I \$INC -cocci_file $COCCI/$s -dir $PROJECT/ $FLAGS \\" >> $RESULTS/$f.sh
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
45 done # s in $SMPL
46
47
48 #############################################
49 # Fill the Makefile
50 #############################################
51 # Generation of a Makefile per project
52 echo -e ".SUFFIXES: .out .sh\n" > $RESULTS/Makefile
53 echo -e "all: out\n" >> $RESULTS/Makefile
54 echo -e ".sh.out:" >> $RESULTS/Makefile
55 echo -e "\t-@./\$<\n" >> $RESULTS/Makefile
56
57 ALL_SMPL=`echo -n "out:"`
58
59 for 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"
65
66 done # s
67
68 echo "$ALL_SMPL" >> $RESULTS/Makefile
69
70 #############################################
71
72 # Cleanup dead links
73 find -L $RESULTS -type l -delete
74 # Cleanup empty dir.
75 find results/ -depth -type d -empty -delete