-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
executable file
·324 lines (292 loc) · 13.8 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build" name="Java Information Dynamics Toolkit" xmlns:if="ant:if">
<description>
Build file for the Java Information Dynamics Toolkit
</description>
<!-- set global properties for this build -->
<property name="version" value="1.6"/>
<property name="mainfilename" value="infodynamics"/>
<property name="jarplainname" value="${mainfilename}.jar" />
<property name="jarversiondistnamezip" value="${mainfilename}-jar-${version}.zip" />
<property name="distname" value="${mainfilename}-dist-${version}" />
<property name="distnamezip" value="${distname}.zip" />
<property name="distnametargz" value="${distname}.tar.gz" />
<property name="src" location="java/source"/>
<property name="cudasrc" location="cuda"/>
<property name="bin" location="bin"/>
<property name="unittestsouttoplevel" location="unittests"/>
<property name="unittestssrc" location="java/unittests"/>
<property name="unittestsbin" location="${unittestsouttoplevel}/bin"/>
<property name="reports.tests" location="${unittestsouttoplevel}/reports"/>
<property name="javadocsdir" location="javadocs"/>
<property name="versionfile" value="version-${version}.txt"/>
<!-- To enable GPU code, set the following variable to true -->
<property name="enablegpu" value="false"/>
<path id="project.classpath">
<pathelement location="bin"/>
</path>
<path id="apache-classpath">
<pathelement path="./share/commons-math3-3.5.jar"/>
</path>
<!-- Make required directories -->
<target name="init" description="Create the compiled code directories">
<mkdir dir="${bin}"/>
<mkdir dir="${bin}/cuda"/>
<mkdir dir="${unittestsbin}"/>
<mkdir dir="${unittestsbin}/cuda"/>
<mkdir dir="${reports.tests}"/>
</target>
<!-- Compile the java toolkit -->
<target name="compile" depends="init" description="compile the source">
<!-- Compile to Java 7 to provide compatibility for users with older JREs.
Caveat: The flags here only check the language compatibility, but
may still use newer libraries which may cause issues for users with JDK 7.
Indeed, one gets the warning: "bootstrap class path not set in conjunction with -source 1.7"
To fix this, one would use the bootstrap classpath to point our JDK to an rt.jar
for Java 7.
At this stage, I'm sure I'm not using new library calls from Java 8+, so we can
ignore the warning, and I don't want to bother installing newer Java just to compile
like this. I'll endeavour not to use JDK 8 libraries so as not to cause
any issues here ... -->
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" encoding="UTF8">
<classpath refid="apache-classpath"/>
</javac>
<!-- Compiling Cpp code -->
<antcall target="gpu" if:true="${enablegpu}">
<param name="DEBUG" value="0"/>
</antcall>
</target>
<!-- Jar the toolkit -->
<target name="jar" depends="compile" description="Create the jar for distribution">
<!-- Put everything in ${bin} into the infodynamics-${version}.jar file -->
<jar jarfile="${jarplainname}" basedir="${bin}" excludes="cuda/*.o,cuda/*.a,cuda/findComputeCapability">
<manifest>
<attribute name="Main-Class" value="infodynamics.demos.autoanalysis.AutoAnalyserLauncher"/>
</manifest>
</jar>
<!-- Set the jar to be runnable: (only has effect on unix/linux)
so we can double click to run the AutoAnalyser -->
<chmod file="${jarplainname}" perm="u+x"/>
</target>
<!-- Compile and run the JUnit tests -->
<target name="junit" depends="compile" description="Run the junit tests and make sure they compile">
<!-- Compile the junit tests first -->
<javac destdir="${unittestsbin}" includeAntRuntime="true" debug="true">
<!-- Need includeAntRuntime=true if you want to pick up junit.jar and ant-junit.jar in ANT_HOME/lib;
Otherwise you will need to set the classpath to include these here. -->
<src path="${unittestssrc}"/>
<classpath refid="project.classpath"/>
<classpath refid="apache-classpath"/>
</javac>
<!-- Run the junit tests and make sure they complete ok -->
<junit printsummary="yes" showoutput="yes" fork="true" forkmode="once" haltonfailure="yes" haltonerror="yes" includeantruntime="true">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${unittestsbin}"/>
<pathelement location="${basedir}/clover.jar"/>
</classpath>
<formatter type="plain"/>
<batchtest todir="${reports.tests}"> <!-- Writes full reports with stdout and stderr to ${reports.tests} -->
<fileset dir="${unittestsbin}">
<include name="**/*.class"/>
<exclude name="**/*AbstractTester.class"/>
<exclude name="**/ActiveInfoStorageCalculatorCorrelationIntegrals.class"/>
<exclude name="**/ActiveInfoStorageCalculatorKernelDirect.class"/>
<exclude name="**/*GPU*.class"/>
</fileset>
</batchtest>
</junit>
<!-- If applicable, run also GPU tests -->
<antcall target="gputest" if:true="${enablegpu}"/>
</target>
<!-- Make javadocs, excluding the AutoAnalyser and classes we've derived from Apache Commons Math -->
<target name="javadocs" depends="compile" description="Make the javadocs for the toolkit">
<delete dir="${javadocsdir}"/>
<javadoc destdir="${javadocsdir}">
<packageset dir="${src}">
<include name="**"/>
<exclude name="infodynamics/demos/**"/>
<exclude name="**/commonsmath3/*"/>
<exclude name="**/commonsmath3/**"/>
</packageset>
</javadoc>
<!-- Change some of the style in the javadocs css for our lists: -->
<concat destfile="${javadocsdir}/stylesheet.css" append="true">
.block ul li {list-style:disc; margin-left: 20px;}
.block ol li {list-style:decimal; margin-left: 40px;}
.block ol li ol li {list-style:lower-alpha; margin-left: 40px;}
.block ol li ul li {list-style:disc; margin-left: 40px;}
.block ol li ul li ol li {list-style:lower-alpha; margin-left: 40px;}
.block ol li ol li ol li {list-style:lower-roman; margin-left: 40px;}
.block ul li ol li {list-style:decimal; margin-left: 20px;}
</concat>
</target>
<!-- Clean up -->
<target name="clean">
<!-- Delete the compiled code directories -->
<delete dir="${bin}"/>
<delete dir="${unittestsbin}"/>
<delete dir="${reports.tests}"/>
<delete dir="${unittestsouttoplevel}"/>
<delete dir="${javadocsdir}"/>
<delete dir="demos/clojure/target"/>
<delete file="demos/clojure/pom.xml"/>
<delete file="demos/clojure/pom.xml.asc"/>
<delete file="demos/clojure/project.clj"/>
<delete file="${jarversiondistnamezip}"/>
<delete file="${distnamezip}"/>
<delete file="${distnametargz}"/>
<delete file="${jarplainname}"/>
<delete>
<fileset dir="demos/AutoAnalyser" includes="GeneratedCalculator.*"/>
</delete>
<delete>
<fileset dir="demos/java/infodynamics/demos/autoanalysis" includes="GeneratedCalculator.*"/>
</delete>
<antcall target="gpuclean"/>
<!-- Don't delete the readme and version files - the user may not have the template to recreate them from -->
</target>
<!-- Build the project jar for users -->
<target name="build" depends="jar" description="user: build the project jar file">
<echo message="${ant.project.name}: ${ant.file}"/>
</target>
<!--
***********************************
Developer builds below here
***********************************
-->
<!-- Compile and jar the toolkit with debug symbols -->
<target name="debug" depends="init" description="compile and jar with debug symbols">
<echo message="Compiling for debug"/>
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" debug="true">
<classpath refid="apache-classpath"/>
</javac>
<!-- Compiling Cpp code -->
<antcall target="gpu" if:true="${enablegpu}">
<param name="DEBUG" value="1"/>
</antcall>
<jar jarfile="${jarplainname}" basedir="${bin}"/>
</target>
<!-- Compile GPU code -->
<target name="gpu" depends="init" description="compile only C/C++ GPU code">
<exec executable="make" dir="${cudasrc}" failonerror="true" resultproperty="return.code">
<env key="DEBUG" value="${DEBUG}"/>
</exec>
<fail>
<condition>
<isfailure code="${return.code}"/>
</condition>
</fail>
</target>
<!-- Clean GPU code -->
<target name="gpuclean" description="clean only C/C++ GPU code">
<exec executable="make" dir="${cudasrc}" failonerror="true">
<arg value="clean"/>
</exec>
</target>
<!-- Test GPU code -->
<target name="gputest" depends="gpu, compile" description="compile and run C unit tests for GPU code">
<!-- Compile and run the C-only GPU unit tests -->
<exec executable="make" dir="${cudasrc}" failonerror="true" resultproperty="return.code">
<arg value="test"/>
</exec>
<fail>
<condition>
<isfailure code="${return.code}"/>
</condition>
</fail>
<exec executable="./unittest" dir="${unittestsbin}/cuda/" failonerror="true" resultproperty="return.code"/>
<fail>
<condition>
<isfailure code="${return.code}"/>
</condition>
</fail>
<!-- Compile and run the Java+C GPU tests -->
<javac destdir="${unittestsbin}" includeAntRuntime="true" debug="true">
<src path="${unittestssrc}"/>
<classpath refid="project.classpath"/>
<classpath refid="apache-classpath"/>
</javac>
<junit printsummary="yes" showoutput="yes" fork="true" forkmode="once" haltonfailure="yes" haltonerror="yes" includeantruntime="true">
<classpath>
<path refid="project.classpath"/>
<pathelement path="${unittestsbin}"/>
<pathelement location="${basedir}/clover.jar"/>
</classpath>
<formatter type="plain"/>
<batchtest todir="${reports.tests}"> <!-- Writes full reports with stdout and stderr to ${reports.tests} -->
<fileset dir="${unittestsbin}">
<include name="**/*GPU*.class"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- Developer build - creates readme and version files -->
<target name="readmefiles" description="developer: create the readme and version files from templates">
<tstamp>
<format property="TODAY_DATE" pattern="dd/MM/yyyy" locale="en,UK"/>
<format property="TODAY_YEAR" pattern="yyyy" locale="en,UK"/>
</tstamp>
<copy file="readme-template.txt" toFile="readme.txt" failonerror="false" overwrite="true">
<!-- The template file only exists in SVN - this won't crash ant
if users try to run it though because failonerror="false" -->
<filterset>
<filter token="YEAR" value="${TODAY_YEAR}"/>
<filter token="DATE" value="${TODAY_DATE}"/>
<filter token="VERSION" value="${version}"/>
</filterset>
</copy>
<copy file="version-template.txt" toFile="${versionfile}" failonerror="false">
<!-- The template file only exists in SVN - this won't crash ant
if users try to run it though because failonerror="false" -->
<filterset>
<filter token="YEAR" value="${TODAY_YEAR}"/>
<filter token="DATE" value="${TODAY_DATE}"/>
<filter token="VERSION" value="${version}"/>
</filterset>
</copy>
<copy file="demos/clojure/deploy/project-template.clj" toFile="demos/clojure/deploy/project.clj" failonerror="false" overwrite="true">
<!-- The template file only exists in SVN - this won't crash ant
if users try to run it though because failonerror="false" -->
<filterset>
<filter token="VERSION" value="${version}"/>
</filterset>
</copy>
</target>
<!-- Developer build - builds everything and makes the jar only distribution file -->
<target name="jardist" depends="build,readmefiles" description="developer: generate the jar distribution">
<zip destfile="${jarversiondistnamezip}">
<fileset file="${jarplainname}"/>
<fileset file="license-gplv3.txt"/>
<fileset file="readme.txt"/>
<fileset file="${versionfile}"/>
<zipfileset dir="notices" includes="**/*.*,**/*" prefix="notices"/>
</zip>
</target>
<!-- Developer build - builds everything and makes the full distribution file in zip and tar.gz -->
<target name="dist" depends="jar,junit,javadocs,readmefiles" description="developer: generate the full distribution">
<echo message="${ant.project.name}: ${ant.file}"/>
<zip destfile="${distnamezip}">
<fileset file="build.xml"/>
<zipfileset file="${jarplainname}" filemode="755"/>
<fileset file="license-gplv3.txt"/>
<fileset file="readme.txt"/>
<fileset file="InfoDynamicsToolkit.pdf"/>
<fileset file="JIDT-logo.png" erroronmissingdir="false"/> <!-- This file is missing in full repository versions -->
<fileset file="${versionfile}"/>
<zipfileset dir="java" includes="**/*.java" prefix="java"/>
<zipfileset dir="demos" includes="**/*.*,**/*" excludes="clojure/deploy,clojure/deploy/*.*,python/*.pyc,**/*.sh,**/*.bat" prefix="demos"/>
<zipfileset dir="demos" includes="**/*.sh,**/*.bat" prefix="demos" filemode="755"/> <!-- Do these separately to get executable permissions -->
<zipfileset dir="javadocs" includes="**/*.*,**/*" prefix="javadocs"/>
<zipfileset dir="notices" includes="**/*.*,**/*" prefix="notices"/>
<zipfileset dir="cuda" prefix="cuda" excludes="benchmark.sh"/>
<zipfileset dir="cuda" prefix="cuda" includes="benchmark.sh" filemode="755"/> <!-- Do this separately to get executable permissions -->
<zipfileset dir="course" prefix="course"/>
<zipfileset dir="tutorial" prefix="tutorial"/> <!-- Get rid of this when tutorial is subsumed in course... -->
<zipfileset dir="web" includes="JIDT-logo.png" prefix="" erroronmissingdir="false"/> <!-- This file is missing in zip dist versions -->
</zip>
<tar destfile="${distnametargz}" compression="gzip" longfile="posix"> <!-- for longfiles could also use "gnu" but apparently is slightly less widely supported -->
<zipfileset src="${distnamezip}"/>
</tar>
</target>
</project>