|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project basedir="." default="build" name="Java Information Dynamics Toolkit" xmlns:if="ant:if"> |
| 3 | + <description> |
| 4 | + Build file for the Java Information Dynamics Toolkit |
| 5 | + </description> |
| 6 | + |
| 7 | + <!-- set global properties for this build --> |
| 8 | + <property name="version" value="1.6.1"/> |
| 9 | + <property name="mainfilename" value="infodynamics"/> |
| 10 | + <property name="jarplainname" value="${mainfilename}.jar" /> |
| 11 | + <property name="jarversiondistnamezip" value="${mainfilename}-jar-${version}.zip" /> |
| 12 | + <property name="distname" value="${mainfilename}-dist-${version}" /> |
| 13 | + <property name="distnamezip" value="${distname}.zip" /> |
| 14 | + <property name="distnametargz" value="${distname}.tar.gz" /> |
| 15 | + <property name="src" location="java/source"/> |
| 16 | + <property name="cudasrc" location="cuda"/> |
| 17 | + <property name="bin" location="bin"/> |
| 18 | + <property name="unittestsouttoplevel" location="unittests"/> |
| 19 | + <property name="unittestssrc" location="java/unittests"/> |
| 20 | + <property name="unittestsbin" location="${unittestsouttoplevel}/bin"/> |
| 21 | + <property name="reports.tests" location="${unittestsouttoplevel}/reports"/> |
| 22 | + <property name="javadocsdir" location="javadocs"/> |
| 23 | + <property name="versionfile" value="version-${version}.txt"/> |
| 24 | + <!-- To enable GPU code, set the following variable to true --> |
| 25 | + <property name="enablegpu" value="false"/> |
| 26 | + |
| 27 | + <path id="project.classpath"> |
| 28 | + <pathelement location="bin"/> |
| 29 | + </path> |
| 30 | + |
| 31 | + <path id="apache-classpath"> |
| 32 | + <pathelement path="./share/commons-math3-3.5.jar"/> |
| 33 | + </path> |
| 34 | + |
| 35 | + <!-- Make required directories --> |
| 36 | + <target name="init" description="Create the compiled code directories"> |
| 37 | + <mkdir dir="${bin}"/> |
| 38 | + <mkdir dir="${bin}/cuda"/> |
| 39 | + <mkdir dir="${unittestsbin}"/> |
| 40 | + <mkdir dir="${unittestsbin}/cuda"/> |
| 41 | + <mkdir dir="${reports.tests}"/> |
| 42 | + </target> |
| 43 | + |
| 44 | + <!-- Compile the java toolkit --> |
| 45 | + <target name="compile" depends="init" description="compile the source"> |
| 46 | + <!-- Compile to Java 7 to provide compatibility for users with older JREs. |
| 47 | + Caveat: The flags here only check the language compatibility, but |
| 48 | + may still use newer libraries which may cause issues for users with JDK 7. |
| 49 | + Indeed, one gets the warning: "bootstrap class path not set in conjunction with -source 1.7" |
| 50 | + To fix this, one would use the bootstrap classpath to point our JDK to an rt.jar |
| 51 | + for Java 7. |
| 52 | + At this stage, I'm sure I'm not using new library calls from Java 8+, so we can |
| 53 | + ignore the warning, and I don't want to bother installing newer Java just to compile |
| 54 | + like this. I'll endeavour not to use JDK 8 libraries so as not to cause |
| 55 | + any issues here ... --> |
| 56 | + <javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" encoding="UTF8"> |
| 57 | + <classpath refid="apache-classpath"/> |
| 58 | + </javac> |
| 59 | + |
| 60 | + <!-- Compiling Cpp code --> |
| 61 | + <antcall target="gpu" if:true="${enablegpu}"> |
| 62 | + <param name="DEBUG" value="0"/> |
| 63 | + </antcall> |
| 64 | + |
| 65 | + </target> |
| 66 | + |
| 67 | + <!-- Jar the toolkit --> |
| 68 | + <target name="jar" depends="compile" description="Create the jar for distribution"> |
| 69 | + <!-- Put everything in ${bin} into the infodynamics-${version}.jar file --> |
| 70 | + <jar jarfile="${jarplainname}" basedir="${bin}" excludes="cuda/*.o,cuda/*.a,cuda/findComputeCapability"> |
| 71 | + <manifest> |
| 72 | + <attribute name="Main-Class" value="infodynamics.demos.autoanalysis.AutoAnalyserLauncher"/> |
| 73 | + </manifest> |
| 74 | + </jar> |
| 75 | + <!-- Set the jar to be runnable: (only has effect on unix/linux) |
| 76 | + so we can double click to run the AutoAnalyser --> |
| 77 | + <chmod file="${jarplainname}" perm="u+x"/> |
| 78 | + </target> |
| 79 | + |
| 80 | + <!-- Compile and run the JUnit tests --> |
| 81 | + <target name="junit" depends="compile" description="Run the junit tests and make sure they compile"> |
| 82 | + |
| 83 | + <!-- Compile the junit tests first --> |
| 84 | + <javac destdir="${unittestsbin}" includeAntRuntime="true" debug="true"> |
| 85 | + <!-- Need includeAntRuntime=true if you want to pick up junit.jar and ant-junit.jar in ANT_HOME/lib; |
| 86 | + Otherwise you will need to set the classpath to include these here. --> |
| 87 | + <src path="${unittestssrc}"/> |
| 88 | + <classpath refid="project.classpath"/> |
| 89 | + <classpath refid="apache-classpath"/> |
| 90 | + </javac> |
| 91 | + |
| 92 | + <!-- Run the junit tests and make sure they complete ok --> |
| 93 | + <junit printsummary="yes" showoutput="yes" fork="true" forkmode="once" haltonfailure="yes" haltonerror="yes" includeantruntime="true"> |
| 94 | + <classpath> |
| 95 | + <path refid="project.classpath"/> |
| 96 | + <pathelement path="${unittestsbin}"/> |
| 97 | + <pathelement location="${basedir}/clover.jar"/> |
| 98 | + </classpath> |
| 99 | + <formatter type="plain"/> |
| 100 | + <batchtest todir="${reports.tests}"> <!-- Writes full reports with stdout and stderr to ${reports.tests} --> |
| 101 | + <fileset dir="${unittestsbin}"> |
| 102 | + <include name="**/*.class"/> |
| 103 | + <exclude name="**/*AbstractTester.class"/> |
| 104 | + <exclude name="**/ActiveInfoStorageCalculatorCorrelationIntegrals.class"/> |
| 105 | + <exclude name="**/ActiveInfoStorageCalculatorKernelDirect.class"/> |
| 106 | + <exclude name="**/*GPU*.class"/> |
| 107 | + </fileset> |
| 108 | + </batchtest> |
| 109 | + </junit> |
| 110 | + |
| 111 | + <!-- If applicable, run also GPU tests --> |
| 112 | + <antcall target="gputest" if:true="${enablegpu}"/> |
| 113 | + </target> |
| 114 | + |
| 115 | + <!-- Make javadocs, excluding the AutoAnalyser and classes we've derived from Apache Commons Math --> |
| 116 | + <target name="javadocs" depends="compile" description="Make the javadocs for the toolkit"> |
| 117 | + <delete dir="${javadocsdir}"/> |
| 118 | + <javadoc destdir="${javadocsdir}"> |
| 119 | + <packageset dir="${src}"> |
| 120 | + <include name="**"/> |
| 121 | + <exclude name="infodynamics/demos/**"/> |
| 122 | + <exclude name="**/commonsmath3/*"/> |
| 123 | + <exclude name="**/commonsmath3/**"/> |
| 124 | + </packageset> |
| 125 | + </javadoc> |
| 126 | + <!-- Change some of the style in the javadocs css for our lists: --> |
| 127 | + <concat destfile="${javadocsdir}/stylesheet.css" append="true"> |
| 128 | + .block ul li {list-style:disc; margin-left: 20px;} |
| 129 | + .block ol li {list-style:decimal; margin-left: 40px;} |
| 130 | + .block ol li ol li {list-style:lower-alpha; margin-left: 40px;} |
| 131 | + .block ol li ul li {list-style:disc; margin-left: 40px;} |
| 132 | + .block ol li ul li ol li {list-style:lower-alpha; margin-left: 40px;} |
| 133 | + .block ol li ol li ol li {list-style:lower-roman; margin-left: 40px;} |
| 134 | + .block ul li ol li {list-style:decimal; margin-left: 20px;} |
| 135 | + </concat> |
| 136 | + </target> |
| 137 | + |
| 138 | + <!-- Clean up --> |
| 139 | + <target name="clean"> |
| 140 | + <!-- Delete the compiled code directories --> |
| 141 | + <delete dir="${bin}"/> |
| 142 | + <delete dir="${unittestsbin}"/> |
| 143 | + <delete dir="${reports.tests}"/> |
| 144 | + <delete dir="${unittestsouttoplevel}"/> |
| 145 | + <delete dir="${javadocsdir}"/> |
| 146 | + <delete dir="demos/clojure/target"/> |
| 147 | + <delete file="demos/clojure/pom.xml"/> |
| 148 | + <delete file="demos/clojure/pom.xml.asc"/> |
| 149 | + <delete file="demos/clojure/project.clj"/> |
| 150 | + <delete file="${jarversiondistnamezip}"/> |
| 151 | + <delete file="${distnamezip}"/> |
| 152 | + <delete file="${distnametargz}"/> |
| 153 | + <delete file="${jarplainname}"/> |
| 154 | + <delete> |
| 155 | + <fileset dir="demos/AutoAnalyser" includes="GeneratedCalculator.*"/> |
| 156 | + </delete> |
| 157 | + <delete> |
| 158 | + <fileset dir="demos/java/infodynamics/demos/autoanalysis" includes="GeneratedCalculator.*"/> |
| 159 | + </delete> |
| 160 | + <antcall target="gpuclean"/> |
| 161 | + <!-- Don't delete the readme and version files - the user may not have the template to recreate them from --> |
| 162 | + </target> |
| 163 | + |
| 164 | + <!-- Build the project jar for users --> |
| 165 | + <target name="build" depends="jar" description="user: build the project jar file"> |
| 166 | + <echo message="${ant.project.name}: ${ant.file}"/> |
| 167 | + </target> |
| 168 | + |
| 169 | + <!-- |
| 170 | + *********************************** |
| 171 | + |
| 172 | + Developer builds below here |
| 173 | + |
| 174 | + *********************************** |
| 175 | + --> |
| 176 | + |
| 177 | + <!-- Compile and jar the toolkit with debug symbols --> |
| 178 | + <target name="debug" depends="init" description="compile and jar with debug symbols"> |
| 179 | + <echo message="Compiling for debug"/> |
| 180 | + <javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" debug="true"> |
| 181 | + <classpath refid="apache-classpath"/> |
| 182 | + </javac> |
| 183 | + |
| 184 | + <!-- Compiling Cpp code --> |
| 185 | + <antcall target="gpu" if:true="${enablegpu}"> |
| 186 | + <param name="DEBUG" value="1"/> |
| 187 | + </antcall> |
| 188 | + |
| 189 | + <jar jarfile="${jarplainname}" basedir="${bin}"/> |
| 190 | + </target> |
| 191 | + |
| 192 | + <!-- Compile GPU code --> |
| 193 | + <target name="gpu" depends="init" description="compile only C/C++ GPU code"> |
| 194 | + <exec executable="make" dir="${cudasrc}" failonerror="true" resultproperty="return.code"> |
| 195 | + <env key="DEBUG" value="${DEBUG}"/> |
| 196 | + </exec> |
| 197 | + <fail> |
| 198 | + <condition> |
| 199 | + <isfailure code="${return.code}"/> |
| 200 | + </condition> |
| 201 | + </fail> |
| 202 | + </target> |
| 203 | + |
| 204 | + <!-- Clean GPU code --> |
| 205 | + <target name="gpuclean" description="clean only C/C++ GPU code"> |
| 206 | + <exec executable="make" dir="${cudasrc}" failonerror="true"> |
| 207 | + <arg value="clean"/> |
| 208 | + </exec> |
| 209 | + </target> |
| 210 | + |
| 211 | + <!-- Test GPU code --> |
| 212 | + <target name="gputest" depends="gpu, compile" description="compile and run C unit tests for GPU code"> |
| 213 | + |
| 214 | + <!-- Compile and run the C-only GPU unit tests --> |
| 215 | + <exec executable="make" dir="${cudasrc}" failonerror="true" resultproperty="return.code"> |
| 216 | + <arg value="test"/> |
| 217 | + </exec> |
| 218 | + <fail> |
| 219 | + <condition> |
| 220 | + <isfailure code="${return.code}"/> |
| 221 | + </condition> |
| 222 | + </fail> |
| 223 | + |
| 224 | + <exec executable="./unittest" dir="${unittestsbin}/cuda/" failonerror="true" resultproperty="return.code"/> |
| 225 | + <fail> |
| 226 | + <condition> |
| 227 | + <isfailure code="${return.code}"/> |
| 228 | + </condition> |
| 229 | + </fail> |
| 230 | + |
| 231 | + <!-- Compile and run the Java+C GPU tests --> |
| 232 | + <javac destdir="${unittestsbin}" includeAntRuntime="true" debug="true"> |
| 233 | + <src path="${unittestssrc}"/> |
| 234 | + <classpath refid="project.classpath"/> |
| 235 | + <classpath refid="apache-classpath"/> |
| 236 | + </javac> |
| 237 | + |
| 238 | + <junit printsummary="yes" showoutput="yes" fork="true" forkmode="once" haltonfailure="yes" haltonerror="yes" includeantruntime="true"> |
| 239 | + <classpath> |
| 240 | + <path refid="project.classpath"/> |
| 241 | + <pathelement path="${unittestsbin}"/> |
| 242 | + <pathelement location="${basedir}/clover.jar"/> |
| 243 | + </classpath> |
| 244 | + <formatter type="plain"/> |
| 245 | + <batchtest todir="${reports.tests}"> <!-- Writes full reports with stdout and stderr to ${reports.tests} --> |
| 246 | + <fileset dir="${unittestsbin}"> |
| 247 | + <include name="**/*GPU*.class"/> |
| 248 | + </fileset> |
| 249 | + </batchtest> |
| 250 | + </junit> |
| 251 | + |
| 252 | + </target> |
| 253 | + |
| 254 | + <!-- Developer build - creates readme and version files --> |
| 255 | + <target name="readmefiles" description="developer: create the readme and version files from templates"> |
| 256 | + <tstamp> |
| 257 | + <format property="TODAY_DATE" pattern="dd/MM/yyyy" locale="en,UK"/> |
| 258 | + <format property="TODAY_YEAR" pattern="yyyy" locale="en,UK"/> |
| 259 | + </tstamp> |
| 260 | + <copy file="readme-template.txt" toFile="readme.txt" failonerror="false" overwrite="true"> |
| 261 | + <!-- The template file only exists in SVN - this won't crash ant |
| 262 | + if users try to run it though because failonerror="false" --> |
| 263 | + <filterset> |
| 264 | + <filter token="YEAR" value="${TODAY_YEAR}"/> |
| 265 | + <filter token="DATE" value="${TODAY_DATE}"/> |
| 266 | + <filter token="VERSION" value="${version}"/> |
| 267 | + </filterset> |
| 268 | + </copy> |
| 269 | + <copy file="version-template.txt" toFile="${versionfile}" failonerror="false"> |
| 270 | + <!-- The template file only exists in SVN - this won't crash ant |
| 271 | + if users try to run it though because failonerror="false" --> |
| 272 | + <filterset> |
| 273 | + <filter token="YEAR" value="${TODAY_YEAR}"/> |
| 274 | + <filter token="DATE" value="${TODAY_DATE}"/> |
| 275 | + <filter token="VERSION" value="${version}"/> |
| 276 | + </filterset> |
| 277 | + </copy> |
| 278 | + <copy file="demos/clojure/deploy/project-template.clj" toFile="demos/clojure/deploy/project.clj" failonerror="false" overwrite="true"> |
| 279 | + <!-- The template file only exists in SVN - this won't crash ant |
| 280 | + if users try to run it though because failonerror="false" --> |
| 281 | + <filterset> |
| 282 | + <filter token="VERSION" value="${version}"/> |
| 283 | + </filterset> |
| 284 | + </copy> |
| 285 | + </target> |
| 286 | + |
| 287 | + <!-- Developer build - builds everything and makes the jar only distribution file --> |
| 288 | + <target name="jardist" depends="build,readmefiles" description="developer: generate the jar distribution"> |
| 289 | + <zip destfile="${jarversiondistnamezip}"> |
| 290 | + <fileset file="${jarplainname}"/> |
| 291 | + <fileset file="license-gplv3.txt"/> |
| 292 | + <fileset file="readme.txt"/> |
| 293 | + <fileset file="${versionfile}"/> |
| 294 | + <zipfileset dir="notices" includes="**/*.*,**/*" prefix="notices"/> |
| 295 | + </zip> |
| 296 | + </target> |
| 297 | + |
| 298 | + <!-- Developer build - builds everything and makes the full distribution file in zip and tar.gz --> |
| 299 | + <target name="dist" depends="jar,junit,javadocs,readmefiles" description="developer: generate the full distribution"> |
| 300 | + <echo message="${ant.project.name}: ${ant.file}"/> |
| 301 | + <zip destfile="${distnamezip}"> |
| 302 | + <fileset file="build.xml"/> |
| 303 | + <zipfileset file="${jarplainname}" filemode="755"/> |
| 304 | + <fileset file="license-gplv3.txt"/> |
| 305 | + <fileset file="readme.txt"/> |
| 306 | + <fileset file="InfoDynamicsToolkit.pdf"/> |
| 307 | + <fileset file="JIDT-logo.png" erroronmissingdir="false"/> <!-- This file is missing in full repository versions --> |
| 308 | + <fileset file="${versionfile}"/> |
| 309 | + <zipfileset dir="java" includes="**/*.java" prefix="java"/> |
| 310 | + <zipfileset dir="demos" includes="**/*.*,**/*" excludes="clojure/deploy,clojure/deploy/*.*,python/*.pyc,**/*.sh,**/*.bat" prefix="demos"/> |
| 311 | + <zipfileset dir="demos" includes="**/*.sh,**/*.bat" prefix="demos" filemode="755"/> <!-- Do these separately to get executable permissions --> |
| 312 | + <zipfileset dir="javadocs" includes="**/*.*,**/*" prefix="javadocs"/> |
| 313 | + <zipfileset dir="notices" includes="**/*.*,**/*" prefix="notices"/> |
| 314 | + <zipfileset dir="cuda" prefix="cuda" excludes="benchmark.sh"/> |
| 315 | + <zipfileset dir="cuda" prefix="cuda" includes="benchmark.sh" filemode="755"/> <!-- Do this separately to get executable permissions --> |
| 316 | + <zipfileset dir="course" prefix="course"/> |
| 317 | + <zipfileset dir="tutorial" prefix="tutorial"/> <!-- Get rid of this when tutorial is subsumed in course... --> |
| 318 | + <zipfileset dir="web" includes="JIDT-logo.png" prefix="" erroronmissingdir="false"/> <!-- This file is missing in zip dist versions --> |
| 319 | + </zip> |
| 320 | + <tar destfile="${distnametargz}" compression="gzip" longfile="posix"> <!-- for longfiles could also use "gnu" but apparently is slightly less widely supported --> |
| 321 | + <zipfileset src="${distnamezip}"/> |
| 322 | + </tar> |
| 323 | + </target> |
| 324 | +</project> |
0 commit comments