forked from rahulsavani/gte
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
374 lines (295 loc) · 12.9 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?xml version="1.0" encoding="utf-8"?>
<!--
Build file for Game Theory Explorer
@author Martin Prause
Adapted by Mark Egesdal and Rahul Savani
to replace dependency on Google App Engine with Jetty
-->
<project name="GameTheoryExplorer" basedir="." default="compileComplete">
<!-- setup a prefix for all environment variables -->
<property file="build.properties" />
<!-- ===================== -->
<!-- Define parameters -->
<!-- ===================== -->
<property name="gui.proj.dir" value="gui-builder"/>
<property name="gui.test.proj.dir" value="gui-builder/test"/>
<property name="lib.proj.dir" value="lib-algo"/>
<property name="lib.test.proj.dir" value="lib-algo/test"/>
<property name="web.proj.dir" value="web-service"/>
<property name="lib.proj.native" value="native-algo"/>
<property name="lib.proj.native.algo" value="native-algo/lrslib-042c"/>
<property name="lib.proj.native.my" value="native-algo/myNative"/>
<property name="war.name" value="gte"/>
<property name="lib.jar.name" value="${lib.proj.dir}"/>
<property name="build.dir" value="build"/>
<property name="lib.build.dir" value="${build.dir}/${lib.proj.dir}"/>
<property name="lib.test.build.dir" value="${build.dir}/${lib.proj.dir}-test"/>
<property name="gui.build.dir" value="${build.dir}/${gui.proj.dir}"/>
<property name="gui.test.build.dir" value="${build.dir}/${gui.proj.dir}-test"/>
<property name="war.dir" value="${build.dir}/${war.name}"/>
<condition property="isUnix">
<os family="unix" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<macrodef name="jetty-start">
<sequential>
<antcall target="jetty-stop"/>
<echo>${JETTY_HOME}</echo>
<java jar="${JETTY_HOME}/start.jar" fork="true" dir="${JETTY_HOME}" >
<jvmarg value="-Dfile.encoding=UTF-8"/>
<jvmarg value="-DSTOP.PORT=8079"/>
<jvmarg value="-DSTOP.KEY=secret"/>
</java>
</sequential>
</macrodef>
<!-- ===================== -->
<!-- Compile external Code -->
<!-- ===================== -->
<target name="compileOnlyNative">
<antcall target="-setUnixEnv" />
<antcall target="-setWindowsEnv" />
<exec dir="${lib.proj.native.algo}" executable="make" />
</target>
<target name="-setWindowsEnv" if="isWindows">
<echo>Windows</echo>
<copy file="${lib.proj.native.algo}/makefile_windows" tofile="${lib.proj.native.algo}/makefile" overwrite="true" />
</target>
<target name="-setUnixEnv" if="isUnix">
<copy file="${lib.proj.native.algo}/makefile_unix" tofile="${lib.proj.native.algo}/makefile" overwrite="true" />
</target>
<!-- ===================== -->
<!-- Jetty targets -->
<!-- ===================== -->
<target name="jetty-check-status">
<condition property="jetty.started">
<socket server="localhost" port="8080"/>
</condition>
</target>
<target name="jetty-start">
<jetty-start/>
</target>
<target name="jetty-stop" depends="jetty-check-status" if="jetty.started">
<java jar="${JETTY_HOME}/start.jar" fork="true" dir="${JETTY_HOME}">
<jvmarg value="-DSTOP.PORT=8079"/>
<jvmarg value="-DSTOP.KEY=secret"/>
<arg value="--stop"/>
</java>
<sleep seconds="2"/>
</target>
<!-- This is what you have to include to be able to use "mxml" ant task -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<taskdef resource="flexUnitTasks.tasks">
<classpath>
<fileset dir="${gui.test.proj.dir}/lib">
<include name="flexUnitTasks*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- <target name="main" depends="clean, jetty-stop, test-core, test-gui, copy-package, copy-natives"> -->
<target name="compileComplete" depends="clean, jetty-stop, test-core, compileOnlyNative, copy-package, copy-natives ">
<echo>Finished</echo>
</target>
<target name="compileQuick" depends="clean, jetty-stop, copy-package, copy-natives">
<jetty-start/>
<echo>Finished</echo>
</target>
<target name="makeProductive" depends="clean, compileOnlyNative, copy-package, copy-natives">
<echo>Finished make productive</echo>
</target>
<target name="makeWarFile" depends="clean, copy-package-war-dist">
<echo>Finished make copy-package-war-dist</echo>
</target>
<target name="makeJettyFile" depends="clean, copy-package-jetty-dist">
<echo>Finished make copy-package-jetty-dist</echo>
</target>
<target name="setup">
<mkdir dir="${build.dir}"/>
</target>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile-core" depends="setup">
<echo>Compiling core library...</echo>
<mkdir dir="${lib.build.dir}"/>
<javac
srcdir="${lib.proj.dir}/src"
destdir="${lib.build.dir}"
includeAntRuntime="false"
/>
<!-- <copy file="${web.proj.dir}/src/config.properties" todir="${war.dir}/WEB-INF/classes" overwrite="true"/>-->
</target>
<target name="compile-gui" depends="setup">
<echo>Compiling Flash GUI...</echo>
<mxmlc
file="${gui.proj.dir}/src/lse/math/games/builder/view/Main.mxml"
debug="false"
output="${gui.build.dir}/GuiBuilder.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
link-report="${gui.build.dir}/MxmlcReport.xml"
incremental="true"
fork="true"
maxmemory="1024m">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.source-path path-element="${gui.proj.dir}/src"/>
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!--<library-path dir="${SWC_LIB_DIR}" append="true">
<include name="*.swc" />
</library-path> -->
</mxmlc>
</target>
<target name="test-gui" depends="compile-gui">
<mkdir dir="${gui.test.build.dir}"/>
<!-- Execute FlexUnit tests and publish reports -->
<flexunit
workingDir="${gui.test.build.dir}"
toDir="${gui.test.build.dir}"
haltonfailure="true"
verbose="false"
localTrusted="true">
<source dir="${gui.proj.dir}/src" />
<testSource dir="${gui.test.proj.dir}/src">
<include name="**/*Test.as" />
</testSource>
<library dir="${gui.test.proj.dir}/lib" />
</flexunit>
<!-- Generate readable JUnit-style reports -->
<!--<junitreport todir="${gui.test.build.dir}">
<fileset dir="${gui.test.build.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${gui.test.build.dir}/html" />
</junitreport>-->
</target>
<target name="test-core" depends="compile-core">
<mkdir dir="${lib.test.build.dir}"/>
<echo>Compiling Java library tests...</echo>
<javac
srcdir="${lib.test.proj.dir}/src"
destdir="${lib.test.build.dir}"
includeAntRuntime="false">
<classpath>
<pathelement location="${lib.build.dir}" />
<fileset dir="${lib.test.proj.dir}/lib">
<include name="junit*.jar" />
</fileset>
</classpath>
</javac>
<echo>Running Java library tests...</echo>
<junit printsummary="on" haltonfailure="yes">
<formatter type="brief" usefile="true"/>
<classpath>
<pathelement location="${lib.test.build.dir}" />
<pathelement location="${lib.build.dir}" />
<fileset dir="${lib.test.proj.dir}/lib">
<include name="junit*.jar" />
</fileset>
</classpath>
<batchtest todir="${lib.test.build.dir}">
<fileset dir="${lib.test.proj.dir}/src"/>
</batchtest>
</junit>
</target>
<target name="create-package" depends="compile-core, compile-gui">
<echo>Building WAR directory...</echo>
<mkdir dir="${war.dir}"/>
<copy todir="${war.dir}" overwrite="true">
<fileset dir="${web.proj.dir}/war"></fileset>
</copy>
<tstamp>
<format property="last.mod" pattern="yyyy-MM-dd hh:mm" timezone="GMT"/>
</tstamp>
<replace file="${war.dir}/builder/index.jsp" token="yyyy-MM-dd hh:mm" value="${last.mod}"/>
<echo>Creating core library JAR file...</echo>
<mkdir dir="${war.dir}/WEB-INF/lib"/>
<jar
destfile="${war.dir}/WEB-INF/lib/${lib.jar.name}.jar"
basedir="${lib.build.dir}"
update="true"
/>
<echo>Copying GUI flash program to WAR...</echo>
<html-wrapper swf="GuiBuilder" express-install="true" output="${gui.build.dir}" height="100%" width="100%" />
<copy file="${gui.build.dir}/GuiBuilder.swf" todir="${war.dir}/builder" overwrite="true"/>
<copy file="${gui.build.dir}/playerProductInstall.swf" todir="${war.dir}/builder" overwrite="true"/>
<copy file="${gui.build.dir}/swfobject.js" todir="${war.dir}/builder" overwrite="true"/>
<!-- Timestamp the swf to prevent browser caching of the old one -->
<replace file="${war.dir}/builder/index.jsp" token="GuiBuilder.swf" value="GuiBuilder-${DSTAMP}${TSTAMP}.swf"/>
<move file="${war.dir}/builder/GuiBuilder.swf" tofile="${war.dir}/builder/GuiBuilder-${DSTAMP}${TSTAMP}.swf" />
<echo>Compiling WAR class files...</echo>
<mkdir dir="${war.dir}/WEB-INF/classes"/>
<javac
srcdir="${web.proj.dir}/src"
destdir="${war.dir}/WEB-INF/classes"
includeAntRuntime="false">
<classpath>
<fileset dir="${war.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${JETTY_HOME}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
<echo>Packaging WAR...</echo>
<war destfile="${build.dir}/${war.name}.war"
webxml="${war.dir}/WEB-INF/web.xml"
basedir="${war.dir}">
</war>
</target>
<target name="copy-package" depends="create-package">
<copy file="${build.dir}/${war.name}.war" todir="${JETTY_HOME}/webapps" overwrite="true" />
</target>
<target name="copy-package-war-dist" depends="create-package">
<copy file="${build.dir}/${war.name}.war" todir="${WAR_DIST_DIR}" overwrite="true" />
</target>
<target name="makeWithoutServer" depends="create-package">
<zip destfile="${GTE_WSC}/gte_wsc.zip"
basedir="${gui.build.dir}">
</zip>
</target>
<target name="copy-package-jetty-dist" depends="create-package">
<copy file="${build.dir}/${war.name}.war" todir="${JETTY_DIST_DIR}/webapps" overwrite="true" />
<delete dir="${JETTY_DIST_DIR}/${lib.proj.native}"/>
<mkdir dir="${JETTY_DIST_DIR}/${lib.proj.native}"/>
<mkdir dir="${JETTY_DIST_DIR}/${lib.proj.native.algo}"/>
<mkdir dir="${JETTY_DIST_DIR}/${lib.proj.native.my}"/>
<antcall target="-copyUnixFiles" />
<antcall target="-copyWindowsFiles" />
<zip destfile="${JETTY_ZIP_DIR}/${war.name}.zip"
basedir="${JETTY_DIST_DIR}">
</zip>
</target>
<target name="copy-natives">
<delete dir="${JETTY_HOME}/${lib.proj.native}"/>
<mkdir dir="${JETTY_HOME}/${lib.proj.native}"/>
<mkdir dir="${JETTY_HOME}/${lib.proj.native.algo}"/>
<mkdir dir="${JETTY_HOME}/${lib.proj.native.my}"/>
<antcall target="-copyUnixFiles" />
<antcall target="-copyWindowsFiles" />
</target>
<target name="-copyWindowsFiles" if="isWindows">
<echo>Windows</echo>
<copy file="${lib.proj.native.algo}/nash.exe" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.algo}/prepare_nash.exe" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.algo}/lrs.exe" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.algo}/coclique3.exe" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.my}/test.bat" todir="${JETTY_HOME}/${lib.proj.native.my}" overwrite="true" />
</target>
<target name="-copyUnixFiles" if="isUnix">
<copy file="${lib.proj.native.algo}/nash" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.algo}/prepare_nash" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<copy file="${lib.proj.native.algo}/coclique3" todir="${JETTY_HOME}/${lib.proj.native.algo}" overwrite="true" />
<chmod file="${JETTY_HOME}/${lib.proj.native.algo}/nash" perm="700"/>
<chmod file="${JETTY_HOME}/${lib.proj.native.algo}/prepare_nash" perm="700"/>
<chmod file="${JETTY_HOME}/${lib.proj.native.algo}/lrs" perm="700"/>
<chmod file="${JETTY_HOME}/${lib.proj.native.algo}/coclique3" perm="700"/>
<copy file="${lib.proj.native.my}/test.sh" todir="${JETTY_HOME}/${lib.proj.native.my}" overwrite="true" />
<chmod file="${JETTY_HOME}/${lib.proj.native.my}/test.sh" perm="700"/>
</target>
</project>