1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

script: Add toolchain-{download,run}

Add scripts to download, verify and use GNU Arm Embedded 5 2016q2.

2016q2 (SVN revision 237715) generates identical output to Debian
Stretch used by Docker build (SVN revision 241155).
This commit is contained in:
Saleem Rashid 2018-06-25 20:13:07 +01:00 committed by Pavol Rusnak
parent 8f6a2045e6
commit 67852dcaba
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 76 additions and 0 deletions

54
script/toolchain-download Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
# script/toolchain-download: Download and extract the GNU Arm Embedded toolchain
# for building the TREZOR firmware.
set -e
cd "$(dirname "$0")/../vendor"
readonly URL="https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2"
readonly SHA256SUM="9910b6b5df12efe564dbb3856bf1599d4c16178a6f28bd8a23c9e5c3edc219e4"
readonly FILENAME="$(basename "$URL")"
readonly DIRECTORY="gcc-arm-none-eabi-5_4-2016q2"
if [ "$(uname)" != "Linux" ]; then
printf "Unsupported platform\n" >&2
exit 1
fi
validate_download() {
printf "$SHA256SUM $FILENAME" | sha256sum -c
}
download_file() {
curl -LC- "$URL" -o "$FILENAME"
}
extract_download() {
local temporary_dir="$(mktemp -d ./toolchain.XXXXXXXXXX)"
trap "rm -rf $temporary_dir" EXIT
tar -xf "$FILENAME" -C "$temporary_dir"
mv "$temporary_dir/$DIRECTORY" .
rm -f "$FILENAME"
}
if [ ! -d "$DIRECTORY" ]; then
if ! validate_download; then
download_file
validate_download
fi
extract_download
fi
# init toolchain as repository so Git will skip it
git init -q "$DIRECTORY"
# update toolchain symlink
ln -snf "$DIRECTORY" toolchain
# sanity-check extracted toolchain
toolchain/bin/arm-none-eabi-gcc --version >/dev/null

18
script/toolchain-run Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# script/toolchain-run: Run command with downloaded GNU Arm Embedded toolchain.
#
set -e
readonly TOOLCHAIN_RELATIVE_DIR="vendor/toolchain"
readonly TOOLCHAIN_DIR="$(readlink -f "$(dirname "$0")/../$TOOLCHAIN_RELATIVE_DIR")"
if [ ! -d "$TOOLCHAIN_DIR" ]; then
printf "Could not find toolchain in %s.\n" "$TOOLCHAIN_RELATIVE_DIR" >&2
printf "Run script/toolchain-download to download it.\n" >&2
exit 1
fi
export PATH="$TOOLCHAIN_DIR/bin:$PATH"
exec "$@"

4
vendor/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# toolchain-download
gcc-arm-none-eabi-*
toolchain
toolchain.*/