forked from jdf/processing.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
410 lines (377 loc) · 15.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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
processing.py
Write processing sketches in Python.
This build file has only been tested on mac osx, but is expected to
work just fine on Linux. It is not expected to work at all on Windows.
jdf
====================================================================== -->
<project name="processing.py" default="jar">
<description>Write Processing sketches in Python</description>
<!-- for <if> tag -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="buildtime/lib/java/ant-contrib.jar"/>
<property name="corejar" value="externals/processing/core/library/core.jar"/>
<property name="joglall" value="externals/processing/core/library/jogl-all.jar"/>
<property name="gluegenrt" value="externals/processing/core/library/gluegen-rt.jar"/>
<property name="jython" value="buildtime/lib/jython/jython.jar"/>
<!-- jycessing.buildnumber is the current version string -->
<property file="runtime/src/jycessing/buildnumber.properties" prefix="jycessing"/>
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="buildtime/lib/java/appbundler-1.0.jar"/>
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}">
<arg value="@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name="rm-rf">
<attribute name="target"/>
<sequential>
<exec executable="/bin/rm" failonerror="true">
<arg value="-rf"/>
<arg value="${basedir}/@{target}"/>
</exec>
</sequential>
</macrodef>
<target name="newversion" depends="bump-version,clean,make-all-distributions"/>
<target name="jar" depends="build">
<jar destfile="processing-py.jar">
<fileset dir="bin" excludes="jycessing/build/**,test/**"/>
<zipgroupfileset file="${jython}"/>
<zipgroupfileset file="${corejar}"/>
<manifest>
<attribute name="Main-Class" value="jycessing.Runner"/>
</manifest>
</jar>
</target>
<target name="build" depends="generate-driver,build-processing">
<mkdir dir="bin"/>
<javac destdir="bin" includeantruntime="false">
<src path="runtime/src"/>
<src path="runtime/generated"/>
<classpath>
<pathelement location="${jython}"/>
<pathelement location="${corejar}"/>
<fileset dir="libraries/fisica">
<include name="*.jar"/>
</fileset>
</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="update-processing-submodule">
<echo message="Making sure processing submodule is up-to-date." />
<git command="submodule">
<args>
<arg value="update" />
<arg value="--init" />
<arg value="--recursive" />
</args>
</git>
</target>
<target name="check-processing-needs-build"
depends="update-processing-submodule">
<uptodate property="processing-is-uptodate"
srcfile="externals/processing/core/src/processing/core/PApplet.java"
targetfile="${corejar}"/>
</target>
<target name="build-processing"
depends="check-processing-needs-build"
unless="processing-is-uptodate">
<echo message="Building processing." />
<ant dir="externals/processing/build" target="build"/>
</target>
<target name="check-driver-required">
<uptodate property="driver-is-generated"
srcfile="buildtime/template/DriverImpl.java.cog"
targetfile="runtime/generated/jycessing/DriverImpl.java"/>
</target>
<target name="generate-driver"
depends="check-driver-required,build-processing"
unless="driver-is-generated"
description="Generate DriverImpl class">
<java
classpath="${jython}:${corejar}:${joglall}:${gluegenrt}"
classname="org.python.util.jython"
fork="true">
<arg value="buildtime/py/cog.py"/>
<arg value="-U"/>
<arg value="-o"/>
<arg value="runtime/generated/jycessing/DriverImpl.java"/>
<arg value="buildtime/template/DriverImpl.java.cog"/>
</java>
</target>
<target name="clean">
<ant dir="externals/processing/build" target="clean"/>
<rm-rf target="bin"/>
<rm-rf target="dist"/>
<rm-rf target=".cache"/>
<delete file="runtime/generated/jycessing/DriverImpl.java"/>
<delete file="processing-py.jar"/>
<delete>
<fileset dir="buildtime/py" includes="*.class"/>
</delete>
<delete>
<fileset dir="buildtime/lib/jython/Lib/cogapp" includes="*.class"/>
</delete>
<exec executable="find" failonerror="true">
<arg line=". -name .DS_Store -depth -exec rm {} ;"/>
</exec>
</target>
<target name="bump-version">
<propertyfile file="runtime/src/jycessing/buildnumber.properties">
<entry key="buildnumber" type="int" operation="+" pattern="0000" default="0000"/>
</propertyfile>
</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 name="dist.name" value="processing.py-${jycessing.buildnumber}-@{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>
<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-7u25-@{platform}.tgz"/>
<param name="jre.local.dir" value="JREs/@{platform}"/>
<param name="jre.local.compressed" value="JREs/@{platform}.tgz"/>
</antcall>
</sequential>
</macrodef>
<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}"/>
</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="/bin/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="externals/processing/java/libraries/@{library}/library"
includes="*.txt,*.jar,${platform}/**,${platform}64/**"/>
</copy>
</sequential>
</macrodef>
<target name="check-for-platform-lib-cache">
<uptodate property="platform-lib-cache-exists"
srcfile="externals/processing/core/library/gluegen-rt.jar"
targetfile=".cache/libs/${platform}/opengl/gluegen-rt.jar"/>
</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="externals/processing/core/library" includes="*.jar" excludes="core.jar"/>
</copy>
<copy-processing-library dir="${cache}" library="dxf"/>
<copy-processing-library dir="${cache}" library="lwjgl"/>
<copy-processing-library dir="${cache}" library="minim"/>
<copy-processing-library dir="${cache}" library="net"/>
<copy-processing-library dir="${cache}" library="pdf"/>
<copy-processing-library dir="${cache}" library="serial"/>
<copy-processing-library dir="${cache}" library="video"/>
</target>
<target name="make-one-distribution" depends="platform-lib-cache">
<echo message="Building distribution for ${platform}" />
<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="*.sh,*.bat,processing-py.app/**"/>
</copy>
<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}/processing-py.jar" link="${basedir}/${dist.dir}/processing-py.jar"/>
<compress from="${dist.name}" to="${dist.compressed}" dir="dist"/>
</target>
<target name="make-all-distributions" depends="jar">
<for-all-platforms target="make-one-distribution"/>
</target>
<!--
$ ant –Dplatform=macosx make-distribution
-->
<target name="make-distribution" depends="jar">
<for-platform platform="${platform}" target="make-one-distribution"/>
</target>
<target name="upload-one-distribution">
<echo message="Pushing ${dist.compressed} to py.processing.org..." />
<exec executable="/bin/sh">
<arg value="-c"/>
<arg value="scp -i ~/.ssh/id_rsa-processing.org dist/${dist.compressed} [email protected]:/var/www/py" />
</exec>
</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:processing-py.jar" destdir="testing/bin"
includeantruntime="false">
<src path="testing/src"/>
</javac>
</target>
<target name="test" depends="build-tests">
<java classname="org.junit.runner.JUnitCore" fork="true">
<arg value="test.jycessing.JycessingTests"/>
<classpath>
<pathelement location="testing/bin"/>
<pathelement location="processing-py.jar"/>
<pathelement location="testing/library/junit-4.11.jar"/>
<pathelement location="testing/library/hamcrest-core-1.3.jar"/>
<fileset dir="externals/processing/core/library">
<include name="*.jar"/>
<exclude name="core.jar"/> <!-- It's already in the processing-py.jar. -->
</fileset>
</classpath>
</java>
</target>
</project>