|
16 | 16 |
|
17 | 17 | set -e
|
18 | 18 |
|
| 19 | +# Function to update/install native GCC inside the Docker container |
| 20 | +update_native_gcc() { |
| 21 | + REQUIRED_MAJOR=12 |
| 22 | + INSTALLED_MAJOR=$(gcc -dumpversion | cut -d. -f1 || echo 0) |
| 23 | + |
| 24 | + if [[ "$INSTALLED_MAJOR" -lt "$REQUIRED_MAJOR" ]]; then |
| 25 | + echo "Installing native GCC $REQUIRED_MAJOR..." |
| 26 | + apt-get update |
| 27 | + apt-get install -y --no-install-recommends gcc-$REQUIRED_MAJOR g++-$REQUIRED_MAJOR \ |
| 28 | + cpp-$REQUIRED_MAJOR libgcc-$REQUIRED_MAJOR-dev libstdc++-$REQUIRED_MAJOR-dev |
| 29 | + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$REQUIRED_MAJOR 60 |
| 30 | + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$REQUIRED_MAJOR 60 |
| 31 | + rm -rf /var/lib/apt/lists/* |
| 32 | + else |
| 33 | + echo "Native GCC is already version $INSTALLED_MAJOR; skipping installation." |
| 34 | + fi |
| 35 | +} |
| 36 | + |
| 37 | +# Function to update/install ARM Embedded GCC inside the Docker container |
| 38 | +update_cross_gcc() { |
| 39 | + ARM_GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi.tar.xz" |
| 40 | + TOOLCHAIN_DIR="/opt/arm-gcc" |
| 41 | + |
| 42 | + # Install prerequisites |
| 43 | + echo "Installing prerequisites for ARM toolchain..." |
| 44 | + apt-get update |
| 45 | + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 46 | + curl libncurses5 xz-utils file |
| 47 | + rm -rf /var/lib/apt/lists/* |
| 48 | + |
| 49 | + # Download and extract |
| 50 | + echo "Downloading and extracting ARM Embedded GCC..." |
| 51 | + mkdir -p "$TOOLCHAIN_DIR" |
| 52 | + curl -SLf "$ARM_GCC_URL" -o /tmp/arm-gcc.tar.xz |
| 53 | + tar -xJf /tmp/arm-gcc.tar.xz -C "$TOOLCHAIN_DIR" --strip-components=1 |
| 54 | + rm -f /tmp/arm-gcc.tar.xz |
| 55 | + |
| 56 | + # Symlink into PATH |
| 57 | + echo "Symlinking ARM toolchain into /usr/local/bin..." |
| 58 | + ln -sf "$TOOLCHAIN_DIR/bin/"* /usr/local/bin/ |
| 59 | +} |
| 60 | + |
| 61 | +# Ensure we have the proper compiler before running tests |
| 62 | +update_native_gcc |
| 63 | +update_cross_gcc |
| 64 | + |
19 | 65 | source $(dirname "$0")/paths.sh
|
20 | 66 |
|
21 | 67 | SKIP_SIZE=$1
|
22 | 68 | BUILD_TYPE=$2
|
23 | 69 | DAMAGE_TYPE=$3
|
24 | 70 | FIH_LEVEL=$4
|
25 | 71 |
|
| 72 | +# Required for git am to apply patches under TF-M |
| 73 | +git config --global user.email "docker@fih-test.com" |
| 74 | +git config --global user.name "fih-test docker" |
| 75 | + |
26 | 76 | if test -z "$FIH_LEVEL"; then
|
27 | 77 | # Use the default level
|
28 | 78 | CMAKE_FIH_LEVEL=""
|
|
0 commit comments