1#!/bin/bash 2set -u -e 3 4BASENAME=arm-gnu-toolchain 5VER=${VER:-13.2.Rel1} 6HOST_ARCH=${HOST_ARCH:-$(uname -m)} 7 8# 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/}" 12 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 16download() { 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 22if [ $HOST_ARCH = "aarch64" ]; then 23 # AArch64 Linux hosted cross compilers 24 25 # AArch32 target with hard float 26 download arm-none-linux-gnueabihf 27elif [ $HOST_ARCH = "x86_64" ]; then 28 # x86_64 Linux hosted cross compilers 29 30 # AArch32 target with hard float 31 download arm-none-linux-gnueabihf 32 33 # AArch64 GNU/Linux target 34 download aarch64-none-linux-gnu 35else 36 echo "ERROR - Unknown build arch of $HOST_ARCH" 37 exit 1 38fi 39 40for 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 43 continue 44 fi 45 46 tar -C $TOOLCHAIN_DIR -axvf $DOWNLOAD_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz 47 fi 48 49 # Setup a link for the toolchain to use local to the building machine (e.g., not in a shared location) 50 ln -s $TOOLCHAIN_DIR/$BASENAME-$VER-$HOST_ARCH-$i-none-linux-gnu* $TOOLCHAIN_LINK_DIR/$i 51done 52