forked from jeffpiazza/derbynet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
567 lines (502 loc) · 19.2 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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<project name="DerbyNet" default="dist" basedir=".">
<description>
Web-based software for managing pinewood derby races
</description>
<property name="replay-dir" location="replay"/>
<property name="replay-app.name" value="MacDerbyReplay"/>
<property name="replay-app-dir" location="${replay-dir}/build/Release"/>
<property name="timer-dir" location="timer"/>
<property name="timer-jar-dir" location="${timer-dir}/dist/lib"/>
<property name="docs-dir" location="docs"/>
<!-- uniserver-resources is where the downloaded Uniform Server
self-extracting (.exe) archives are found. Only available on a
Windows machine. -->
<property name="uniserver-resources" location="../uniserver-resources"/>
<!-- The self-extracting archives get applied to this directory, which can be
copied to non-Windows build platforms. -->
<property name="uniserver-unpacked" location="../uniserver-unpacked"/>
<!-- The content of the .win.zip is staged here, zipped, and then
deleted. -->
<property name="uniserver-target" location="dist/uniserver"/>
<!-- Contains a recent copy of
https://webrtc.github.io/adapter/adapter-latest.js -->
<property name="webrtc-adapter-cache" location="adapter-webrtc"/>
<condition property="is_mac">
<os family="mac"/>
</condition>
<condition property="is_windows">
<os family="windows"/>
</condition>
<target name="clean"
description="Remove generated artifacts for a clean build environment">
<delete quiet="true">
<fileset dir="website/inc">
<filename name="banner.inc"/>
<filename name="generated-version.inc"/>
<filename name="generated-build-date.inc"/>
<filename name="generated-commit-hash.inc"/>
</fileset>
</delete>
<ant dir="${timer-dir}" target="clean"/>
<ant dir="${docs-dir}" target="clean"/>
</target>
<target name="dist" depends="dist.oneclick, dist.mac, dist.debian"
description="Build complete distribution"/>
<target name="dist.zip" depends="timer-jar, docs-dist, generated"
description="Build OS-neutral zip-file distribution">
<zip destfile="../DerbyNet-${release-series}-${git-rev-count}${git-dirty}-${DSTAMP}.zip">
<fileset dir=".">
<include name="MIT-LICENSE.txt"/>
<include name="README.txt"/>
</fileset>
<fileset dir=".">
<include name="website/**/*"/>
<exclude name="website/local/**"/>
</fileset>
<mappedresources>
<fileset dir="docs/dist">
<include name="**"/>
</fileset>
<globmapper from="*" to="docs/*"/>
</mappedresources>
<fileset dir="${timer-jar-dir}">
<include name="*.jar"/>
</fileset>
<fileset dir=".">
<include name="lib/jSSC*src.jar"/>
<include name="extras/**/*"/>
</fileset>
</zip>
<delete file="${replay-app.name}.dmg" quiet="yes" failonerror="false"/>
</target>
<target name="generated" depends="banner, generated-version.inc,
generated-build-date.inc,
release-series, generated-commit-hash.inc, quickref, webrtc-adapter"
description="Build generated files">
</target>
<target name="webrtc-adapter">
<mkdir dir="${webrtc-adapter-cache}"/>
<get src="https://webrtc.github.io/adapter/adapter-latest.js"
dest="${webrtc-adapter-cache}" ignoreerrors="true"/>
<copy file="${webrtc-adapter-cache}/adapter-latest.js"
tofile="website/js/adapter.js" overwrite="true"/>
</target>
<target name="generated-version.inc">
<exec executable="git" outputproperty="git-rev-count">
<arg value="rev-list"/>
<arg value="HEAD"/>
<arg value="--count"/>
</exec>
<concat destfile="website/inc/generated-version.inc">
<propertyresource name="git-rev-count"/>
</concat>
</target>
<target name="generated-build-date.inc">
<tstamp/>
<concat destfile="website/inc/generated-build-date.inc">
<propertyresource name="TODAY"/>
</concat>
</target>
<target name="generated-commit-hash.inc">
<exec executable="git" outputproperty="git-hash">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="git-status-short">
<arg value="status"/>
<arg value="--short"/>
</exec>
<!-- If there's no output, git-status-short doesn't even get set. If it
IS set, this property element has no effect. -->
<property name="git-status-short" value=""/>
<loadresource property="git-dirty">
<propertyresource name="git-status-short"/>
<filterchain>
<striplinebreaks/>
<replaceregex pattern=".+" replace="-modified" flags="s"/>
</filterchain>
</loadresource>
<property name="git-dirty" value=""/>
<concat destfile="website/inc/generated-commit-hash.inc">
<propertyresource name="git-hash"/>
<propertyresource name="git-dirty"/>
</concat>
</target>
<target name="release-series">
<exec executable="git" outputproperty="git-branch">
<arg value="rev-parse"/>
<arg value="--abbrev-ref"/>
<arg value="HEAD"/>
</exec>
<loadresource property="release-series">
<propertyresource name="git-branch"/>
<filterchain>
<striplinebreaks/>
<replaceregex pattern="master" replace="dev" flags="s"/>
</filterchain>
</loadresource>
</target>
<target name="banner" depends="release-series">
<loadresource property="banner-release">
<propertyresource name="git-branch"/>
<filterchain>
<striplinebreaks/>
<replaceregex pattern="master" replace="dev"/>
</filterchain>
</loadresource>
<copy file="templates/banner.inc" tofile="website/inc/banner.inc" overwrite="true">
<filterchain>
<replacetokens>
<token key="BRANCH" value="${banner-release}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<target name="quickref" depends="docs-dist">
<copy file="docs/dist/Quick Reference.pdf" tofile="website/quickref.pdf" overwrite="true"/>
</target>
<target name="timer-jar" depends="generated"
description="Builds the jar file for derby-timer">
<ant dir="${timer-dir}"/>
</target>
<target name="dist.debian" depends="generated, timer-jar, docs-dist"
description="Build a Debian binary package (.deb) for all of DerbyNet">
<ant dir="installer/debian" target="dist"/>
</target>
<target name="docs-dist" description="Generate documentation PDFs">
<ant dir="${docs-dir}"/>
</target>
<!-- From http://www.rkuntz.org/pmwiki.php?n=Code.AntDiskImage -->
<!-- Create a DMG - This only works on MacOSX (requires hdiutil) -->
<target name="replay-dmg" if="is_mac" depends="replay-build-release"
description="Create a DMG package for MacOSX (only works on MacOSX)">
<!-- Set this property value to your application name -->
<!-- Set this property value to a directory where you can
mount temporarily your images, for example /tmp -->
<property name="mountdir"
value="/tmp"/>
<!-- Delete previously created DMG -->
<delete file="${replay-app.name}.dmg"
quiet="yes" failonerror="false"/>
<!-- Create a temporary Disk Image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="create"/>
<arg value="-srcfolder"/>
<arg value="${replay-app-dir}/${replay-app.name}.app"/>
<arg value="-volname"/>
<arg value="${replay-app.name}"/>
<arg value="-ov"/>
<arg value="${replay-app.name}-tmp.dmg"/>
<arg value="-format"/>
<arg value="UDRW"/>
</exec>
<!-- Attach the temporary image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="attach"/>
<arg value="${replay-app.name}-tmp.dmg"/>
<arg value="-mountroot"/>
<arg value="${mountdir}/"/>
</exec>
<!-- Copy the background, the volume icon and DS_Store files -->
<!--
<mkdir dir="${mountdir}/${replay-app.name}/.background"/>
<copy file="background.png"
tofile="${mountdir}/${replay-app.name}/.background/background.png"
overwrite="true"/>
<copy file="VolumeIcon.icns"
tofile="${mountdir}/${replay-app.name}/.VolumeIcon.icns"
overwrite="true"/>
<copy file="DS_Store"
tofile="${mountdir}/${replay-app.name}/.DS_Store"
overwrite="true"/>
-->
<!-- Indicate that we want a custom icon -->
<!--
<exec executable="/Developer/Tools/SetFile" os="Mac OS X">
<arg value="-a"/>
<arg value="C"/>
<arg value="${mountdir}/${replay-app.name}"/>
</exec>
-->
<!-- Add a symbolic link to the Applications directory -->
<symlink link="${mountdir}/${replay-app.name}" resource="/Applications"/>
<!-- Detach the temporary image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="detach"/>
<arg value="${mountdir}/${replay-app.name}"/>
</exec>
<!-- Compress it to a new image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="convert"/>
<arg value="${replay-app.name}-tmp.dmg"/>
<arg value="-format"/>
<arg value="UDZO"/>
<arg value="-o"/>
<arg value="${replay-app.name}.dmg"/>
</exec>
<!-- Delete the temporary image -->
<delete file="${replay-app.name}-tmp.dmg"
quiet="yes" failonerror="false"/>
</target>
<target name="replay-build-release" if="is_mac"
description="(Mac only)">
<exec executable="/usr/bin/xcodebuild" os="Mac OS X">
<arg value="-project"/>
<arg value="replay/MacDerbyReplay.xcodeproj"/>
<arg value="-configuration"/>
<arg value="Release"/>
<arg value="build"/>
</exec>
</target>
<target name="mac.installer.website" if="is_mac" depends="generated">
<mkdir dir="ROOT/Library/WebServer/Documents/derbynet"/>
<copy todir="ROOT/Library/WebServer/Documents/derbynet" overwrite="true">
<fileset dir="website">
<include name="**"/>
<exclude name="local/**"/>
</fileset>
</copy>
<exec executable="/usr/bin/pkgbuild">
<arg value="--root"/>
<arg value="ROOT"/>
<arg value="--scripts"/>
<arg value="installer/mac/scripts/webserver"/>
<arg value="--identifier"/>
<arg value="org.jeffpiazza.derbynet.website"/>
<arg value="--version"/>
<arg value="1.0"/>
<arg value="derbynet.website.pkg"/>
</exec>
<delete dir="ROOT"/>
</target>
<target name="mac.installer.replay" if="is_mac" depends="replay-build-release">
<mkdir dir="ROOT/Applications/DerbyNet"/>
<copy todir="ROOT/Applications/DerbyNet/" overwrite="true">
<fileset dir="${replay-app-dir}">
<include name="${replay-app.name}.app/**"/>
</fileset>
</copy>
<chmod perm="+x"
file="ROOT/Applications/DerbyNet/${replay-app.name}.app/Contents/MacOS/${replay-app.name}"/>
<exec executable="/usr/bin/pkgbuild">
<arg value="--component"/>
<arg value="ROOT/Applications/DerbyNet/${replay-app.name}.app"/>
<arg value="--install-location"/>
<arg value="/Applications/DerbyNet"/>
<arg value="--identifier"/>
<arg value="org.jeffpiazza.derbynet.replay"/>
<arg value="--version"/>
<arg value="1.0"/>
<arg value="derbynet.replay.pkg"/>
</exec>
<delete dir="ROOT"/>
</target>
<target name="mac.installer.timer" if="is_mac" depends="timer-jar">
<mkdir dir="ROOT/Applications/DerbyNet"/>
<copy todir="ROOT/Applications/DerbyNet" overwrite="true">
<fileset dir="${timer-jar-dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="lib">
<include name="jSSC*src.jar"/>
</fileset>
</copy>
<exec executable="/usr/bin/pkgbuild">
<arg value="--root"/>
<arg value="ROOT"/>
<arg value="--identifier"/>
<arg value="org.jeffpiazza.derbynet.timer"/>
<arg value="--version"/>
<arg value="1.0"/>
<arg value="derbynet.timer.pkg"/>
</exec>
<delete dir="ROOT"/>
</target>
<target name="mac.installer.docs" if="is_mac" depends="docs-dist">
<mkdir dir="ROOT/Applications/DerbyNet/docs"/>
<copy todir="ROOT/Applications/DerbyNet" overwrite="true">
<mappedresources>
<fileset dir="docs/dist">
<include name="**"/>
</fileset>
<globmapper from="*" to="docs/*"/>
</mappedresources>
</copy>
<exec executable="/usr/bin/pkgbuild">
<arg value="--root"/>
<arg value="ROOT"/>
<arg value="--identifier"/>
<arg value="org.jeffpiazza.derbynet.docs"/>
<arg value="--version"/>
<arg value="1.0"/>
<arg value="derbynet.docs.pkg"/>
</exec>
<delete dir="ROOT"/>
</target>
<target name="mac.installer.extras" if="is_mac">
<mkdir dir="ROOT/Applications/DerbyNet/extras"/>
<copy todir="ROOT/Applications/DerbyNet">
<fileset dir="installer/mac/scripts/webserver">
<include name="create-or-update-php-ini.sh"/>
<include name="update-apache-config.sh"/>
</fileset>
</copy>
<chmod perm="+x"
file="ROOT/Applications/DerbyNet/create-or-update-php-ini.sh"/>
<chmod perm="+x"
file="ROOT/Applications/DerbyNet/update-apache-config.sh"/>
<copy todir="ROOT/Applications/DerbyNet/extras">
<fileset dir="extras"/>
</copy>
<exec executable="/usr/bin/pkgbuild">
<arg value="--root"/>
<arg value="ROOT"/>
<arg value="--identifier"/>
<arg value="org.jeffpiazza.derbynet.extras"/>
<arg value="--version"/>
<arg value="1.0"/>
<arg value="derbynet.extras.pkg"/>
</exec>
<delete dir="ROOT"/>
</target>
<target name="dist.mac" if="is_mac" description="Full Macintosh installer package"
depends="mac.installer.website,
mac.installer.replay, mac.installer.timer,
mac.installer.docs, mac.installer.extras,
generated-version.inc,
generated-build-date.inc,
release-series, generated-commit-hash.inc">
<mkdir dir="RESOURCES"/>
<copy file="installer/mac/README.html" todir="RESOURCES"/>
<exec executable="/usr/bin/productbuild">
<arg value="--distribution"/>
<arg value="installer/mac/Distribution.xml"/>
<arg value="--resources"/>
<arg value="RESOURCES"/>
<arg value="../DerbyNet-${release-series}-${git-rev-count}${git-dirty}-${DSTAMP}.pkg"/>
</exec>
<delete file="derbynet.docs.pkg"/>
<delete file="derbynet.extras.pkg"/>
<delete file="derbynet.replay.pkg"/>
<delete file="derbynet.timer.pkg"/>
<delete file="derbynet.website.pkg"/>
<delete dir="RESOURCES"/>
</target>
<target name="unpack-uniserver" if="is_windows"
description="Runs the self-extracting archives from ${uniserver-resources} to build ${uniserver-unpacked}">
<delete dir="${uniserver-unpacked}"/>
<mkdir dir="${uniserver-unpacked}"/>
<pathconvert property="controller-exe">
<path>
<fileset dir="${uniserver-resources}" includes="*controller*.exe"/>
</path>
</pathconvert>
<exec executable="${controller-exe}" failonerror="true">
<arg value="-y"/>
<arg value="-o${uniserver-unpacked}"/>
</exec>
<pathconvert property="apache-exe">
<path>
<fileset dir="${uniserver-resources}" includes="*apache*.exe"/>
</path>
</pathconvert>
<exec executable="${apache-exe}" failonerror="true">
<arg value="-y"/>
<arg value="-o${uniserver-unpacked}\UniServerZ"/>
</exec>
<pathconvert property="php-exe">
<path>
<fileset dir="${uniserver-resources}" includes="*php*.exe"/>
</path>
</pathconvert>
<exec executable="${php-exe}" failonerror="true">
<arg value="-y"/>
<arg value="-o${uniserver-unpacked}\UniServerZ"/>
</exec>
</target>
<target name="dist.oneclick" depends="generated, timer-jar, docs-dist"
description="Build the "one-click" zip file to run Uniform Server on Windows">
<delete dir="${uniserver-target}"/>
<mkdir dir="${uniserver-target}"/>
<mkdir dir="${uniserver-target}/Data"/>
<copy todir="${uniserver-target}">
<fileset dir="${uniserver-unpacked}">
<include name="**"/>
</fileset>
</copy>
<pathconvert property="php-core-dir">
<path>
<dirset file="${uniserver-target}\UniServerZ\core\php*"/>
</path>
</pathconvert>
<loadresource property="php-version">
<propertyresource name="php-core-dir"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern=".*\\" flags="g"/>
<replaceregex pattern=".*/" flags="g"/>
</tokenfilter>
</filterchain>
</loadresource>
<replaceregexp file="${uniserver-target}\UniServerZ\home\us_config\us_user.ini"
match="PHP_SELECT=php[0-9]*"
replace="PHP_SELECT=${php-version}"/>
<replaceregexp file="${uniserver-target}\UniServerZ\home\us_config\us_user.ini"
match="DISPLAY_PAGE_2=yes"
replace="DISPLAY_PAGE_2=no"/>
<replaceregexp file="${uniserver-target}\UniServerZ\core\${php-version}\php_production.ini"
match=";(extension=php_pdo_odbc.dll)"
replace="\1"/>
<replaceregexp file="${uniserver-target}\UniServerZ\core\${php-version}\php_production.ini"
match=";(extension=php_pdo_sqlite.dll)"
replace="\1"/>
<delete>
<!-- Delete .htaccess, favicon.ico, and other cruft -->
<fileset dir="${uniserver-target}\UniServerZ\www"
includes="**"/>
</delete>
<copy todir="${uniserver-target}\UniServerZ\www">
<fileset dir="website">
<exclude name="local/**"/>
</fileset>
</copy>
<mkdir dir="${uniserver-target}\UniServerZ\www\local"/>
<echo file="${uniserver-target}\UniServerZ\www\local\default-file-path.inc"><![CDATA[<?php
$default_file_path=dirname(dirname(dirname(dirname(__FILE__)))).DIRECTORY_SEPARATOR."Data";
?>
]]>
</echo>
<copy todir="${uniserver-target}">
<fileset dir="${timer-jar-dir}">
<include name="*.jar"/>
</fileset>
</copy>
<copy todir="${uniserver-target}\docs">
<fileset dir="docs/dist">
<include name="**"/>
</fileset>
</copy>
<copy todir="${uniserver-target}\installers">
<fileset dir="${uniserver-resources}">
<include name="*.exe"/>
<exclude name="Zero*"/>
</fileset>
</copy>
<copy todir="${uniserver-target}">
<fileset dir="installer/win">
<include name="README"/>
</fileset>
</copy>
<zip destfile="../DerbyNet-${release-series}-${git-rev-count}${git-dirty}-${DSTAMP}.win.zip">
<fileset dir="${uniserver-target}">
<include name="**"/>
</fileset>
</zip>
<delete dir="${uniserver-target}"/>
<delete dir="dist"/>
</target>
<target name="demo" description="demo">
<ant dir="demo"/>
</target>
</project>