-
Notifications
You must be signed in to change notification settings - Fork 222
/
build.xml
556 lines (504 loc) · 21 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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
processing.py
Write processing sketches in Python.
This ant build file contains targets both for "Python Mode" for the
Processing Development Environment and for the standalone processing.py
distribution.
This has been tested on Mac OSX and linux. It is not expected to work at
all on Windows.
-jdf
Run
ant test - to run unit tests.
ant mode.zip - to create a Python Mode zip file.
ant make-all-distributions - to create a processing.py release.
ant -Dplatform=macosx make-distribution - to create the OSX processing.py release.
====================================================================== -->
<project name="processing.py" default="mode.zip">
<description>Write Processing sketches in Python</description>
<!--
You can specify the location of the Processing source code by passing
it to ant via -Dprocessing=/path/to/processing
By default, we'll look in a directory next to this one.
The same goes for processing-video (https://github.com/processing/processing-video).
-->
<property name="processing" value="../processing"/>
<property name="processing-video" value="../processing-video"/>
<!-- for <if> and <foreach> tags. -->
<taskdef
resource="net/sf/antcontrib/antcontrib.properties"
classpath="buildtime/lib/java/ant-contrib.jar"/>
<property name="pdejar" value="${processing}/app/pde.jar"/>
<property name="corejar" value="${processing}/core/library/core.jar"/>
<property name="jython" value="buildtime/lib/jython/jython.jar"/>
<property name="jython.license" value="buildtime/lib/jython/LICENSE.txt"/>
<property name="guava" value="buildtime/lib/java/guava-17.0.jar"/>
<taskdef name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="buildtime/lib/java/appbundler-1.0.jar"/>
<macrodef name="rm-rf">
<attribute name="target"/>
<sequential>
<exec executable="rm" failonerror="true">
<arg value="-rf"/>
<arg value="${basedir}/@{target}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="push">
<attribute name="srcfile"/>
<sequential>
<echo message="Pushing @{srcfile} to py.processing.org..." />
<exec executable="sh" failonerror="true">
<arg value="-c"/>
<arg value="rsync --progress -avz @{srcfile} [email protected]:/var/www/py/3" />
</exec>
</sequential>
</macrodef>
<target name="bumpversion">
<propertyfile
file="runtime/src/jycessing/build.properties"
comment="Python mode build number">
<entry key="build.date" type="date" value="now"/>
<entry key="build.number" type="int" default="0300" operation="+" pattern="0000"/>
</propertyfile>
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<echo message="Bumped to version ${jycessing.build.number}."></echo>
</target>
<target name="mode.jar" depends="build">
<jar destfile="work/PythonMode.jar">
<fileset dir="bin" excludes="jycessing/build/**,test/**"/>
</jar>
</target>
<target name="mode.dist" depends="mode.jar">
<delete dir="work/modedist" />
<property name="bundle" value="work/modedist/PythonMode"/>
<mkdir dir="${bundle}" />
<copy todir="${bundle}" file="LICENSE.txt"/>
<mkdir dir="${bundle}/mode" />
<copy todir="${bundle}/mode" file="work/PythonMode.jar"/>
<copy todir="${bundle}/mode" file="${guava}"/>
<copy todir="${bundle}/mode" file="${jython}"/>
<copy tofile="${bundle}/mode/LICENSE.jython" file="${jython.license}"/>
<copy todir="${bundle}">
<fileset dir="mode/" />
</copy>
<copy todir="${bundle}/mode">
<fileset dir="native/" />
</copy>
<copy todir="${bundle}/theme" file="libraries/runtime/splash.png"/>
<zip destfile="${bundle}/src.zip" basedir="."
includes="runtime/src/**,testing/src/**,testing/resources/**"
excludes="**/_DS.Store" />
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@version@@" replace="${jycessing.build.number}" />
<replaceregexp file="${bundle}/mode.properties" flags="g"
match="@@pretty-version@@"
replace="${jycessing.build.number}" />
<copy tofile="work/modedist/PythonMode.txt" file="${bundle}/mode.properties"/>
</target>
<target name="mode.zip" depends="mode.dist">
<zip destfile="work/PythonMode.zip" basedir="work/modedist"
excludes="PythonMode.txt,**/_DS.Store" />
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<copy file="work/PythonMode.zip" tofile="work/PythonMode_${jycessing.build.number}.zip" />
</target>
<target name="mode.upload" depends="mode.zip">
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<push srcfile="work/PythonMode_${jycessing.build.number}.zip"/>
<exec executable="sh" failonerror="true">
<arg value="-c"/>
<arg value="ssh [email protected] 'cp /var/www/py/3/PythonMode_${jycessing.build.number}.zip /var/www/py/3/PythonMode.zip'" />
</exec>
<push srcfile="work/modedist/PythonMode.txt"/>
<exec executable="sh" failonerror="true">
<arg value="-c"/>
<arg value="ssh [email protected] 'chmod a+rX /var/www/py/3/*'" />
</exec>
<echo message="Uploaded build ${jycessing.build.number}"></echo>
</target>
<target name="jar" depends="build">
<jar destfile="work/processing-py.jar">
<fileset dir="bin" excludes="jycessing/build/**,test/**"/>
<zipgroupfileset file="${guava}"/>
<zipgroupfileset file="${jython}"/>
<zipgroupfileset file="${corejar}"/>
<zipgroupfileset file="${processing}/core/library/gluegen-rt.jar"/>
<zipgroupfileset file="${processing}/core/library/jogl-all.jar"/>
<manifest>
<attribute name="Main-Class" value="jycessing.Runner"/>
</manifest>
</jar>
<foreach
list="macosx-universal,linux-i586,linux-amd64,windows-i586,windows-amd64"
param="natives.platform"
target="jar.natives"/>
</target>
<target name="jar.natives">
<jar destfile="work/processing-py-natives-${natives.platform}.jar">
<zipgroupfileset
file="${processing}/core/library/gluegen-rt-natives-${natives.platform}.jar"/>
<zipgroupfileset
file="${processing}/core/library/jogl-all-natives-${natives.platform}.jar"/>
</jar>
</target>
<target name="build" depends="build-processing,build-pde,build-video">
<mkdir dir="bin"/>
<javac destdir="bin" includeantruntime="false">
<src path="runtime/src"/>
<classpath>
<pathelement location="${jython}"/>
<pathelement location="${corejar}"/>
<pathelement location="${processing}/core/library/jogl-all.jar"/>
<pathelement location="${pdejar}"/>
<pathelement location="${guava}"/>
</classpath>
</javac>
<copy todir="bin">
<fileset dir="runtime/src" excludes="**/*.java"/>
</copy>
<!-- Update the internal launch script with the external one-->
<copy tofile="processing-py.app/Contents/Resources/script" file="processing-py.sh"/>
<chmod file="processing-py.app/Contents/MacOS/processing-py" perm="755"/>
</target>
<target name="check-pde-needs-build">
<uptodate property="pde-is-uptodate"
targetfile="${pdejar}">
<srcfiles dir="${processing}/app/src/processing/app"/>
</uptodate>
</target>
<target name="build-pde"
depends="check-pde-needs-build"
unless="pde-is-uptodate">
<echo message="Building pde." />
<ant dir="${processing}/build" target="build"/>
</target>
<target name="check-processing-needs-build">
<uptodate property="processing-is-uptodate"
targetfile="${corejar}">
<srcfiles dir="${processing}/core/src/processing/core"/>
</uptodate>
</target>
<target name="build-processing"
depends="check-processing-needs-build"
unless="processing-is-uptodate">
<echo message="Building processing." />
<ant dir="${processing}/build" target="build" inheritAll="false"/>
</target>
<target name="check-video-needs-build">
<uptodate property="video-is-uptodate"
targetfile="${processing-video}/library/video.jar">
<srcfiles dir="${processing-video}/src/processing/video"/>
</uptodate>
</target>
<target name="build-video"
depends="check-video-needs-build"
unless="video-is-uptodate">
<echo message="Building processing-video." />
<ant dir="${processing-video}" target="build">
<property name="core.classpath.location" value="../processing/core/library/"/>
</ant>
</target>
<target name="clean-self">
<rm-rf target="bin"/>
<rm-rf target="dist"/>
<rm-rf target=".cache"/>
<rm-rf target="work"/>
<delete>
<fileset dir="buildtime/py" includes="*.class"/>
</delete>
<exec executable="find" failonerror="true">
<arg line=". -name .DS_Store -depth -exec rm {} ;"/>
</exec>
</target>
<target name="clean" depends="clean-self">
<ant dir="${processing}/build" target="clean"/>
</target>
<!--
At the moment creating this launcher requires a few manual steps:
1) Run this target ("ant launcher.mac")
2.1) Remove the content of the contained "Java" folder
2.2) Adjust the included Info.plist so our python code recognizes it (TODO!)
3) Zip the app folder
4) Place the zip into the runtime's deployment folder.
-->
<target name="launcher.mac">
<mkdir dir="launcher.mac"/>
<touch file="Info.plist"/>
<bundleapp outputdirectory="launcher.mac" name="Processing" displayname="Processing.py Launcher" identifier="processing.py.launcher" shortversion="1.0" applicationCategory="public.app-category.developer-tools" mainclassname="jycessing.Runner">
<argument value="--internal"/>
<classpath file="processing-py.jar"/>
</bundleapp>
<delete>
<fileset file="Info.plist"/>
</delete>
</target>
<!--
The following macros define properties for building, compressing, and distributing
platform-specific distributions.
-->
<macrodef name="for-platform">
<attribute name="platform"/>
<attribute name="target"/>
<element name="actions" implicit="true"/>
<sequential>
<local name="dist.name"/>
<property file="runtime/src/jycessing/build.properties" prefix="jycessing"/>
<property name="dist.name" value="processing.py-${jycessing.build.number}-@{platform}"/>
<local name="compression"/>
<if>
<matches pattern="^windows.*$" string="@{platform}"/>
<then>
<property name="compression" value="zip"/>
</then>
<else>
<property name="compression" value="tgz"/>
</else>
</if>
<local name="gl.platform"/>
<switch value="@{platform}">
<case value="macosx"><property name="gl.platform" value="macosx-universal"/></case>
<case value="linux32"><property name="gl.platform" value="linux-i586"/></case>
<case value="linux64"><property name="gl.platform" value="linux-amd64"/></case>
<case value="windows32"><property name="gl.platform" value="windows-i586"/></case>
<case value="windows64"><property name="gl.platform" value="windows-amd64"/></case>
</switch>
<echo message="Executing target @{target} for platform @{platform}."/>
<antcall target="@{target}">
<param name="platform" value="@{platform}"/>
<param name="dist.name" value="${dist.name}"/>
<param name="dist.compressed" value="${dist.name}.${compression}"/>
<param name="dist.dir" value="dist/${dist.name}"/>
<param name="dist.jre" value="dist/${dist.name}/jre"/>
<param name="jre.remote" value="http://processing.py.s3.amazonaws.com/jre-8u92-@{platform}.tgz"/>
<param name="jre.local.dir" value="JREs/@{platform}"/>
<param name="jre.local.compressed" value="JREs/@{platform}.tgz"/>
<param name="gl.platform" value="${gl.platform}"/>
</antcall>
</sequential>
</macrodef>
<target name="jni-OSX" depends="build">
<javah destdir="runtime/src/jycessing/jni"
force="yes"
class="jycessing.jni.OSX"
classpath="./bin"/>
</target>
<macrodef name="for-all-platforms">
<attribute name="target"/>
<sequential>
<for-platform platform="macosx" target="@{target}"/>
<for-platform platform="linux32" target="@{target}"/>
<for-platform platform="linux64" target="@{target}"/>
<for-platform platform="windows32" target="@{target}"/>
<for-platform platform="windows64" target="@{target}"/>
</sequential>
</macrodef>
<!-- For debugging the platform macros. -->
<target name="dump-platform">
<echo message="Dumping ${platform}:"/>
<echo message=" $${dist.name} = ${dist.name}"/>
<echo message=" $${dist.dir} = ${dist.dir}"/>
<echo message=" $${dist.compressed} = ${dist.compressed}"/>
<echo message=" $${dist.jre} = ${dist.jre}"/>
<echo message=" $${jre.remote} = ${jre.remote}"/>
<echo message=" $${jre.local.dir} = ${jre.local.dir}"/>
<echo message=" $${jre.local.compressed} = ${jre.local.compressed}"/>
<echo message=" $${gl.platform} = ${gl.platform}"/>
</target>
<target name="dump-all-platforms">
<for-all-platforms target="dump-platform"/>
</target>
<!--
The following targets can only be run for particular platforms, as in
<for-platform platform="windows64" target="targetname"/>
They all refer to properties defined by the for-platform macro.
-->
<target name="getjre">
<if>
<not><available file="JREs/${platform}"/></not>
<then>
<echo message="Fetching JRE for ${platform}" />
<get src="${jre.remote}" dest="${jre.local.compressed}" usetimestamp="true"/>
<mkdir dir="${jre.local.dir}"/>
<exec executable="tar" dir="JREs">
<arg line="zxf ${platform}.tgz -C ${platform} --strip-components 1 "/>
</exec>
<if>
<equals arg1="${platform}" arg2="macosx"/>
<then>
<echo message="Moving mac JRE to sane location."/>
<exec executable="sh" dir="${jre.local.dir}" failonerror="true">
<arg value="-c"/>
<arg value="mv Contents/Home/* ."/>
</exec>
</then>
</if>
</then>
</if>
<chmod dir="${jre.local.dir}/bin" includes="*" perm="755"/>
</target>
<macrodef name="compress">
<attribute name="from"/>
<attribute name="to"/>
<attribute name="dir"/>
<sequential>
<if>
<matches pattern="^.*zip$" string="@{to}"/>
<then>
<echo message="Creating zip archive @{to}."/>
<exec executable="zip" dir="@{dir}">
<arg line="-q -r @{to} @{from}"/>
</exec>
</then>
<else>
<echo message="Creating gzipped tar archive @{to}."/>
<exec executable="tar" dir="@{dir}">
<arg line="zcfh @{to} @{from}"/>
</exec>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="copy-processing-library">
<attribute name="library"/>
<attribute name="dir"/>
<sequential>
<mkdir dir="@{dir}/@{library}"/>
<copy todir="@{dir}/@{library}">
<!--
The business about ${platform}/**, ${platform}64/** is for
catching both macosx/*.dylib and macosx64/*.dylib, for those
libraries that still have legacy OSX DLLs. Right now, that's
only video.
-->
<fileset dir="${processing}/java/libraries/@{library}/library"
includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
</copy>
</sequential>
</macrodef>
<target name="check-for-platform-lib-cache">
<condition property="platform-lib-cache-exists">
<and>
<uptodate srcfile="${processing}/core/library/gluegen-rt.jar"
targetfile=".cache/libs/${platform}/opengl/gluegen-rt.jar"/>
<uptodate srcfile="${processing-video}/library/video.jar"
targetfile=".cache/libs/${platform}/video/video.jar"/>
</and>
</condition>
</target>
<target name="platform-lib-cache"
depends="check-for-platform-lib-cache"
unless="platform-lib-cache-exists">
<local name="cache"/>
<property name="cache" value=".cache/libs/${platform}"/>
<mkdir dir="${cache}"/>
<mkdir dir="${cache}/opengl"/>
<copy todir="${cache}/opengl">
<fileset dir="${processing}/core/library" includes="*.jar" excludes="core.jar"/>
</copy>
<copy todir="${cache}/video">
<fileset dir="${processing-video}/library"
includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
</copy>
<copy-processing-library dir="${cache}" library="dxf"/>
<copy-processing-library dir="${cache}" library="io"/>
<copy-processing-library dir="${cache}" library="net"/>
<copy-processing-library dir="${cache}" library="pdf"/>
<copy-processing-library dir="${cache}" library="serial"/>
</target>
<target name="make-one-distribution" depends="jar,platform-lib-cache">
<echo message="Building distribution for ${platform}" />
<!-- Do not fetch JRE.
<for-platform platform="${platform}" target="getjre"/>
-->
<rm-rf target="${dist.dir}"/>
<mkdir dir="${dist.dir}"/>
<copy todir="${dist.dir}">
<fileset file="LICENSE.txt"/>
<fileset dir="." includes="workspace/**"/>
<fileset dir="." includes="libraries/**"/>
<fileset dir="." includes="processing-py.app/**"/>
</copy>
<copy todir="${dist.dir}" file="processing-py.sh" />
<copy todir="${dist.dir}" file="processing-py.bat" />
<chmod file="${dist.dir}/processing-py.sh" perm="755"/>
<chmod file="${dist.dir}/processing-py.bat" perm="755"/>
<chmod file="${dist.dir}/processing-py.app/Contents/Resources/script" perm="755"/>
<chmod file="${dist.dir}/processing-py.app/Contents/MacOS/processing-py" perm="755"/>
<symlink resource="${basedir}/.cache/libs/${platform}"
link="${basedir}/${dist.dir}/libraries/processing"/>
<symlink resource="${basedir}/${jre.local.dir}" link="${basedir}/${dist.jre}"/>
<symlink resource="${basedir}/examples.py" link="${basedir}/${dist.dir}/examples.py"/>
<symlink resource="${basedir}/work/processing-py.jar" link="${basedir}/${dist.dir}/processing-py.jar"/>
<symlink resource="${basedir}/work/processing-py-natives-${gl.platform}.jar"
link="${basedir}/${dist.dir}/processing-py-natives-${gl.platform}.jar"/>
<compress from="${dist.name}" to="${dist.compressed}" dir="dist"/>
</target>
<target name="make-all-distributions">
<for-all-platforms target="make-one-distribution"/>
</target>
<!--
$ ant –Dplatform=macosx make-distribution
-->
<target name="make-distribution">
<for-platform platform="${platform}" target="make-one-distribution"/>
</target>
<target name="upload-one-distribution">
<push srcfile="dist/${dist.compressed}"/>
</target>
<target name="upload-all-distributions">
<echo message="If you're not feinberg, this target will fail for you."/>
<for-all-platforms target="upload-one-distribution"/>
</target>
<!--
$ ant –Dplatform=macosx upload-distribution
-->
<target name="upload-distribution" depends="jar">
<for-platform platform="${platform}" target="upload"/>
</target>
<!--
Testing-related targets.
-->
<target name="build-tests" depends="jar">
<mkdir dir="testing/bin"/>
<javac
classpath="testing/library/junit-4.11.jar:work/processing-py.jar"
destdir="testing/bin"
includeantruntime="false" deprecation="true">
<src path="testing/src"/>
</javac>
</target>
<target name="test.standalone" depends="build-tests">
<junit fork="true" haltonfailure="true">
<test name="test.jycessing.JycessingTests">
<formatter type="plain" usefile="false"/>
</test>
<classpath>
<pathelement location="testing/bin"/>
<pathelement location="work/processing-py.jar"/>
<pathelement location="testing/library/junit-4.11.jar"/>
<pathelement location="testing/library/hamcrest-core-1.3.jar"/>
</classpath>
</junit>
</target>
<target name="test.mode" depends="build-tests,mode.jar">
<junit fork="true" haltonfailure="true">
<test name="test.jycessing.JycessingTests">
<formatter type="plain" usefile="false"/>
</test>
<classpath>
<pathelement location="testing/bin"/>
<pathelement location="${corejar}"/>
<pathelement location="${processing}/core/library/gluegen-rt.jar"/>
<pathelement location="${processing}/core/library/jogl-all.jar"/>
<pathelement location="work/PythonMode.jar"/>
<pathelement location="${guava}"/>
<pathelement location="${jython}"/>
<pathelement location="testing/library/junit-4.11.jar"/>
<pathelement location="testing/library/hamcrest-core-1.3.jar"/>
</classpath>
</junit>
</target>
<target name="test" depends="test.mode,test.standalone"/>
</project>