blob: bfdd8c573bf3db36682fac0248637c8791f88fd4 [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001#!/bin/bash
2set -u
3
4HOST_ARCH=$(uname -m)
5VER="11.2-2022.02"
6
7DOWNLOAD_DIR=$1
8TOOLCHAIN_DIR=$2
9TOOLCHAIN_LINK_DIR=$3
10
11# These should be already created by .gitlab-ci.yml, but do here if run outside of that env
12mkdir -p $DOWNLOAD_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
13
14if [ $HOST_ARCH = "aarch64" ]; then
15 #AArch64 Linux hosted cross compilers
16
17 #AArch32 target with hard float (arm-none-linux-gnueabihf)
18 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/gcc-arm-$VER-$HOST_ARCH-arm-none-linux-gnueabihf.tar.xz
19elif [ $HOST_ARCH = "x86_64" ]; then
20 #x86_64 Linux hosted cross compilers
21
22 #AArch32 target with hard float (arm-linux-none-gnueabihf)
23 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/gcc-arm-$VER-$HOST_ARCH-arm-none-linux-gnueabihf.tar.xz
24
25 #AArch64 GNU/Linux target (aarch64-none-linux-gnu)
26 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/gcc-arm-$VER-$HOST_ARCH-aarch64-none-linux-gnu.tar.xz
27
28 #AArch64 GNU/Linux target (aarch64_be-none-linux-gnu)
29 wget -P $DOWNLOAD_DIR -nc https://developer.arm.com/-/media/Files/downloads/gnu/$VER/binrel/gcc-arm-$VER-$HOST_ARCH-aarch64_be-none-linux-gnu.tar.xz
30else
31 echo "ERROR - Unknown build arch of $HOST_ARCH"
32 exit 1
33fi
34
35for i in arm aarch64 aarch64_be; do
36 if [ ! -d $TOOLCHAIN_DIR/gcc-arm-$VER-$HOST_ARCH-$i-none-linux-gnu*/ ]; then
37 if [ ! -f $DOWNLOAD_DIR/gcc-arm-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz ]; then
38 continue
39 fi
40
41 tar -C $TOOLCHAIN_DIR -axvf $DOWNLOAD_DIR/gcc-arm-$VER-$HOST_ARCH-$i-none-linux-gnu*.tar.xz
42 fi
43
44 # Setup a link for the toolchain to use local to the building machine (e.g., not in a shared location)
45 ln -s $TOOLCHAIN_DIR/gcc-arm-$VER-$HOST_ARCH-$i-none-linux-gnu* $TOOLCHAIN_LINK_DIR/$i
46done