- <project name="Ex2P1" default="uploadandrun">
- <description>
- Robot Programming NXT
- </description>
- <!-- set properties for this build -->
- <property environment="env" />
- <property file="build.properties" />
- <!-- check whether nxj.home is correct -->
- <available file="${nxj.home}/lib/pc" property="lejos.pc.exists" />
- <available file="${nxj.home}/lib/nxt" property="lejos.nxt.exists" />
- <fail unless="lejos.pc.exists" message="nxj.home variable incorrect, ${nxj.home}/lib/pc does not exist" />
- <fail unless="lejos.nxt.exists" message="nxj.home variable incorrect, ${nxj.home}/lib/nxt does not exist" />
- <!-- define the search paths -->
- <path id="lejos.pc">
- <fileset dir="${nxj.home}/lib/pc">
- <include name="**/*.jar" />
- </fileset>
- </path>
- <path id="lejos.nxt">
- <fileset dir="${nxj.home}/lib/nxt">
- <include name="**/*.jar" />
- </fileset>
- </path>
- <condition property="d32Flag" value="-d32" else="-Dblank.dummy.arg=">
- <and>
- <os family="mac" />
- </and>
- </condition>
- <!-- deletes generated files -->
- <target name="clean" description="clean up all generated files">
- <delete dir="${build.dir}" />
- </target>
- <target name="compile" depends="clean" description="compile the source ">
- <!-- Compile the java code from ${source.dir} to ${classes.dir} -->
- <mkdir dir="${classes.dir}" />
- <javac
- srcdir="${source.dir}"
- includes="${source.include}"
- excludes="${source.exclude}"
- encoding="${source.encoding}"
- source="${source.version}"
- target="${target.version}"
- destdir="${classes.dir}"
- debug="true"
- includeAntRuntime="false"
- includeJavaRuntime="false"
- verbose="false"
- >
- <bootclasspath refid="lejos.nxt" />
- <!-- enable warnings -->
- <compilerarg value="-Xlint:${source.warn}" />
- <!--
- Without this, there are some JDK jars in the classpath.
- Set verbose=true to check that the classpath is really clean.
- -->
- <compilerarg value="-extdirs" />
- <compilerarg value="" />
- </javac>
- </target>
- <target name="link" depends="compile" description="link the binary ">
- <!-- Link the binary and create a signature file -->
- <java classname="lejos.pc.tools.NXJLink" failonerror="true">
- <classpath refid="lejos.pc" />
- <arg value="--bootclasspath" />
- <arg pathref="lejos.nxt" />
- <arg value="--classpath" />
- <arg path="${classes.dir}" />
- <arg value="--writeorder" />
- <arg value="LE" />
- <arg value="-o" />
- <arg file="${output.nxj}" />
- <arg value="-od" />
- <arg file="${output.nxd}" />
- <arg value="-v" />
- <arg value="${main.class}" />
- </java>
- </target>
- <target name="debuglink" depends="compile" description="link the binary">
- <!-- Link the binary and create a signature file -->
- <java classname="lejos.pc.tools.NXJLink" failonerror="true">
- <classpath refid="lejos.pc" />
- <arg value="--bootclasspath" />
- <arg pathref="lejos.nxt" />
- <arg value="--classpath" />
- <arg path="${classes.dir}" />
- <arg value="--writeorder" />
- <arg value="LE" />
- <arg value="-o" />
- <arg file="${output.nxj}" />
- <arg value="-od" />
- <arg file="${output.nxd}" />
- <arg value="-gr" />
- <arg value="-v" />
- <arg value="${main.class}" />
- </java>
- </target>
- <target name="upload" depends="link" description="upload the binary">
- <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <jvmarg value="${d32Flag}" />
- <classpath refid="lejos.pc" />
- <arg value="${output.nxj}" />
- </java>
- </target>
- <target name="uploadandrun" depends="link" description="upload and run the binary">
- <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <jvmarg value="${d32Flag}" />
- <classpath refid="lejos.pc" />
- <arg value="-b" />
- <arg value="-r" />
- <arg file="${output.nxj}" />
- </java>
- </target>
- <target name="debuguploadandrun" depends="debuglink" description="upload and run the binary">
- <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <jvmarg value="${d32Flag}" />
- <classpath refid="lejos.pc" />
- <arg value="-r" />
- <arg file="${output.nxj}" />
- </java>
- </target>
- <target name="console" depends="debuguploadandrun" description="run a console">
- <sleep seconds="4" />
- <java classname="lejos.pc.tools.NXJConsole" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <jvmarg value="${d32Flag}" />
- <classpath refid="lejos.pc" />
- <arg value="-di" />
- <arg file="${output.nxj}" />
- </java>
- </target>
- <target name="consoleviewer" depends="debuguploadandrun" description="run the GUI Console Viewer">
- <sleep seconds="4" />
- <java classname="lejos.pc.tools.NXJConsoleViewer" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <jvmarg value="${d32Flag}" />
- <classpath refid="lejos.pc" />
- <arg value="-di" />
- <arg file="${output.nxd}" />
- </java>
- </target>
- <target name="debugtool" description="run the debug tool">
- <input
- message="Exception class:"
- addproperty="class"
- />
- <input
- message="Method number:"
- addproperty="method"
- />
- <input
- message="PC value:"
- addproperty="pc"
- />
- <java classname="lejos.pc.tools.NXJDebugTool" fork="true" failonerror="true">
- <sysproperty key="nxj.home" file="${nxj.home}"/>
- <classpath refid="lejos.pc" />
- <arg value="-di" />
- <arg file="${output.nxd}" />
- <arg value="-c" />
- <arg value="-m" />
- <arg value="${class}" />
- <arg value="${method}" />
- <arg value="${pc}" />
- </java>
- </target>
- <!-- generate javadocs -->
- <target name="docs" description="generate javadocs">
- <delete dir="${docs.dir}" />
- <mkdir dir="${docs.dir}" />
- <javadoc
- destdir="${docs.dir}"
- source="${source.version}"
- encoding="${source.encoding}"
- charset="utf-8"
- locale="en_US"
- author="true"
- access="protected"
- windowtitle="Project documentation"
- verbose="false"
- >
- <bootclasspath refid="lejos.nxt" />
- <!--
- Without this, there are some JDK jars in the classpath.
- Set verbose=true to check that the classpath is really clean.
- -->
- <arg value="-extdirs" />
- <arg value="" />
- <packageset dir="${source.dir}"
- includes="${source.include}"
- excludes="${source.exclude}"
- />
- </javadoc>
- </target>
- <!-- zip the project -->
- <target name="dist.zip" description="generate zip of sources">
- <zip
- destfile="${dist.zip}"
- basedir="${basedir}"
- includes="${dist.include}"
- excludes="${dist.exclude}"
- />
- </target>
- </project>