blob: 9baf1855470480b1a48765e20d5ec884c40da554 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Yann Gautier47193692024-04-19 14:57:26 +02003# Copyright (c) 2019-2024 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -06008export 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.
13clean_build()
14{
15 local flags="$*"
16 echo "Building TF with the following build flags:"
17 echo " $flags"
Andre Przywaradc5ee542021-09-02 12:56:50 +010018 make distclean
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060019 make $flags all
20 echo "Build config complete."
21 echo
22}
23
24# Defines common flags between platforms
25common_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 Sokolovskya1afa402022-11-05 00:52:17 +030038# infrastructure)
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060039is_arm_jenkins_env() {
40 if [ "$JENKINS_HOME" ]; then
Saheer Babubdb0d652025-02-10 14:08:20 +000041 if echo "$JENKINS_PUBLIC_URL" | grep -q "oss.arm.com"; then
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060042 return 0;
43 fi
44 fi
45 return 1
46}
47
Madhukar Pappireddy3d24e422021-06-02 16:52:12 -050048# Use "$1" as a boolean
49upon() {
50 case "$1" in
51 "" | "0" | "false") return 1;;
52 *) return 0;;
53 esac
54}
55
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060056# Provide correct linaro cross toolchain based on environment
57set_cross_compile_gcc_linaro_toolchain() {
58 local cross_compile_path="/home/buildslave/tools"
59
60 # if under arm enviroment, overide cross-compilation path
Madhukar Pappireddy21a5e672021-03-08 17:49:45 -060061 is_arm_jenkins_env || upon "$local_ci" && cross_compile_path="/arm/pdsw/tools"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060062
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
67set_armclang_toolchain() {
Paul Sokolovsky358b1862023-10-20 10:57:32 +030068 local armclang_path="/home/buildslave/tools/armclang-6.18/bin"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060069
70 # if under arm enviroment, overide cross-compilation path
Harrison Mutai013f6332022-02-16 16:06:33 +000071 is_arm_jenkins_env || upon "$local_ci" && armclang_path="/arm/warehouse/Distributions/FA/ARMCompiler/6.18/19/standalone-linux-x86_64-rel/bin"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060072
73 echo "${armclang_path}/armclang"
74}
Fathi Boudra422bf772019-12-02 11:10:16 +020075
Leonardo Sandovalc4dfbb02020-08-17 10:21:44 -050076# mbed TLS variables
77MBED_TLS_DIR=mbedtls
78MBED_TLS_URL_REPO=https://github.com/ARMmbed/mbedtls.git
79
Sandrine Bailleuxdf823892022-04-22 13:27:45 +020080# mbed TLS source tag to checkout when building Trusted Firmware with
81# cryptography support (e.g. for Trusted Board Boot feature).
Lauren Wehrmeister307178f2025-04-03 12:56:54 -050082MBED_TLS_SOURCES_TAG="mbedtls-3.6.3"
Fathi Boudra422bf772019-12-02 11:10:16 +020083
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060084ARMCLANG_PATH="$(set_armclang_toolchain)"
85
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060086TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls"
87ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa"