forked from fathominfo/processing-p5js-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·180 lines (149 loc) · 6.22 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
<project name="p5js-mode" default="install">
<property file="local.properties" />
<condition property="props.present">
<available file="local.properties" />
</condition>
<fail unless="props.present"
message=" ${line.separator}Missing file.
${line.separator}Create a file named local.properties,
${line.separator}and write a line that reads:
${line.separator}processing.dir=/path/to/processing-git
${line.separator}with the path to where you have the code for processing checked out
${line.separator}and another line that reads:
${line.separator}sketchbook.dir=/path/to/your/sketchbook" />
<property name="me" value="p5jsMode" />
<property name="install.dir"
value="${sketchbook.dir}/modes/${me}" />
<property name="jar.path"
value="mode/${me}.jar" />
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="build">
<!-- Locate the JDT compiler, since we know processing.dir must exist and
using the JDT allows us to build the PDE with only a JRE on Windows
and Linux. If something goes wrong, javac (the "modern" compiler)
will be used instead. (Logic from processing/core/build.xml) -->
<property name="jdt.jar"
value="${processing.dir}/java/mode/org.eclipse.jdt.core.jar" />
<condition property="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"
else="modern">
<available file="${jdt.jar}" />
</condition>
<!--<echo message="compiler is ${build.compiler}" />-->
<mkdir dir="bin" />
<javac source="1.8"
target="1.8"
encoding="UTF-8"
includeAntRuntime="false"
debug="true"
srcdir="src"
destdir="bin"
classpath="${processing.dir}/core/bin;
${processing.dir}/app/bin;
${processing.dir}/java/bin;
mode/jsoup-1.10.1.jar"
nowarn="true">
<!-- kinda gross, but if not using the JDT, this just ignored anyway -->
<compilerclasspath path="${jdt.jar}; ${processing.dir}/java/mode/jdtCompilerAdapter.jar" />
</javac>
<!-- make sure this exists -->
<!--<mkdir dir="mode" />-->
<!-- jsoup is in there now, no need -->
<jar destfile="${jar.path}">
<fileset dir="bin" />
</jar>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install" depends="build">
<available file="examples" property="examples.exist" />
<fail unless="examples.exist" message="First run the 'ant examples' target to get the examples folder ready." />
<copy todir="${install.dir}/examples">
<fileset dir="examples" />
</copy>
<copy todir="${install.dir}/libraries">
<fileset dir="libraries" />
</copy>
<copy todir="${install.dir}/mode">
<fileset dir="mode" />
</copy>
<copy todir="${install.dir}/template">
<fileset dir="template" />
</copy>
<copy todir="${install.dir}">
<fileset file="mode.properties" />
<fileset file="jshint.js" />
<fileset file="keywords.txt" />
</copy>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="examples" depends="build">
<delete dir="examples" />
<java classname="processing.mode.p5js.build.ImportExamples"
classpath="bin;
${processing.dir}/core/bin;
${processing.dir}/app/bin;
${processing.dir}/app/lib/jna.jar;
${processing.dir}/app/lib/jna-platform.jar" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="clean">
<delete dir="${install.dir}" />
<delete dir="bin" />
<delete file="${jar.path}" />
<!--<delete dir="mode" />-->
<delete file="${me}.zip" />
<delete file="${me}.txt" />
<delete dir="examples" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="dist" depends="revision-check, build">
<mkdir dir="dist" />
<zip destfile="dist/${me}.zip">
<!-- This can probably be done more efficiently, no? How about a PR? -->
<zipfileset dir="." prefix="p5jsMode" includes="examples/**" />
<zipfileset dir="." prefix="p5jsMode" includes="jshint.js" />
<zipfileset dir="." prefix="p5jsMode" includes="keywords.txt" />
<zipfileset dir="." prefix="p5jsMode" includes="libraries/**" />
<zipfileset dir="." prefix="p5jsMode" includes="mode/**" />
<zipfileset dir="." prefix="p5jsMode" includes="mode.properties" />
<zipfileset dir="." prefix="p5jsMode" includes="template/**" />
</zip>
<copy file="mode.properties" tofile="dist/${me}.txt" />
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="revision-check">
<!-- figure out the revision number -->
<loadfile srcfile="todo.txt" property="revision">
<filterchain>
<headfilter lines="1"/>
<tokenfilter>
<stringtokenizer suppressdelims="true"/>
<!-- remove the preceding zeroes -->
<containsregex pattern="0+(\d+)" />
</tokenfilter>
</filterchain>
</loadfile>
<!-- <echo message="revision is ${revision}." /> -->
<!-- figure out the revision number in base.java -->
<loadfile srcfile="mode.properties"
property="revision.base">
<filterchain>
<tokenfilter>
<linetokenizer />
<containsregex pattern="version="/>
<replaceregex pattern="[^0-9]*" flags="g" replace=""/>
</tokenfilter>
</filterchain>
</loadfile>
<!-- <echo message="base revision is ${revision.base}." /> -->
<condition property="revision.correct">
<!-- Using contains because I can't figure out how to get rid of the
LF in revision.base. Please file a bug if you have a fix. -->
<contains string="${revision.base}" substring="${revision}"/>
</condition>
<!-- the revision.base property won't be set
if $revision wasn't found... -->
<fail unless="revision.correct"
message="Fix revision number in mode.properties, it should be ${revision}" />
</target>
</project>