Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 3 | # Copyright (c) 2019-2024 Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 8 | export CROSS_COMPILE=aarch64-none-elf- |
| 9 | |
| 10 | # We need to clean the platform build between each configuration because Trusted |
| 11 | # Firmware's build system doesn't track build options dependencies and won't |
| 12 | # rebuild the files affected by build options changes. |
| 13 | clean_build() |
| 14 | { |
| 15 | local flags="$*" |
| 16 | echo "Building TF with the following build flags:" |
| 17 | echo " $flags" |
Andre Przywara | dc5ee54 | 2021-09-02 12:56:50 +0100 | [diff] [blame] | 18 | make distclean |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 19 | make $flags all |
| 20 | echo "Build config complete." |
| 21 | echo |
| 22 | } |
| 23 | |
| 24 | # Defines common flags between platforms |
| 25 | common_flags() { |
| 26 | local release="${1:-}" |
| 27 | local num_cpus="$(/usr/bin/getconf _NPROCESSORS_ONLN)" |
| 28 | local parallel_make="-j $num_cpus" |
| 29 | |
| 30 | # default to debug mode, unless a parameter is passed to the function |
| 31 | debug="DEBUG=1" |
| 32 | [ -n "$release" ] && debug="" |
| 33 | |
| 34 | echo " $parallel_make $debug -s " |
| 35 | } |
| 36 | |
| 37 | # Check if execution environment is ARM's jenkins (Jenkins running under ARM |
Paul Sokolovsky | a1afa40 | 2022-11-05 00:52:17 +0300 | [diff] [blame] | 38 | # infrastructure) |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 39 | is_arm_jenkins_env() { |
| 40 | if [ "$JENKINS_HOME" ]; then |
Arthur She | 4c61059 | 2025-02-03 21:39:57 -0800 | [diff] [blame] | 41 | if echo "$JENKINS_PUBLIC_URL" | grep -q "oss.arm.com"; then |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 42 | return 0; |
| 43 | fi |
| 44 | fi |
| 45 | return 1 |
| 46 | } |
| 47 | |
Madhukar Pappireddy | 3d24e42 | 2021-06-02 16:52:12 -0500 | [diff] [blame] | 48 | # Use "$1" as a boolean |
| 49 | upon() { |
| 50 | case "$1" in |
| 51 | "" | "0" | "false") return 1;; |
| 52 | *) return 0;; |
| 53 | esac |
| 54 | } |
| 55 | |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 56 | # Provide correct linaro cross toolchain based on environment |
| 57 | set_cross_compile_gcc_linaro_toolchain() { |
| 58 | local cross_compile_path="/home/buildslave/tools" |
| 59 | |
| 60 | # if under arm enviroment, overide cross-compilation path |
Madhukar Pappireddy | 21a5e67 | 2021-03-08 17:49:45 -0600 | [diff] [blame] | 61 | is_arm_jenkins_env || upon "$local_ci" && cross_compile_path="/arm/pdsw/tools" |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 62 | |
| 63 | echo "${cross_compile_path}/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-" |
| 64 | } |
| 65 | |
| 66 | # Provide correct armclang toolchain based on environment |
| 67 | set_armclang_toolchain() { |
Paul Sokolovsky | 577a788 | 2023-10-20 10:57:32 +0300 | [diff] [blame] | 68 | local armclang_path="/home/buildslave/tools/armclang-6.18/bin" |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 69 | |
| 70 | # if under arm enviroment, overide cross-compilation path |
Harrison Mutai | 013f633 | 2022-02-16 16:06:33 +0000 | [diff] [blame] | 71 | is_arm_jenkins_env || upon "$local_ci" && armclang_path="/arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin" |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 72 | |
| 73 | echo "${armclang_path}/armclang" |
| 74 | } |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 75 | |
Leonardo Sandoval | c4dfbb0 | 2020-08-17 10:21:44 -0500 | [diff] [blame] | 76 | # mbed TLS variables |
| 77 | MBED_TLS_DIR=mbedtls |
| 78 | MBED_TLS_URL_REPO=https://github.com/ARMmbed/mbedtls.git |
| 79 | |
Sandrine Bailleux | df82389 | 2022-04-22 13:27:45 +0200 | [diff] [blame] | 80 | # mbed TLS source tag to checkout when building Trusted Firmware with |
| 81 | # cryptography support (e.g. for Trusted Board Boot feature). |
Lauren Wehrmeister | 4211823 | 2025-04-03 12:56:54 -0500 | [diff] [blame] | 82 | MBED_TLS_SOURCES_TAG="mbedtls-3.6.3" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 83 | |
Manish V Badarkhe | 58a88f0 | 2023-11-06 21:42:11 +0000 | [diff] [blame] | 84 | # TF-M variables |
| 85 | TF_M_TESTS_DIR=tf-m-tests |
| 86 | TF_M_TESTS_URL_REPO=https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
| 87 | |
| 88 | TF_M_EXTRAS_DIR=tf-m-extras |
| 89 | TF_M_EXTRAS_URL_REPO=https://git.trustedfirmware.org/TF-M/tf-m-extras.git |
| 90 | |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 91 | QCBOR_LIB_DIR=qcbor |
| 92 | QCBOR_URL_REPO=https://github.com/laurencelundblade/QCBOR.git |
| 93 | |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 94 | ARMCLANG_PATH="$(set_armclang_toolchain)" |
| 95 | |
Leonardo Sandoval | ed5da5b | 2020-11-18 12:02:14 -0600 | [diff] [blame] | 96 | TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls" |
| 97 | ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa" |