blob: 69a4d38ec04c1e921f1df1b1c941d53b19d35d6e [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001#!/bin/bash
Andrew Geissler517393d2023-01-13 08:55:19 -06002set -u -e
Brad Bishopbec4ebc2022-08-03 09:55:16 -04003
Andrew Geissler517393d2023-01-13 08:55:19 -06004BASENAME=arm-gnu-toolchain
Andrew Geisslerea144b02023-01-27 16:03:57 -06005VER=${VER:-12.2.rel1}
Andrew Geissler517393d2023-01-13 08:55:19 -06006HOST_ARCH=${HOST_ARCH:-$(uname -m)}
Brad Bishopbec4ebc2022-08-03 09:55:16 -04007
Patrick Williams2a254922023-08-11 09:48:11 -05008# Use the standard kas container locations if nothing is passed into the script
9DOWNLOAD_DIR="${1:-/builds/persist/downloads/}"
10TOOLCHAIN_DIR="${2:-/builds/persist//toolchains/}"
11TOOLCHAIN_LINK_DIR="${3:-build/toolchains/}"
Brad Bishopbec4ebc2022-08-03 09:55:16 -040012
13# These should be already created by .gitlab-ci.yml, but do here if run outside of that env
14mkdir -p $DOWNLOAD_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
15
Andrew Geissler517393d2023-01-13 08:55:19 -060016download() {
17 TRIPLE=$1
18 URL=https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/$BASENAME-$VER-$HOST_ARCH-$TRIPLE.tar.xz
19 wget -P $DOWNLOAD_DIR -nc $URL
20}
21
Brad Bishopbec4ebc2022-08-03 09:55:16 -040022if [ $HOST_ARCH = "aarch64" ]; then
Andrew Geissler517393d2023-01-13 08:55:19 -060023 # AArch64 Linux hosted cross compilers
Brad Bishopbec4ebc2022-08-03 09:55:16 -040024
Andrew Geissler517393d2023-01-13 08:55:19 -060025 # AArch32 target with hard float
26 download arm-none-linux-gnueabihf
Brad Bishopbec4ebc2022-08-03 09:55:16 -040027elif [ $HOST_ARCH = "x86_64" ]; then
Andrew Geissler517393d2023-01-13 08:55:19 -060028 # x86_64 Linux hosted cross compilers
Brad Bishopbec4ebc2022-08-03 09:55:16 -040029
Andrew Geissler517393d2023-01-13 08:55:19 -060030 # AArch32 target with hard float
31 download arm-none-linux-gnueabihf
Brad Bishopbec4ebc2022-08-03 09:55:16 -040032
Andrew Geissler517393d2023-01-13 08:55:19 -060033 # AArch64 GNU/Linux target
34 download aarch64-none-linux-gnu
Brad Bishopbec4ebc2022-08-03 09:55:16 -040035else
36 echo "ERROR - Unknown build arch of $HOST_ARCH"
37 exit 1
38fi
39
Andrew Geissler517393d2023-01-13 08:55:19 -060040for i in arm aarch64; do
41 if [ ! -d $TOOLCHAIN_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu*/ ]; then
42 if [ ! -f $DOWNLOAD_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz ]; then
Brad Bishopbec4ebc2022-08-03 09:55:16 -040043 continue
44 fi
45
Andrew Geissler517393d2023-01-13 08:55:19 -060046 tar -C $TOOLCHAIN_DIR -axvf $DOWNLOAD_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz
Brad Bishopbec4ebc2022-08-03 09:55:16 -040047 fi
48
49 # Setup a link for the toolchain to use local to the building machine (e.g., not in a shared location)
Andrew Geissler517393d2023-01-13 08:55:19 -060050 ln -s $TOOLCHAIN_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu* $TOOLCHAIN_LINK_DIR/$i
Brad Bishopbec4ebc2022-08-03 09:55:16 -040051done