Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.24 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <project name="athena-project-build" default="deploy">
  4.  
  5. <!-- Load Tasks -->
  6. <taskdef resource="net/sf/antcontrib/antlib.xml">
  7. <classpath>
  8. <pathelement location="${wpilib.ant.dir}/ant-contrib.jar"/>
  9. </classpath>
  10. </taskdef>
  11. <taskdef resource="net/jtools/classloadertask/antlib.xml" classpath="${classloadertask.jar}"/>
  12. <classloader loader="system" classpath="${jsch.jar}"/>
  13.  
  14. <target name="clean" description="Clean up all build and distribution artifacts.">
  15. <delete dir="${build.dir}"/>
  16. <delete dir="${dist.dir}"/>
  17. </target>
  18.  
  19. <!-- Targets -->
  20.  
  21. <target name="get-target-ip">
  22. <property name="ant.enable.asserts" value="true"/>
  23. <assert name="team-number" exists="true" message="Team number not set. Go to Window->Preferences->WPILib Preferences to set it."/>
  24. <property name="target" value="roboRIO-${team-number}-FRC.local" />
  25. <echo>Trying Target: ${target}</echo>
  26. <if>
  27. <isreachable host="${target}" timeout="5"/>
  28. <then>
  29. <echo>roboRIO found via mDNS</echo>
  30. </then>
  31. <else>
  32. <var name="target" unset="true"/>
  33. <echo> roboRIO not found via mDNS, falling back to static USB</echo>
  34. <property name="target" value="172.22.11.2"/>
  35. <if>
  36. <isreachable host="${target}" timeout="5"/>
  37. <then>
  38. <echo>roboRIO found via static USB</echo>
  39. </then>
  40. <else>
  41. <var name="target" unset="true"/>
  42. <math result="ip.upper" operand1="${team-number}" operation="/" operand2="100" datatype="int"/>
  43. <math result="ip.lower" operand1="${team-number}" operation="%" operand2="100" datatype="int"/>
  44. <property name="target" value="10.${ip.upper}.${ip.lower}.2"/>
  45. <echo>roboRIO not found via USB, falling back to static address of ${target}</echo>
  46. <assert name="roboRIOFound" message="roboRIO not found, please check that the roboRIO is connected, imaged and that the team number is set properly in Eclipse">
  47. <bool>
  48. <isreachable host="${target}" timeout="5"/>
  49. </bool>
  50. </assert>
  51. <echo>roboRIO found via Ethernet static</echo>
  52. </else>
  53. </if>
  54. </else>
  55. </if>
  56. </target>
  57.  
  58. <target name="compile" description="Compile the source code.">
  59. <mkdir dir="${build.dir}"/>
  60. <property name="userLibs" value=""/>
  61. <echo>[athena-compile] Compiling ${src.dir} with classpath=${classpath}:${userLibs} to ${build.dir}</echo>
  62.  
  63. <javac srcdir="${src.dir}"
  64. destdir="${build.dir}"
  65. includeAntRuntime="no"
  66. includeJavaRuntime="no"
  67. classpath="${classpath}:${userLibs}"
  68. target="${ant.java.version}"
  69. source="${ant.java.version}"
  70. compiler="javac${ant.java.version}"
  71. debug="true">
  72. </javac>
  73. </target>
  74.  
  75. <target name="jar" depends="compile">
  76. <echo>[athena-jar] Making jar ${dist.jar}.</echo>
  77. <mkdir dir="${dist.dir}" />
  78. <mkdir dir="${build.jars}" />
  79.  
  80. <echo>[athena-jar] Copying jars from ${classpath}:${userLibs} to ${build.jars}.</echo>
  81. <copy todir="${build.jars}" flatten="true">
  82. <path>
  83. <pathelement path="${classpath}:${userLibs}"/>
  84. </path>
  85. </copy>
  86.  
  87. <jar destfile="${dist.jar}" update="false">
  88. <manifest>
  89. <attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
  90. <attribute name="Robot-Class" value="${robot.class}"/>
  91. <attribute name="Class-Path" value="."/>
  92. </manifest>
  93.  
  94. <fileset dir="${build.dir}" includes="**/*.class"/>
  95.  
  96. <zipgroupfileset dir="${build.jars}">
  97. <include name="**/*.jar" />
  98. </zipgroupfileset>
  99. </jar>
  100. </target>
  101.  
  102. <!-- We're running a clean here to get around a known ant issue where it does not detected changed constant variables.
  103. To get around this, we're recompiling the entire project, which is not an issue for most teams. If this is an issue
  104. for you, you can remove the clean here, just be sure to do a full rebuild after you've changed any constants.
  105. Reference: http://stackoverflow.com/questions/6430001/ant-doesnt-recompile-constants -->
  106. <target name="deploy" depends="clean,jar,get-target-ip,dependencies" description="Deploy the jar and start the program running.">
  107. <echo>[athena-deploy] Copying code over.</echo>
  108. <scp file="${dist.jar}" todir="admin@${target}:${deploy.dir}" password="" trust="true"/>
  109.  
  110. <!-- Suppress the exit status so that if no netconsole was running then
  111. it doesn't show up red on the output. -->
  112. <sshexec host="${target}"
  113. username=lvuser
  114. password=""
  115. trust="true"
  116. failonerror="false"
  117. command="killall -q netconsole-host || :"/>
  118.  
  119. <scp file="${wpilib.ant.dir}/robotCommand" todir="admin@${target}:${command.dir}" password="" trust="true"/>
  120.  
  121. <echo>[athena-deploy] Starting program.</echo>
  122. <sshexec host="${target}"
  123. username=lvuser
  124. password=""
  125. trust="true"
  126. failonerror="false"
  127. command="${deploy.kill.command};"/>
  128.  
  129. <sshexec host="${target}"
  130. username=lvuser
  131. password=""
  132. trust="true"
  133. command="sync" />
  134.  
  135. </target>
  136.  
  137. <target name="debug-deploy" depends="jar,get-target-ip,dependencies" description="Deploy the jar and start the program running.">
  138. <echo>[athena-deploy] Copying code over.</echo>
  139. <scp file="${dist.jar}" todir="admin@${target}:${deploy.dir}" password="" trust="true"/>
  140. <!-- The remoteDebugCommand file is used by /usr/local/frc/bin/frcRunRobot.sh on the roboRIO -->
  141. <scp file="${wpilib.ant.dir}/robotDebugCommand" todir="admin@${target}:${command.dir}" password="" trust="true"/>
  142. <!-- The frcdebug file is used as a flag for /usr/local/frc/bin/frcRunRobot.sh to run the robot program in debug mode -->
  143. <scp file="${wpilib.ant.dir}/frcdebug" todir="admin@${target}:${debug.flag.dir}" password="" trust="true"/>
  144. <sshexec host="${target}"
  145. username=lvuser
  146. password=""
  147. trust="true"
  148. command="${debug.flag.command}"/>
  149.  
  150. <echo>[athena-deploy] Starting Debug program.</echo>
  151. <sshexec host="${target}"
  152. username=lvuser
  153. password=""
  154. trust="true"
  155. failonerror="false"
  156. command="${deploy.kill.command}"/>
  157.  
  158. </target>
  159.  
  160. <!-- Simulate -->
  161. <target name="jar-for-simulation" depends="compile">
  162. <echo>[jar-for-simulation] Building jar.</echo>
  163.  
  164. <jar destfile="${simulation.dist.jar}">
  165. <manifest>
  166. <attribute name="Built-By" value="${user.name}"/>
  167. <attribute name="Robot-Class" value="${robot.class}"/>
  168. <attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
  169. </manifest>
  170. <fileset dir="${build.dir}" />
  171. <zipgroupfileset dir="${wpilib.sim.lib}">
  172. <include name="**/*.jar" />
  173. </zipgroupfileset>
  174. </jar>
  175. </target>
  176.  
  177. <target name="simulate" depends="jar-for-simulation">
  178. <sequential>
  179. <echo>[simulate] You may now run Gazebo and your DriverStation</echo>
  180. <echo>[simulate] Running Code.</echo>
  181. <java jar="${simulation.dist.jar}" fork="true">
  182. <jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
  183. </java>
  184. </sequential>
  185. </target>
  186.  
  187. <target name="debug-simulate" depends="jar-for-simulation">
  188. <sequential>
  189. <echo>[simulate] You may now run Gazebo and your DriverStation</echo>
  190. <echo>[simulate] Running Code In Debug Mode.</echo>
  191. <java jar="${simulation.dist.jar}" fork="true">
  192. <jvmarg value="-Xdebug" />
  193. <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8348" />
  194. <jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
  195. </java>
  196. </sequential>
  197. </target>
  198.  
  199. <target name="dependencies" depends="get-target-ip">
  200. <property name="ant.enable.asserts" value="true"/>
  201. <post to="http://${target}/nisysapi/server" logfile="sysProps.xml" verbose="false" encoding="UTF-16LE" append="false">
  202. <prop name="Function" value="GetPropertiesOfItem"/>
  203. <prop name="Plugins" value="nisyscfg"/>
  204. <prop name="Items" value="system"/>
  205. </post>
  206. <loadfile srcFile="sysProps.xml" encoding="UTF-16LE" property="roboRIOSysValues"/>
  207. <propertyregex property="roboRIOImage" input="${roboRIOSysValues}" regexp="FRC_roboRIO_2016_v([0-9]+)" select="\1" defaultValue="ImageRegExFail"/>
  208. <propertyregex property="roboRIOImageYear" input="${roboRIOSysValues}" regexp="FRC_roboRIO_([0-9]+)_v" select="\1" defaultValue="ImageRegExFail"/>
  209. <assert message="Image of roboRIO does not match plugin. ${line.separator}Allowed image year: ${roboRIOAllowedYear} version: ${roboRIOAllowedImages}. ${line.separator}Actual image year: ${roboRIOImageYear} version ${roboRIOImage}. ${line.separator}RoboRIO needs to be re-imaged or plugins updated.">
  210. <bool>
  211. <and>
  212. <contains string="${roboRIOAllowedImages}" substring="${roboRIOImage}"/>
  213. <contains string="${roboRIOAllowedYear}" substring="${roboRIOImageYear}"/>
  214. </and>
  215. </bool>
  216. </assert>
  217. <echo>roboRIO image version validated</echo>
  218. <echo>Checking for JRE. If this fails install the JRE using these instructions: https://wpilib.screenstepslive.com/s/4485/m/13503/l/288822-installing-java-8-on-the-roborio-using-the-frc-roborio-java-installer-java-only</echo>
  219. <sshexec host="${target}"
  220. username=lvuser
  221. password=""
  222. trust="true"
  223. failonerror="true"
  224. command="test -d ${roboRIOJRE.dir}"/>
  225. </target>
  226. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement