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