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
|
<?xml version="1.0"?>
<project name="Arduino PDE" xmlns:if="ant:if" xmlns:unless="ant:unless" default="build">
<path id="class.path">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${env.JAVA_HOME}/lib/tools.jar"/>
<pathelement path="../arduino-core/arduino-core.jar"/>
</path>
<path id="class.path.test">
<path refid="class.path"/>
<pathelement location="bin/"/>
<fileset dir="test-lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean" description="Clean the build directories">
<delete dir="bin" />
<delete dir="test-bin" />
<delete file="pde.jar" />
</target>
<target name="compile" description="Compile sources">
<condition property="core-built">
<available file="../arduino-core/arduino-core.jar" />
</condition>
<fail unless="core-built" message="Please build the Arduino-core library first and make sure it sits in ../arduino-core/arduino-core.jar" />
<mkdir dir="bin" />
<!-- ant seems to nuke ${java.home} for some reason, pointing at the JRE
subfolder instead of the actual JDK found at JAVA_HOME.
To avoid this, we grab the actual JAVA_HOME environment variable
and use that to specify the location of tools.jar. -->
<!-- if someone is better with ant please help clean this up -->
<property environment="env" />
<property name="java_home" value="${env.JAVA_HOME}" />
<condition property="linux"><os family="unix" /></condition>
<fail if="linux" unless="java_home"
message="The JAVA_HOME variable must be set to the location of a full JDK. For instance, on Ubuntu Linux, this might be /usr/lib/jvm/java-6-sun." />
<condition property="windows"><os family="windows" /></condition>
<fail if="windows" unless="java_home"
message="The JAVA_HOME variable must be set to the location of a full JDK. For instance, on Windows, this might be c:\jdk1.6.0_18." />
<condition property="work.dir" value="../build/macosx/work/Arduino.app/Contents/Java/">
<os family="mac"/>
</condition>
<condition property="java.additional.library.path" value=".">
<os family="mac"/>
</condition>
<condition property="work.dir" value="../build/windows/work/">
<os family="windows"/>
</condition>
<condition property="java.additional.library.path" value=".">
<os family="windows"/>
</condition>
<condition property="work.dir" value="../build/linux/work/">
<os family="unix"/>
</condition>
<condition property="java.additional.library.path" value="lib">
<os family="unix"/>
</condition>
<!--
<dirname property="blah" file="${java.home}" />
<echo message="here! ${java.home}/lib/tools.jar or there: ${blah}" />
<echo message="override ${env.JAVA_HOME}/lib/tools.jar" />
<fail />
-->
<javac source="1.8" target="1.8"
srcdir="src"
destdir="bin"
encoding="UTF-8"
includeAntRuntime="false"
debug="true"
classpathref="class.path" />
</target>
<target name="test" depends="compile" description="Runs the test">
<mkdir dir="test-bin"/>
<javac source="1.8" target="1.8"
srcdir="test"
destdir="test-bin"
encoding="UTF-8"
includeAntRuntime="false"
debug="true"
classpathref="class.path.test">
</javac>
<copy todir="test-bin" overwrite="true" verbose="true">
<fileset dir="test" includes="**/*.zip" />
<fileset dir="test" includes="**/*.txt" />
<fileset dir="test" includes="**/*.properties" />
<fileset dir="test" includes="**/*.ino" />
<fileset dir="test" includes="**/*.json*" />
<fileset dir="test" includes="**/*.key" />
<fileset dir="test" includes="**/*.hex" />
<fileset dir="test" includes="**/*.pac" />
</copy>
<!-- XML and TXT reports will be written here -->
<property name="test.reportdir" value="test-bin/results"/>
<!-- Summary HTML report will be written here -->
<property name="test.htmldir" value="test-bin/results/html"/>
<!-- Remove the reportdir, so the HTML report only includes tests from this run -->
<delete dir="${test.reportdir}" />
<mkdir dir="${test.reportdir}"/>
<mkdir dir="${test.htmldir}"/>
<!-- Sanity check: when single-test-methods is set, but single-test-class is not, raise an error -->
<fail message="Need single-test-class if single-test-methods is set" if="single-test-methods" unless="single-test-class"/>
<junit printsummary="yes" dir="${work.dir}" fork="true" showoutput="no" failureproperty="test.failed">
<jvmarg value="-Djava.library.path=${java.additional.library.path}"/>
<jvmarg value="-DWORK_DIR=."/>
<jvmarg value="-ea"/>
<classpath>
<pathelement location="bin"/>
<pathelement location="test-bin"/>
<pathelement location="${work.dir}/lib/jna-4.2.2.jar"/>
<pathelement location="${work.dir}/lib/jna-platform-4.2.2.jar"/>
<path refid="class.path.test"/>
</classpath>
<!-- Write XML files (for report-generation) and TXT files (for manual review) for every test class -->
<formatter type="plain" />
<formatter type="xml"/>
<!-- Print full details to stdout when running a single test -->
<formatter type="plain" usefile="false" if="single-test-class"/>
<!-- When running all tests, print details for failing tests and a summary for each test class (printsummary=yes above) -->
<formatter type="brief" usefile="false" unless="single-test-class"/>
<!-- When both single-test-class and single-test-methods are specified, pass both to unit -->
<test name="${single-test-class}" methods="${single-test-methods}" todir="${test.reportdir}" if="single-test-methods"/>
<!-- When just single-test-class is specified, omit methods to run the entire class -->
<test name="${single-test-class}" todir="${test.reportdir}" if="single-test-class" unless="single-test-methods"/>
<!-- When neither are specified, run *all* testcases -->
<batchtest fork="yes" todir="${test.reportdir}" unless="single-test-class">
<fileset dir="test">
<include name="**/*Test.java"/>
<exclude name="**/Abstract*.java"/>
</fileset>
</batchtest>
</junit>
<!-- Convert generated XML reports to browsable HTML -->
<junitreport todir="${test.reportdir}">
<fileset dir="${test.reportdir}">
<include name="TEST-*.xml" />
</fileset>
<!-- Create a browsable frame-based HTML -->
<report format="frames" todir="${test.htmldir}" />
<!-- Also create a single-page version, to use as CI test result -->
<report format="noframes" todir="${test.htmldir}" />
</junitreport>
<!-- Make these paths relative to user.dir, which is the current directory when invoking ant (so the resulting paths are relative to the environment of the user. -->
<property name="test.htmldir.display" location="${test.htmldir}" relative="true" basedir="${user.dir}"/>
<property name="test.reportdir.display" location="${test.reportdir}" relative="true" basedir="${user.dir}"/>
<echo unless:set="running-from-github-action" message="Detailed test results can be found in ${test.reportdir.display}"/>
<echo unless:set="running-from-github-action" message="A browsable HTML summary is generated in ${test.htmldir.display}/index.html"/>
<echo if:set="running-from-github-action" message="Detailed test results can be downloaded as an asset from this github action. Easiest to view is the single-file version in junit-noframes.html. Alternatively, the multi-file version can be viewed from index.html and includes full stdout/stderr output of tests."/>
<fail if="test.failed"/>
</target>
<target name="build" depends="compile" description="Build PDE">
<jar basedir="bin" destfile="pde.jar" />
</target>
</project>
|