1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00
Arduino/build/build.xml
2015-03-27 14:51:13 +01:00

995 lines
40 KiB
XML

<?xml version="1.0"?>
<project name="Arduino" default="build">
<!--echo message="os.name = ${os.name}" /-->
<!--echo message="os.arch = ${os.arch}" /-->
<!--echo message="os.version = ${os.version}" /-->
<!-- Sets properties for macosx/windows/linux depending on current system -->
<condition property="platform" value="macosx-old">
<and>
<os family="mac" />
<matches string="${os.version}" pattern="^10.[56]." />
</and>
</condition>
<condition property="platform" value="macosx"><os family="mac" /></condition>
<condition property="platform" value="windows"><os family="windows" /></condition>
<condition property="platform" value="linux32"><os family="unix" arch="i386" /></condition>
<condition property="platform" value="linux64"><os family="unix" arch="amd64" /></condition>
<condition property="macosx"><equals arg1="${platform}" arg2="macosx-old" /></condition>
<condition property="macosx"><equals arg1="${platform}" arg2="macosx" /></condition>
<condition property="windows"><equals arg1="${platform}" arg2="windows" /></condition>
<condition property="linux32"><equals arg1="${platform}" arg2="linux32" /></condition>
<condition property="linux64"><equals arg1="${platform}" arg2="linux64" /></condition>
<condition property="linux"><equals arg1="${platform}" arg2="linux32" /></condition>
<condition property="linux"><equals arg1="${platform}" arg2="linux64" /></condition>
<condition property="staging_folder" value="macosx"><equals arg1="${platform}" arg2="macosx" /></condition>
<condition property="staging_folder" value="macosx"><equals arg1="${platform}" arg2="macosx-old" /></condition>
<condition property="staging_folder" value="windows"><equals arg1="${platform}" arg2="windows" /></condition>
<condition property="staging_folder" value="linux"><equals arg1="${platform}" arg2="linux32" /></condition>
<condition property="staging_folder" value="linux"><equals arg1="${platform}" arg2="linux64" /></condition>
<condition property="staging_hardware_folder" value="Arduino.app/Contents/Java/hardware"><equals arg1="${platform}" arg2="macosx" /></condition>
<condition property="staging_hardware_folder" value="Arduino.app/Contents/Resources/Java/hardware"><equals arg1="${platform}" arg2="macosx-old" /></condition>
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="windows" /></condition>
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linux32" /></condition>
<condition property="staging_hardware_folder" value="hardware"><equals arg1="${platform}" arg2="linux64" /></condition>
<condition property="arch-bits" value="32">
<equals arg1="${platform}" arg2="linux32"/>
</condition>
<condition property="arch-bits" value="64">
<equals arg1="${platform}" arg2="linux64"/>
</condition>
<condition property="launch4j-download-unpack-target-name" value="launch4j-windows"><os family="windows" /></condition>
<property name="launch4j-download-unpack-target-name" value="launch4j-linux"/>
<!-- Libraries required for running arduino -->
<fileset dir=".." id="runtime.jars">
<include name="arduino-core/arduino-core.jar" />
<include name="app/pde.jar" />
<include name="app/lib/*.jar" />
</fileset>
<target name="build" description="Build Arduino.">
<antcall target="${platform}-build" />
</target>
<target name="run" description="Run Arduino.">
<antcall target="${platform}-run" />
</target>
<target name="dist" depends="revision-check"
description="Build Arduino for distribution.">
<input message="Enter version number:"
addproperty="version"
defaultvalue="${revision}" />
<antcall target="${platform}-dist" />
</target>
<!-- "§$§$&, ant doesn't have a built-in help target :( -->
<target name="help" description="Show project help">
<java classname="org.apache.tools.ant.Main">
<arg value="-p" />
</java>
</target>
<target name="test" depends="subprojects-test"/>
<!-- - - - - - - - - - - - - - - - - - -->
<!-- Subprojects: Core, App, Libraries -->
<!-- - - - - - - - - - - - - - - - - - -->
<target name="subprojects-clean">
<subant buildpath="../arduino-core" target="clean"/>
<subant buildpath="../app" target="clean"/>
</target>
<target name="subprojects-build">
<subant buildpath="../arduino-core" target="build"/>
<subant buildpath="../app" target="build"/>
</target>
<target name="subprojects-test">
<subant buildpath="../app" target="test"/>
</target>
<!-- - - - - - - - - -->
<!-- Basic Assembly -->
<!-- - - - - - - - - -->
<target name="assemble">
<fail unless="target.path" message="Do not call assemble from the command line." />
<!-- copy shared tools folder -->
<copy todir="${target.path}/tools">
<fileset dir="shared/tools" />
</copy>
<antcall target="assemble-hardware" />
<!-- copy shared examples folder -->
<copy todir="${target.path}/examples">
<fileset dir="shared/examples" />
</copy>
<!-- Unzip documentation -->
<antcall target="unzip">
<param name="archive_file" value="shared/reference-1.6.0.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/reference-1.6.0.zip" />
<param name="final_folder" value="${target.path}/reference" />
<param name="dest_folder" value="${target.path}" />
</antcall>
<!-- Write the revision file! -->
<echo file="${target.path}/lib/version.txt" message="${version}" />
<antcall target="assemble-libraries" />
</target>
<!-- copy library folder -->
<target name="assemble-libraries" unless="light_bundle">
<copy todir="${target.path}/libraries">
<fileset dir="../libraries" />
</copy>
</target>
<!-- copy hardware folder -->
<target name="assemble-hardware" unless="light_bundle">
<mkdir dir="${staging_folder}/work/dist/bundled_package/packages/arduino/hardware/avr/1.6.1-beta1/"/>
<copy todir="${staging_folder}/work/dist/bundled_package/packages/arduino/hardware/avr/1.6.1-beta1/">
<fileset dir="../hardware/arduino/avr/"/>
</copy>
</target>
<!-- - - - - - - - - -->
<!-- Revision check -->
<!-- - - - - - - - - -->
<target name="revision-check">
<!-- figure out the revision number -->
<loadfile srcfile="shared/revisions.txt" property="revision">
<filterchain>
<ignoreblank />
<headfilter lines="1"/>
<tokenfilter>
<linetokenizer includeDelims="false" />
<!-- grab the thing from the first line that's 4 digits -->
<containsregex pattern="ARDUINO ([^ ]*)" />
<replaceregex pattern="ARDUINO ([^ ]*).*" replace="\1" />
</tokenfilter>
<tokenfilter>
<stringtokenizer suppressdelims="true" />
</tokenfilter>
</filterchain>
</loadfile>
<echo message="Latest revision detected in shared/revision.txt is: ${revision}" />
<!-- figure out the revision number in base.java -->
<loadfile srcfile="../arduino-core/src/processing/app/BaseNoGui.java"
property="revision.base">
<filterchain>
<tokenfilter>
<linetokenizer />
<containsregex pattern="String VERSION_NAME = "/>
<replaceregex pattern=".*&quot;(.*)&quot;.*" flags="g" replace="\1"/>
</tokenfilter>
</filterchain>
</loadfile>
<echo message=" Revision in BaseNoGui.java is: ${revision.base}" />
</target>
<!-- - - - - - - - -->
<!-- Mac OS X -->
<!-- - - - - - - - -->
<target name="macosx-clean" depends="macosx-old-clean" description="Clean Mac OS X build"/>
<target name="macosx-old-clean" depends="subprojects-clean" description="Clean Mac OS X build">
<delete dir="macosx/work" />
<delete dir="macosx/working_dir" />
<delete dir="macosx/working.dmg" />
<delete file="macosx/arduino-*.dmg" />
<delete>
<fileset dir="macosx" includes="arduino-*macosx*.zip"/>
</delete>
</target>
<target name="macosx-checkos" unless="macosx">
<echo>
=======================================================
Arduino for Mac OS X can only be built on Mac OS X.
Bye.
=======================================================
</echo>
<fail message="wrong platform (${os.name})" />
</target>
<target name="macosx-old-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build" description="Build Mac OS X version">
<mkdir dir="macosx/work" />
<mkdir dir="macosx/work/${staging_hardware_folder}" />
<!-- assemble the pde -->
<copy todir="macosx/work/Arduino.app">
<fileset dir="macosx/template.app" includes="**"/>
</copy>
<chmod file="macosx/work/Arduino.app/Contents/MacOS/JavaApplicationStub" perm="755" />
<copy todir="macosx/work/Arduino.app/Contents/Resources/Java" flatten="true">
<fileset refid="runtime.jars"/>
</copy>
<copy todir="macosx/work/Arduino.app/Contents/Resources/Java">
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />
</copy>
<antcall target="macosx-build-common"/>
<replace file="macosx/work/Arduino.app/Contents/Info.plist"
token="VERSION" value="${version}" />
<replace file="macosx/work/Arduino.app/Contents/Info.plist"
token="REVISION" value="${revision}" />
</target>
<target name="macosx-build" if="macosx" depends="revision-check, macosx-checkos, subprojects-build" description="Build Mac OS X version">
<fail unless="MACOSX_BUNDLED_JVM" message="MacOSX requires MACOSX_BUNDLED_JVM property set"/>
<mkdir dir="${staging_folder}/work" />
<antcall target="unzip">
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea-upstream1.jar.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/appbundler-1.0ea-upstream1.jar.zip" />
<param name="final_folder" value="${staging_folder}/appbundler-1.0ea-upstream1" />
<param name="dest_folder" value="${staging_folder}/appbundler-1.0ea-upstream1" />
</antcall>
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="${staging_folder}/appbundler-1.0ea-upstream1/appbundler-1.0ea-upstream1.jar"/>
<bundleapp
jvmRequired="1.8"
outputdirectory="${staging_folder}/work"
name="Arduino"
displayname="Arduino"
executablename="Arduino"
identifier="cc.arduino.Arduino"
shortversion="${version}"
version="${revision}"
signature="Pde1"
icon="macosx/template.app/Contents/Resources/processing.icns"
mainclassname="processing.app.Base"
copyright="Arduino LLC"
minimumsystemversion="10.7"
highresolutioncapable="true">
<runtime dir="${MACOSX_BUNDLED_JVM}"/>
<arch name="x86_64"/>
<arch name="i386"/>
<classpath refid="runtime.jars"/>
<option value="-Dapple.awt.application.name=Arduino" />
<option value="-Dapple.laf.useScreenMenuBar=true"/>
<option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
<option value="-Dcom.apple.smallTabs=true"/>
<option value="-Dcom.apple.macos.useScreenMenuBar=true" />
<!--
<option value="-Dapple.awt.showGrowBox=false"/>
<option value="-Dapple.awt.Antialiasing=false"/>
<option value="-Dapple.awt.TextAntialiasing=true"/>
<option value="-Dcom.apple.hwaccel=true"/>
<option value="-Dapple.awt.graphics.UseQuartz=true"/>
-->
<!--<option value="-Dcom.apple.macos.useScreenMenuBar=true"/>-->
<!-- Workaround since the icon parameter for bundleapp doesn't work -->
<option value="-Xdock:name=Arduino"/>
<option value="-Dcom.apple.mrj.application.apple.menu.about.name=Arduino"/>
<option value="-Dfile.encoding=UTF-8"/>
<option value="-Xms128M"/>
<option value="-Xmx512M"/>
<option value="-splash:$APP_ROOT/Contents/Java/lib/splash.png"/>
<bundledocument extensions="ino,c,cpp,h"
icon="macosx/template.app/Contents/Resources/pde.icns"
name="Arduino Source File"
role="Editor">
</bundledocument>
</bundleapp>
<mkdir dir="${staging_folder}/work/${staging_hardware_folder}" />
<copy todir="${staging_folder}/work/${staging_hardware_folder}/../">
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />
</copy>
<antcall target="macosx-build-common"/>
</target>
<target name="macosx-build-common">
<mkdir dir="${staging_folder}/work" />
<mkdir dir="${staging_folder}/work/${staging_hardware_folder}" />
<antcall target="macosx-build-common-avr-toolchain" />
<antcall target="assemble">
<param name="target.path" value="${staging_folder}/work/${staging_hardware_folder}/.." />
</antcall>
<antcall target="macosx-assemble-bundled-toolchain"/>
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/libastylej-2.05.zip" />
<param name="final_folder" value="${staging_folder}/libastylej" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="macosx/libastylej/libastylej.jnilib" todir="macosx/work/${staging_hardware_folder}/../lib/" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../lib/libastylej.jnilib" />
<copy file="macosx/libastylej/libastylej.jnilib" tofile="macosx/work/${staging_hardware_folder}/../lib/libastylej.dylib" />
<chmod perm="755" file="macosx/work/${staging_hardware_folder}/../lib/libastylej.dylib" />
</target>
<!-- Unzip AVR tools -->
<target name="macosx-build-common-avr-toolchain" unless="light_bundle">
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
<param name="gcc_archive_file" value="avr-gcc-4.8.1-arduino-i386-apple-darwin11.tar.bz2"/>
<param name="gcc_version" value="4.8.1-arduino/"/>
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino-i386-apple-darwin11.tar.bz2"/>
<param name="avrdude_version" value="6.0.1-arduino"/>
</antcall>
<chmod perm="+x">
<fileset dir="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/" includes="**/bin/*"/>
<fileset dir="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/" includes="**/libexec/gcc/avr/4.8.1/*"/>
</chmod>
</target>
<target name="macosx-assemble-bundled-toolchain" unless="light_bundle">
<exec executable="tar" dir="${staging_folder}/work/dist/bundled_package/">
<arg value="-c"/>
<arg value="-z"/>
<arg value="-f"/>
<arg value="../default_package.tar.gz"/>
<arg value="./"/>
</exec>
<mkdir dir="macosx/work/${staging_hardware_folder}/../dist"/>
<move file="${staging_folder}/work/dist/default_package.tar.gz" todir="macosx/work/${staging_hardware_folder}/../dist"/>
<delete dir="${staging_folder}/work/dist/"/>
</target>
<target name="macosx-old-run" depends="macosx-old-build" description="Run Mac OS X version">
<antcall target="macosx-run-common"/>
</target>
<target name="macosx-run" depends="macosx-build" description="Run Mac OS X version">
<antcall target="macosx-run-common"/>
</target>
<target name="macosx-old-debug" depends="macosx-old-build" description="Run Mac OS X version">
<antcall target="macosx-debug-common"/>
</target>
<target name="macosx-debug" depends="macosx-build" description="Run Mac OS X version">
<antcall target="macosx-debug-common"/>
</target>
<target name="macosx-run-common">
<exec executable="open" dir="macosx/work">
<arg value="Arduino.app"/>
</exec>
</target>
<target name="macosx-debug-common">
<exec executable="open" dir="macosx/work" spawn="false">
<arg value="Arduino.app"/>
</exec>
</target>
<!-- - - - - - - - - - - - - - - - -->
<!-- Sign application for MacOSX. -->
<!-- - - - - - - - - - - - - - - - -->
<target name="macosx-signed-dist" if="macosx" depends="macosx-singed-dist-check, dist"
description="Create a downloadable and signed .zip for the Mac OS X version">
<fail unless="version" message="Please set the property 'version' to correctly sign distribution file" />
<!-- Remove everything from working folder -->
<delete dir="macosx/work/Arduino.app" />
<!-- Unzip unsigned app into working dir -->
<exec executable="unzip" dir="macosx/work">
<arg line="../arduino-${version}-${platform}.zip" />
</exec>
<!-- Unlock keychain file -->
<exec executable="security" dir="macosx/work">
<arg line="unlock-keychain -p &quot;${macosx-sign-keychain-pass}&quot; &quot;${macosx-sign-keychain}&quot;" />
</exec>
<!-- Sign app -->
<exec executable="codesign" dir="macosx/work">
<arg line="--keychain &quot;${macosx-sign-keychain}&quot; --force -s &quot;${macosx-sign-id}&quot; -v Arduino.app/" />
</exec>
<!-- Check for successful signing -->
<exec executable="codesign" dir="macosx/work" failonerror="true">
<arg line="-vvvv Arduino.app/" />
</exec>
<delete file="macosx/arduino-${version}-${platform}.zip" />
<!-- Create signed zip file -->
<exec executable="zip" dir="macosx/work">
<arg line="-q -r ../arduino-${version}-${platform}-signed.zip ." />
</exec>
<echo>
=======================================================
Arduino for Mac OS X built and signed.
macosx/arduino-${version}-${platform}-signed.zip
=======================================================
</echo>
</target>
<target name="macosx-singed-dist-check">
<fail unless="macosx-sign-keychain" message="Please set the property 'macosx-sign-keychain' to the correct keychain file" />
<fail unless="macosx-sign-keychain-pass" message="Please set the property 'macosx-sign-keychain-pass' with the password to unlock the keychain" />
<fail unless="macosx-sign-id" message="Please set the property 'macosx-sign-id' to the correct cert identifier" />
</target>
<!-- - - - - - - - - - - - - - - - - - - -->
<!-- Build distribution file for MacOSX. -->
<!-- - - - - - - - - - - - - - - - - - - -->
<target name="macosx-old-dist" if="macosx" depends="macosx-old-build" description="Create a downloadable .zip for the Mac OS X version">
<antcall target="macosx-dist-common"/>
</target>
<target name="macosx-dist" if="macosx" depends="macosx-build" description="Create a downloadable .zip for the Mac OS X version">
<antcall target="macosx-dist-common"/>
</target>
<target name="macosx-dist-common">
<exec executable="zip" dir="macosx/work">
<arg line="-q -r ../arduino-${version}-${platform}.zip ." />
</exec>
<echo>
=======================================================
Arduino for Mac OS X was built. Grab the image from
macosx/arduino-${version}-${platform}.zip
=======================================================
</echo>
</target>
<!--<target name="macosx-dist-old" if="macosx" depends="macosx-build" description="Create a .dmg of the Mac OS X version">-->
<!--&lt;!&ndash; now build the dmg &ndash;&gt;-->
<!--<gunzip src="macosx/template.dmg.gz" dest="macosx/working.dmg" />-->
<!--<mkdir dir="macosx/working_dir" />-->
<!--<exec executable="hdiutil">-->
<!--<arg line="attach macosx/working.dmg -noautoopen -mountpoint macosx/working_dir" />-->
<!--&lt;!&ndash;<arg line="attach macosx/working.dmg -noautoopen -quiet -mountpoint macosx/working_dir" />&ndash;&gt;-->
<!--</exec>-->
<!--<copy todir="macosx/working_dir">-->
<!--<fileset dir="macosx/work" />-->
<!--</copy>-->
<!--&lt;!&ndash; The ant copy command does not preserve permissions. &ndash;&gt;-->
<!--<chmod file="macosx/working_dir/Arduino.app/Contents/MacOS/JavaApplicationStub" perm="+x" />-->
<!--<chmod perm="+x">-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin" includes="**/*" />-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/bin" includes="**/*" />-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr-3/bin" includes="**/*" />-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr-4/bin" includes="**/*" />-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/libexec/gcc/avr/3.4.6/" includes="**/cc1*" />-->
<!--<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/libexec/gcc/avr/4.3.2/" includes="**/cc1*" />-->
<!--</chmod>-->
<!--&lt;!&ndash; Pause briefly for the OS to catch up with the DMG changes. -->
<!--This prevents "hdiutil: couldn't eject "disk3" - Resource busy"-->
<!--errors when ejecting the disk in the next step.-->
<!--You may need to set this value higher for your system. &ndash;&gt;-->
<!--<sleep seconds="3" />-->
<!--<exec executable="hdiutil">-->
<!--&lt;!&ndash;<arg line="detach macosx/working_dir -quiet -force" />&ndash;&gt;-->
<!--<arg line="detach macosx/working_dir" />-->
<!--</exec>-->
<!--<delete file="macosx/arduino-*.dmg" />-->
<!--<exec executable="hdiutil">-->
<!--<arg line="convert macosx/working.dmg -quiet -format UDZO -imagekey zlib-level=9 -o macosx/arduino-${version}.dmg" />-->
<!--</exec>-->
<!--&lt;!&ndash; Clean up the interim files. &ndash;&gt;-->
<!--<delete file="macosx/working.dmg" />-->
<!--<delete dir="macosx/working_dir" />-->
<!--<echo>-->
<!--=======================================================-->
<!--Arduino for Mac OS X was built. Grab the image from-->
<!--macosx/arduino-${version}.dmg-->
<!--=======================================================-->
<!--</echo>-->
<!--</target>-->
<target name="macosx-dist-old-fix-perms" unless="light_bundle">
<chmod perm="+x">
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin" includes="**/*" />
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr/bin" includes="**/*" />
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr-3/bin" includes="**/*" />
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr-4/bin" includes="**/*" />
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/libexec/gcc/avr/3.4.6/" includes="**/cc1*" />
<fileset dir="macosx/working_dir/Arduino.app/Contents/Resources/Java/hardware/tools/avr/libexec/gcc/avr/4.3.2/" includes="**/cc1*" />
</chmod>
</target>
<!-- - - - - - - - -->
<!-- Linux -->
<!-- - - - - - - - -->
<target name="linux-clean" depends="subprojects-clean" description="Clean linux version">
<delete dir="linux/work" />
<delete>
<fileset dir="linux" includes="arduino-*linux*.tar.xz"/>
</delete>
</target>
<target name="linux-checkos" unless="linux">
<echo>
=======================================================
Arduino for Linux can only be built on on unix systems.
Bye.
=======================================================
</echo>
<fail message="wrong platform (${os.name})" />
</target>
<target name="linux-build" depends="revision-check, linux-checkos, subprojects-build" description="Build linux version">
<mkdir dir="linux/work" />
<mkdir dir="linux/work/${staging_hardware_folder}" />
<copy todir="linux/work">
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />
</copy>
<copy todir="linux/work">
<fileset dir="linux/dist" includes="lib/**" />
</copy>
<copy todir="linux/work/lib" flatten="true">
<fileset refid="runtime.jars" />
</copy>
<antcall target="assemble">
<param name="target.path" value="linux/work" />
</antcall>
<copy todir="linux/work" file="linux/dist/arduino" />
<chmod perm="755" file="linux/work/arduino" />
<copy todir="linux/work" file="linux/dist/arduino" />
<chmod perm="755" file="linux/work/arduino" />
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/libastylej-2.05.zip" />
<param name="final_folder" value="${staging_folder}/libastylej" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="linux/libastylej/libastylej${arch-bits}.so" tofile="linux/work/lib/libastylej.so" />
<chmod perm="755" file="linux/work/lib/libastylej.so" />
</target>
<target name="linux32-build" depends="linux-build" unless="light_bundle" description="Build linux (32-bit) version">
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
<param name="gcc_archive_file" value="avr-gcc-4.8.1-arduino-i686-pc-linux-gnu.tar.bz2"/>
<param name="gcc_version" value="4.8.1-arduino/"/>
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino-i686-pc-linux-gnu.tar.bz2"/>
<param name="avrdude_version" value="6.0.1-arduino"/>
</antcall>
<exec executable="tar" dir="${staging_folder}/work/dist/bundled_package/">
<arg value="-c"/>
<arg value="-z"/>
<arg value="-f"/>
<arg value="../default_package.tar.gz"/>
<arg value="./"/>
</exec>
<delete dir="${staging_folder}/work/dist/bundled_package/"/>
</target>
<target name="linux64-build" depends="linux-build" unless="light_bundle" description="Build linux (64-bit) version">
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="untar"/>
<param name="gcc_archive_file" value="avr-gcc-4.8.1-arduino-x86_64-pc-linux-gnu.tar.bz2"/>
<param name="gcc_version" value="4.8.1-arduino/"/>
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino-x86_64-pc-linux-gnu.tar.bz2"/>
<param name="avrdude_version" value="6.0.1-arduino"/>
</antcall>
<exec executable="tar" dir="${staging_folder}/work/dist/bundled_package/">
<arg value="-c"/>
<arg value="-z"/>
<arg value="-f"/>
<arg value="../default_package.tar.gz"/>
<arg value="./"/>
</exec>
<delete dir="${staging_folder}/work/dist/bundled_package/"/>
</target>
<target name="linux32-run" depends="linux32-build" description="Run Linux (32-bit) version">
<exec executable="./linux/work/arduino" spawn="false"/>
</target>
<target name="linux64-run" depends="linux64-build" description="Run Linux (64-bit) version">
<exec executable="./linux/work/arduino" spawn="false"/>
</target>
<!-- Set '${dist_file}_available' property if toolchain dist_file is downloaded -->
<!-- Set '${dist_file}_installed' property if toolchain is installed in working directory -->
<!-- hardware/tools/${dist_check_file} is checked for existence -->
<target name="untar-unzip-check">
<available file="${archive_file}" property="${archive_file}_available" />
<available file="${final_folder}" property="${archive_file}_installed" />
</target>
<!-- Retrieve tool -->
<target name="untar-unzip-download" depends="untar-unzip-check" unless="${archive_file}_available">
<get src="${archive_url}" dest="${archive_file}" verbose="true" ignoreerrors="true" />
</target>
<target name="untar-unzip-checksum" depends="untar-unzip-download">
<echo>Testing checksum of "${archive_file}"</echo>
<checksum file="${archive_file}" algorithm="sha" fileext=".sha" verifyproperty="checksum.matches"/>
<condition property="checksum.matches.fail">
<equals arg1="${checksum.matches}" arg2="false"/>
</condition>
<fail if="checksum.matches.fail">Checksum failed.
File ${archive_file} failed checksum.
Please remove "${archive_file}" to download it again.
</fail>
</target>
<!-- Ensure that the tool is downloaded and test checksums, if everything's ok unzip it on the tools folder -->
<target name="untar" depends="untar-unzip-checksum" unless="${archive_file}_installed">
<echo>Untarring ${archive_file} into folder ${dest_folder}</echo>
<exec executable="tar">
<arg value="xf"/>
<arg value="${archive_file}"/>
<arg value="--directory=${dest_folder}"/>
</exec>
</target>
<target name="unzip" depends="untar-unzip-checksum" unless="${archive_file}_installed">
<echo>Unzipping ${archive_file} into folder ${dest_folder}</echo>
<mkdir dir="${dest_folder}" />
<exec executable="unzip">
<arg value="-q" />
<arg value="-n" />
<arg value="-d" />
<arg value="${dest_folder}" />
<arg value="${archive_file}" />
</exec>
</target>
<target name="unzip-with-ant-task" depends="untar-unzip-checksum" unless="${archive_file}_installed">
<echo>Unzipping ${archive_file} into folder ${dest_folder}</echo>
<mkdir dir="${dest_folder}" />
<unzip src="${archive_file}" dest="${dest_folder}"/>
</target>
<target name="linux-dist" depends="build"
description="Build .tar.xz of linux version">
<!--get src="http://dev.processing.org/build/jre-tools-6u18-linux-i586.tgz"
dest="linux/jre.tgz"
usetimestamp="true" />
<untar compression="gzip"
dest="linux/work"
src="linux/jre.tgz"
overwrite="false"/-->
<!--
<tar compression="gzip" basedir="linux/work"
destfile="linux/arduino-${version}.tgz" />
<tar compression="gzip" destfile="linux/arduino-${version}-linux.tgz">
<tarfileset dir="linux/work"
prefix="arduino-${version}"
excludes="arduino,
hardware/tools/avrdude,
java/**"
/>
<tarfileset file="linux/work/arduino" filemode="755" prefix="arduino-${version}" />
<tarfileset file="linux/work/hardware/tools/avrdude" filemode="755"
prefix="arduino-${version}/hardware/tools" />
</tar>
-->
<move file="linux/work" tofile="linux/arduino-${version}" />
<exec executable="tar" dir="linux">
<arg value="--lzma"/>
<arg value="-c"/>
<arg value="-f"/>
<arg value="arduino-${version}-${platform}.tar.xz"/>
<arg value="arduino-${version}"/>
</exec>
<move file="linux/arduino-${version}" tofile="linux/work" />
<echo>
=======================================================
Arduino for Linux was built. Grab the archive from
linux/arduino-${version}-${platform}.tar.xz
=======================================================
</echo>
</target>
<target name="linux32-dist" depends="linux-dist"
description="Build .tar.xz of linux version" />
<target name="linux64-dist" depends="linux-dist"
description="Build .tar.xz of linux version" />
<!-- - - - - - - - -->
<!-- Windows -->
<!-- - - - - - - - -->
<target name="windows-clean" depends="subprojects-clean"
description="Clean windows version">
<delete dir="windows/work" />
<delete>
<fileset dir="windows" includes="arduino-*windows*.zip"/>
</delete>
</target>
<target name="windows-checkos" unless="windows">
<echo>
=======================================================
Arduino for Windows can only be built on windows.
Bye.
=======================================================
</echo>
<fail message="wrong platform (${os.name})" />
</target>
<target name="download-launch4j-windows">
<antcall target="unzip-with-ant-task">
<param name="archive_file" value="windows/launch4j-3.7-win32.zip"/>
<param name="archive_url" value="http://switch.dl.sourceforge.net/project/launch4j/launch4j-3/3.7/launch4j-3.7-win32.zip"/>
<param name="final_folder" value="windows/launcher/launch4j"/>
<param name="dest_folder" value="windows/launcher/"/>
</antcall>
</target>
<target name="download-launch4j-linux">
<antcall target="untar">
<param name="archive_file" value="windows/launch4j-3.7-linux.tgz"/>
<param name="archive_url" value="http://switch.dl.sourceforge.net/project/launch4j/launch4j-3/3.7/launch4j-3.7-linux.tgz"/>
<param name="final_folder" value="windows/launcher/launch4j"/>
<param name="dest_folder" value="windows/launcher/"/>
</antcall>
</target>
<target name="windows-build"
depends="revision-check, windows-checkos, subprojects-build"
description="Build windows version">
<mkdir dir="windows/work" />
<mkdir dir="windows/work/${staging_hardware_folder}" />
<!-- assemble the pde -->
<mkdir dir="windows/work/lib" />
<copy todir="windows/work/lib" flatten="true">
<fileset refid="runtime.jars" />
</copy>
<copy todir="windows/work">
<fileset dir="shared" includes="lib/**" />
<fileset file="shared/revisions.txt" />
</copy>
<fixcrlf file="windows/work/revisions.txt" eol="dos"/>
<fixcrlf file="windows/work/lib/formatter.conf" eol="dos"/>
<copy todir="windows/work">
<fileset dir="windows/dist" includes="*.dll" />
</copy>
<copy todir="windows/work">
<fileset dir="windows/dist" includes="drivers/**" />
</copy>
<antcall target="windows-build-avr-toolchain" />
<antcall target="unzip">
<param name="archive_file" value="./libastylej-2.05.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/libastylej-2.05.zip" />
<param name="final_folder" value="${staging_folder}/libastylej" />
<param name="dest_folder" value="${staging_folder}" />
</antcall>
<copy file="windows/libastylej/AStylej.dll" todir="windows/work/lib" />
<copy file="windows/msvcp100.dll" todir="windows/work" />
<copy file="windows/msvcr100.dll" todir="windows/work" />
<!-- Copy listComPort.exe tool -->
<copy todir="windows/work/hardware/tools">
<fileset file="windows/listComPorts.exe" />
</copy>
<chmod perm="755">
<fileset file="windows/work/hardware/tools/listComPorts.exe" />
</chmod>
<antcall target="assemble">
<param name="target.path" value="windows/work" />
</antcall>
<antcall target="windows-assemble-bundled-toolchain"/>
<delete dir="windows/launcher/launch4j"/>
<antcall target="download-${launch4j-download-unpack-target-name}" />
<property name="launch4j.dir" value="windows/launcher/launch4j/" />
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${launch4j.dir}/launch4j.jar; ${launch4j.dir}/lib/xstream.jar" />
<copy todir="windows/work">
<fileset dir="windows/launcher"
includes="application.ico, config.xml, config_debug.xml, arduino.l4j.ini"/>
</copy>
<launch4j configFile="windows/work/config.xml" />
<launch4j configFile="windows/work/config_debug.xml" />
<delete dir="windows/work" includes="application.ico, config.xml, config_debug.xml" />
<copy file="windows/work/arduino.l4j.ini" tofile="windows/work/arduino_debug.l4j.ini" />
<!-- cygwin requires html, dll, and exe to have the +x flag -->
<chmod perm="755">
<fileset dir="windows/work" includes="**/*.html, **/*.dll, **/*.exe" />
</chmod>
</target>
<target name="windows-build-avr-toolchain">
<antcall target="avr-toolchain-bundle">
<param name="unpack_target" value="unzip"/>
<param name="gcc_archive_file" value="avr-gcc-4.8.1-arduino-i686-mingw32.zip"/>
<param name="gcc_version" value="4.8.1-arduino/"/>
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino-i686-mingw32.zip"/>
<param name="avrdude_version" value="6.0.1-arduino"/>
</antcall>
</target>
<target name="windows-assemble-bundled-toolchain" unless="light_bundle">
<exec executable="zip" dir="${staging_folder}/work/dist/bundled_package/">
<arg line="-q -r ../default_package.zip ." />
</exec>
<delete dir="${staging_folder}/work/dist/bundled_package/"/>
</target>
<target name="windows-run" depends="windows-build"
description="Run windows version">
<exec executable="windows/work/arduino.exe"
dir="windows/work" spawn="true"/>
</target>
<target name="windows-dist" depends="windows-build"
description="Create .zip files of windows version">
<antcall target="unzip">
<param name="archive_file" value="windows/jre-8u31.zip" />
<param name="archive_url" value="http://arduino.cc/download.php?f=/jre-8u31.zip" />
<param name="final_folder" value="${staging_folder}/work/java" />
<param name="dest_folder" value="${staging_folder}/work/" />
</antcall>
<zip destfile="windows/arduino-${version}-${platform}.zip" level="9">
<zipfileset dir="windows/work"
prefix="arduino-${version}" />
</zip>
<echo>
=======================================================
Arduino for Windows was built. Grab the archive from
windows/arduino-${version}-${platform}.zip
=======================================================
</echo>
</target>
<!-- - - - - - - - -->
<!-- Source -->
<!-- - - - - - - - -->
<target name="source-dist" depends="revision-check"
description="Build .tar.gz of source code">
<input message="Enter version number:"
addproperty="version"
defaultvalue="${revision}" />
<tar compression="gzip" destfile="arduino-${version}-src.tar.gz">
<tarfileset dir="../"
prefix="arduino-${version}"
excludes="**/*.tgz,
**/*.bz2,
**/build/macosx/,
**/build/windows/,
**/work/,
**/.git/,
**/*.class"
/>
</tar>
<echo>
=======================================================
Arduino source distribution was built. Grab the archive from
arduino-${version}-src.tar.gz
=======================================================
</echo>
</target>
<!-- - - - - - - - -->
<!-- Run It! -->
<!-- - - - - - - - -->
<target name="clean" description="Perform a spring cleaning"
depends="linux-clean, windows-clean, macosx-clean, subprojects-clean">
</target>
<target name="avr-toolchain-bundle" unless="light_bundle">
<!-- Unzip AVR tools -->
<mkdir dir="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avr-gcc/"/>
<mkdir dir="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avrdude/"/>
<antcall target="${unpack_target}">
<param name="archive_file" value="${staging_folder}/${gcc_archive_file}"/>
<param name="archive_url" value="http://arduino.cc/download.php?f=/tools/${gcc_archive_file}"/>
<param name="final_folder" value="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avr-gcc/${gcc_version}/"/>
<param name="dest_folder" value="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avr-gcc/"/>
</antcall>
<move file="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avr-gcc/avr" tofile="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avr-gcc/${gcc_version}"/>
<antcall target="${unpack_target}">
<param name="archive_file" value="${staging_folder}/${avrdude_archive_file}"/>
<param name="archive_url" value="http://arduino.cc/download.php?f=/tools/${avrdude_archive_file}"/>
<param name="final_folder" value="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avrdude/${avrdude_version}"/>
<param name="dest_folder" value="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avrdude/"/>
</antcall>
<move file="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avrdude/avrdude-6.0.1" tofile="${staging_folder}/work/dist/bundled_package/packages/arduino/tools/avrdude/${avrdude_version}"/>
<copy file="shared/bundled_package_index.json" tofile="${staging_folder}/work/dist/bundled_package/package_index.json"/>
</target>
</project>