fix bugs in transaction code that:
[IRC.git] / Robust / src / buildscript
1 #!/bin/bash
2
3 printhelp() {
4 echo -dsm distributed shared memory
5 echo -mac distributed shared memory mac support
6 echo -check generate check code
7 echo -dmalloc link in dmalloc
8 echo -recover compile task code
9 echo -specdir directory
10 echo -taskstate do task state analysis
11 echo -optional enable optional
12 echo -debug generate debug symbols
13 echo -webinterface enable web interface
14 echo -runtimedebug printout runtime debug messages
15 echo "-thread use support for multiple threads"
16 echo "-optimize call gcc with -O9 (optimize)"
17 echo "-nooptimize call gcc with -O0 (do not optimize)"
18 echo -curdir directory 
19 echo -mainclass class with main method
20 echo -o binary
21 echo -instructionfailures inject code for instructionfailures
22 echo -help help
23 }
24
25 ROBUSTROOT=~/research/Robust/src
26 DSMRUNTIME=$ROBUSTROOT/Runtime/DSTM/interface/
27 REPAIRROOT=~/research/Repair/RepairCompiler/
28 CURDIR=`pwd`
29 DSMFLAG=false
30 CHECKFLAG=false
31 RECOVERFLAG=false
32 USEDMALLOC=false
33 THREADFLAG=false
34 SPECDIR=`pwd`
35 SRCFILES=''
36 EXTRAOPTIONS=''
37 MAINFILE='a'
38 JAVAOPTS=''
39 OPTIONALFLAG=false
40
41 if [[ -z $1 ]]
42 then
43 printhelp
44 exit
45 fi
46
47 while [[ -n $1 ]]
48 do
49 if [[ $1 = '-help' ]]
50 then
51 printhelp
52 exit
53 elif [[ $1 = '-o' ]]
54 then
55 MAINFILE="$2"
56 shift
57 elif [[ $1 = '-mainclass' ]]
58 then
59 JAVAOPTS="$JAVAOPTS -mainclass $2"
60 shift
61 elif [[ $1 = '-dsm' ]]
62 then
63 JAVAOPTS="$JAVAOPTS -dsm"
64 DSMFLAG=true
65 elif [[ $1 = '-mac' ]]
66 then
67 EXTRAOPTIONS="$EXTRAOPTIONS -DMAC"
68 elif [[ $1 = '-taskstate' ]]
69 then
70 JAVAOPTS="$JAVAOPTS -taskstate"
71 elif [[ $1 = '-optional' ]]
72 then
73 JAVAOPTS="$JAVAOPTS -optional"
74 OPTIONALFLAG=true
75 elif [[ $1 = '-dmalloc' ]]
76 then
77 USEDMALLOC=true
78 elif [[ $1 = '-recover' ]]
79 then
80 RECOVERFLAG=true
81 JAVAOPTS="$JAVAOPTS -task"
82 elif [[ $1 = '-webinterface' ]]
83 then
84 JAVAOPTS="$JAVAOPTS -webinterface"
85 elif [[ $1 = '-instructionfailures' ]]
86 then
87 JAVAOPTS="$JAVAOPTS -instructionfailures"
88 elif [[ $1 = '-check' ]]
89 then
90 CHECKFLAG=true
91 JAVAOPTS="$JAVAOPTS -conscheck"
92 elif [[ $1 = '-specdir' ]]
93 then
94 cd $2
95 SPECDIR=`pwd`
96 cd $CURDIR
97 shift
98 elif [[ $1 = '-debug' ]]
99 then
100 EXTRAOPTIONS="$EXTRAOPTIONS -g"
101 elif [[ $1 = '-runtimedebug' ]]
102 then
103 EXTRAOPTIONS="$EXTRAOPTIONS -DDEBUG"
104 elif [[ $1 = '-nooptimize' ]]
105 then
106 EXTRAOPTIONS="$EXTRAOPTIONS -O0"
107 elif [[ $1 = '-optimize' ]]
108 then
109 EXTRAOPTIONS="$EXTRAOPTIONS -O9"
110 elif [[ $1 = '-thread' ]]
111 then
112 JAVAOPTS="$JAVAOPTS -thread"
113 EXTRAOPTIONS="$EXTRAOPTIONS -DTHREADS -lpthread"
114 THREADFLAG=true
115 elif [[ $1 = '-curdir' ]]
116 then
117 CURDIR=$2
118 shift
119 else
120 SRCFILES="$SRCFILES $1"
121 fi
122 shift
123 done
124
125 BUILDDIR="$CURDIR/tmpbuilddirectory"
126
127 cd $1
128 cd $CURDIR
129 shift
130
131 mkdir $BUILDDIR
132
133 if $CHECKFLAG #Generate structure files for repair tool
134 then
135 JAVAOPTS="$JAVAOPTS -struct structfile"
136 fi
137
138 # Build bristlecone/java sources
139
140 java -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
141 $ROBUSTROOT/ClassLibrary/ -dir $BUILDDIR -precise \
142 $JAVAOPTS $SRCFILES
143
144 # Build all of the consistency specs
145
146 if $CHECKFLAG # CHECKFLAG
147 then
148 cd $SPECDIR
149 mkdir $BUILDDIR/specdir
150 cp $REPAIRROOT/MCC/CRuntime/* $BUILDDIR/specdir
151
152 echo > $BUILDDIR/specs
153
154 # compile specs into C code
155 for i in * # iterate over all directories
156 do
157 if [[ "$i" != "CVS" ]] # CVSDIR CHECK
158 then
159 cd $SPECDIR/$i
160 cat $BUILDDIR/structfile.struct $i.label > $i.struct
161 java -cp $REPAIRROOT/:. MCC.Compiler -name $i -checkonly $i
162 cp size.[c,h] $BUILDDIR/specdir
163 cp $i.c $i\_aux.[c,h] $BUILDDIR/specdir
164 echo $i >> $BUILDDIR/specs
165 fi # CVSDIR CHECK
166 done # iterate over all directories
167
168 #compile C code
169
170 cd $BUILDDIR/specdir
171 ./buildrobust
172 echo > $BUILDDIR/checkers.h
173 for i in `cat $BUILDDIR/specs`
174 do
175 gcc -O0 -g -c $i\_aux.c
176 echo \#include \"specdir\/$i\_aux.h\" >> $BUILDDIR/checkers.h
177 done
178 fi # CHECKFLAG
179
180 #build and link everything
181
182 cd $CURDIR 
183
184 INCLUDES="$INCLUDES -I$ROBUSTROOT/Runtime -I. -IRuntime/include \
185 -I$BUILDDIR"
186
187 FILES="$ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/task.c \
188 $ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c \
189 $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \
190 $ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \
191 $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"
192
193 if $DSMFLAG
194 then
195 EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -I$DSMRUNTIME"
196 FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c"
197 fi
198
199 if $RECOVERFLAG
200 then
201 EXTRAOPTIONS="$EXTRAOPTIONS -DTASK"
202 FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c"
203 fi
204
205 if $OPTIONALFLAG
206 then
207 EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
208 FILES="$FILES tmpbuilddirectory/optionalarrays.c"
209 fi
210
211 if $THREADFLAG
212 then
213 FILES="$FILES $ROBUSTROOT/Runtime/thread.c"
214 fi
215
216 if $CHECKFLAG
217 then
218 EXTRAOPTIONS="$EXTRAOPTIONS -DCONSCHECK $BUILDDIR/specdir/*.o"
219 INCLUDES="$INCLUDES -I$BUILDDIR/specdir"
220 fi
221
222 if $USEDMALLOC
223 then
224 EXTRAOPTIONS="$EXTRAOPTIONS -ldmalloc -DDMALLOC"
225 fi
226
227 gcc $INCLUDES $EXTRAOPTIONS -DPRECISE_GC \
228 tmpbuilddirectory/methods.c $FILES -o $MAINFILE.bin
229
230 exit
231