1. <project name="Ex2P1" default="uploadandrun">
  2. <description>
  3. Robot Programming NXT
  4. </description>
  5. <!-- set properties for this build -->
  6. <property environment="env" />
  7. <property file="build.properties" />
  8. <!-- check whether nxj.home is correct -->
  9. <available file="${nxj.home}/lib/pc" property="lejos.pc.exists" />
  10. <available file="${nxj.home}/lib/nxt" property="lejos.nxt.exists" />
  11. <fail unless="lejos.pc.exists" message="nxj.home variable incorrect, ${nxj.home}/lib/pc does not exist" />
  12. <fail unless="lejos.nxt.exists" message="nxj.home variable incorrect, ${nxj.home}/lib/nxt does not exist" />
  13. <!-- define the search paths -->
  14. <path id="lejos.pc">
  15. <fileset dir="${nxj.home}/lib/pc">
  16. <include name="**/*.jar" />
  17. </fileset>
  18. </path>
  19. <path id="lejos.nxt">
  20. <fileset dir="${nxj.home}/lib/nxt">
  21. <include name="**/*.jar" />
  22. </fileset>
  23. </path>
  24. <condition property="d32Flag" value="-d32" else="-Dblank.dummy.arg=">
  25. <and>
  26. <os family="mac" />
  27. </and>
  28. </condition>
  29. <!-- deletes generated files -->
  30. <target name="clean" description="clean up all generated files">
  31. <delete dir="${build.dir}" />
  32. </target>
  33. <target name="compile" depends="clean" description="compile the source ">
  34. <!-- Compile the java code from ${source.dir} to ${classes.dir} -->
  35. <mkdir dir="${classes.dir}" />
  36. <javac
  37. srcdir="${source.dir}"
  38. includes="${source.include}"
  39. excludes="${source.exclude}"
  40. encoding="${source.encoding}"
  41. source="${source.version}"
  42. target="${target.version}"
  43. destdir="${classes.dir}"
  44. debug="true"
  45. includeAntRuntime="false"
  46. includeJavaRuntime="false"
  47. verbose="false"
  48. >
  49. <bootclasspath refid="lejos.nxt" />
  50. <!-- enable warnings -->
  51. <compilerarg value="-Xlint:${source.warn}" />
  52. <!--
  53. Without this, there are some JDK jars in the classpath.
  54. Set verbose=true to check that the classpath is really clean.
  55. -->
  56. <compilerarg value="-extdirs" />
  57. <compilerarg value="" />
  58. </javac>
  59. </target>
  60. <target name="link" depends="compile" description="link the binary ">
  61. <!-- Link the binary and create a signature file -->
  62. <java classname="lejos.pc.tools.NXJLink" failonerror="true">
  63. <classpath refid="lejos.pc" />
  64. <arg value="--bootclasspath" />
  65. <arg pathref="lejos.nxt" />
  66. <arg value="--classpath" />
  67. <arg path="${classes.dir}" />
  68. <arg value="--writeorder" />
  69. <arg value="LE" />
  70. <arg value="-o" />
  71. <arg file="${output.nxj}" />
  72. <arg value="-od" />
  73. <arg file="${output.nxd}" />
  74. <arg value="-v" />
  75. <arg value="${main.class}" />
  76. </java>
  77. </target>
  78. <target name="debuglink" depends="compile" description="link the binary">
  79. <!-- Link the binary and create a signature file -->
  80. <java classname="lejos.pc.tools.NXJLink" failonerror="true">
  81. <classpath refid="lejos.pc" />
  82. <arg value="--bootclasspath" />
  83. <arg pathref="lejos.nxt" />
  84. <arg value="--classpath" />
  85. <arg path="${classes.dir}" />
  86. <arg value="--writeorder" />
  87. <arg value="LE" />
  88. <arg value="-o" />
  89. <arg file="${output.nxj}" />
  90. <arg value="-od" />
  91. <arg file="${output.nxd}" />
  92. <arg value="-gr" />
  93. <arg value="-v" />
  94. <arg value="${main.class}" />
  95. </java>
  96. </target>
  97. <target name="upload" depends="link" description="upload the binary">
  98. <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
  99. <sysproperty key="nxj.home" file="${nxj.home}"/>
  100. <jvmarg value="${d32Flag}" />
  101. <classpath refid="lejos.pc" />
  102. <arg value="${output.nxj}" />
  103. </java>
  104. </target>
  105. <target name="uploadandrun" depends="link" description="upload and run the binary">
  106. <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
  107. <sysproperty key="nxj.home" file="${nxj.home}"/>
  108. <jvmarg value="${d32Flag}" />
  109. <classpath refid="lejos.pc" />
  110. <arg value="-b" />
  111. <arg value="-r" />
  112. <arg file="${output.nxj}" />
  113. </java>
  114. </target>
  115. <target name="debuguploadandrun" depends="debuglink" description="upload and run the binary">
  116. <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
  117. <sysproperty key="nxj.home" file="${nxj.home}"/>
  118. <jvmarg value="${d32Flag}" />
  119. <classpath refid="lejos.pc" />
  120. <arg value="-r" />
  121. <arg file="${output.nxj}" />
  122. </java>
  123. </target>
  124. <target name="console" depends="debuguploadandrun" description="run a console">
  125. <sleep seconds="4" />
  126. <java classname="lejos.pc.tools.NXJConsole" fork="true" failonerror="true">
  127. <sysproperty key="nxj.home" file="${nxj.home}"/>
  128. <jvmarg value="${d32Flag}" />
  129. <classpath refid="lejos.pc" />
  130. <arg value="-di" />
  131. <arg file="${output.nxj}" />
  132. </java>
  133. </target>
  134. <target name="consoleviewer" depends="debuguploadandrun" description="run the GUI Console Viewer">
  135. <sleep seconds="4" />
  136. <java classname="lejos.pc.tools.NXJConsoleViewer" fork="true" failonerror="true">
  137. <sysproperty key="nxj.home" file="${nxj.home}"/>
  138. <jvmarg value="${d32Flag}" />
  139. <classpath refid="lejos.pc" />
  140. <arg value="-di" />
  141. <arg file="${output.nxd}" />
  142. </java>
  143. </target>
  144. <target name="debugtool" description="run the debug tool">
  145. <input
  146. message="Exception class:"
  147. addproperty="class"
  148. />
  149. <input
  150. message="Method number:"
  151. addproperty="method"
  152. />
  153. <input
  154. message="PC value:"
  155. addproperty="pc"
  156. />
  157. <java classname="lejos.pc.tools.NXJDebugTool" fork="true" failonerror="true">
  158. <sysproperty key="nxj.home" file="${nxj.home}"/>
  159. <classpath refid="lejos.pc" />
  160. <arg value="-di" />
  161. <arg file="${output.nxd}" />
  162. <arg value="-c" />
  163. <arg value="-m" />
  164. <arg value="${class}" />
  165. <arg value="${method}" />
  166. <arg value="${pc}" />
  167. </java>
  168. </target>
  169. <!-- generate javadocs -->
  170. <target name="docs" description="generate javadocs">
  171. <delete dir="${docs.dir}" />
  172. <mkdir dir="${docs.dir}" />
  173. <javadoc
  174. destdir="${docs.dir}"
  175. source="${source.version}"
  176. encoding="${source.encoding}"
  177. charset="utf-8"
  178. locale="en_US"
  179. author="true"
  180. access="protected"
  181. windowtitle="Project documentation"
  182. verbose="false"
  183. >
  184. <bootclasspath refid="lejos.nxt" />
  185. <!--
  186. Without this, there are some JDK jars in the classpath.
  187. Set verbose=true to check that the classpath is really clean.
  188. -->
  189. <arg value="-extdirs" />
  190. <arg value="" />
  191. <packageset dir="${source.dir}"
  192. includes="${source.include}"
  193. excludes="${source.exclude}"
  194. />
  195. </javadoc>
  196. </target>
  197. <!-- zip the project -->
  198. <target name="dist.zip" description="generate zip of sources">
  199. <zip
  200. destfile="${dist.zip}"
  201. basedir="${basedir}"
  202. includes="${dist.include}"
  203. excludes="${dist.exclude}"
  204. />
  205. </target>
  206. </project>