Skip to content

Commit b8f5ba7

Browse files
committed
[sam] Added automatic toolchain download on build.xml (linux only)
1 parent efbf66e commit b8f5ba7

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

build/build.xml

+59-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@
146146
message="Fix revision number in Base.java" />
147147
</target>
148148

149-
149+
<!-- - - - - - - - - - - - - - - - - - - -->
150+
<!-- Download of toolchains for ARM -->
151+
<!-- - - - - - - - - - - - - - - - - - - -->
152+
153+
<target name="get-arm-toolchain" description="Download and unpack toolchain for ARM">
154+
<antcall target="${platform}-get-arm-toolchain" />
155+
</target>
156+
157+
<target name="get-arm-toolchain-help" if="arm_not_available">
158+
<echo>
159+
=========================================================
160+
To download and install ARM-gcc toolchain use the command
161+
162+
ant get-arm-toolchain
163+
=========================================================
164+
</echo>
165+
</target>
166+
150167
<!-- - - - - - - - -->
151168
<!-- Mac OS X -->
152169
<!-- - - - - - - - -->
@@ -344,7 +361,7 @@
344361
<fail message="wrong platform (${os.name})" />
345362
</target>
346363

347-
<target name="linux-build" depends="revision-check, linux-checkos, subprojects-build" description="Build linux version">
364+
<target name="linux-build" depends="revision-check, linux-checkos, subprojects-build, linux-check-arm-toolchain" description="Build linux version">
348365
<mkdir dir="linux/work" />
349366

350367
<copy todir="linux/work">
@@ -372,8 +389,7 @@
372389
<chmod perm="755" file="linux/work/hardware/tools/bossac" />
373390
<chmod perm="755" file="linux/work/hardware/tools/bossac64" />
374391

375-
<copy todir="linux/work" file="linux/dist/arduino" />
376-
<chmod perm="755" file="linux/work/arduino" />
392+
<antcall target="get-arm-toolchain-help" />
377393
</target>
378394

379395
<target name="linux64-build" depends="linux-build" description="Build linux (64-bit) version">
@@ -391,6 +407,45 @@
391407
<exec executable="./linux/work/arduino" spawn="false"/>
392408
</target>
393409

410+
<target name="linux-check-arm-toolchain">
411+
<available file="linux/work/hardware/tools/g++_arm_none_eabi" property="arm_available" />
412+
<condition property="arm_not_available">
413+
<not>
414+
<isset property="arm_available" />
415+
</not>
416+
</condition>
417+
</target>
418+
419+
<target name="linux-get-arm-toolchain" depends="linux-check-arm-toolchain" if="arm_not_available">
420+
<!-- Retrieve ARM toolchain... -->
421+
<get
422+
src="http://static.leaflabs.com/pub/codesourcery/gcc-arm-none-eabi-latest-linux32.tar.gz"
423+
dest="linux/dist/gcc-arm-none-eabi-latest-linux32.tar.gz"
424+
skipexisting="true" verbose="true" />
425+
<checksum file="linux/dist/gcc-arm-none-eabi-latest-linux32.tar.gz" algorithm="sha"
426+
fileext=".sha" verifyproperty="checksum.matches"/>
427+
<condition property="checksum.matches.fail">
428+
<equals arg1="${checksum.matches}" arg2="false"/>
429+
</condition>
430+
<fail if="checksum.matches.fail">
431+
File gcc-arm-none-eabi-latest-linux32.tar.gz failed checksum.
432+
Please remove "linux/dist/gcc-arm-none-eabi-latest-linux32.tar.gz" to download again.
433+
</fail>
434+
435+
<!-- ...and unzip on the destination folder -->
436+
<exec executable="tar" output="/dev/null" os="Linux">
437+
<arg value="xfz"/>
438+
<arg value="linux/dist/gcc-arm-none-eabi-latest-linux32.tar.gz"/>
439+
<arg value="--directory=linux/work/hardware/tools"/>
440+
</exec>
441+
442+
<move file="linux/work/hardware/tools/arm"
443+
tofile="linux/work/hardware/tools/g++_arm_none_eabi" />
444+
445+
<copy todir="linux/work" file="linux/dist/arduino" />
446+
<chmod perm="755" file="linux/work/arduino" />
447+
</target>
448+
394449
<target name="linux-dist" depends="build"
395450
description="Build .tar.gz of linux version">
396451

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d835b43b066ccb224e2767a26e2ca90abcebe06b

0 commit comments

Comments
 (0)