blob: dc92d443061d9cdc8e83c9046d2ff7e9b4ebf00d [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Sandrine Bailleuxdf823892022-04-22 13:27:45 +02003# Copyright (c) 2019-2022 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
Gary Morrison999a9d72022-03-14 18:29:06 -050041 if echo "$JENKINS_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() {
Harrison Mutai013f6332022-02-16 16:06:33 +000068 # FIXME: ARMCompiler 6.18 is symlinked to 6.17 until it is available on OpenCI.
69 local armclang_path="/home/buildslave/tools/armclang-6.17/bin"
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060070
71 # if under arm enviroment, overide cross-compilation path
Harrison Mutai013f6332022-02-16 16:06:33 +000072 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 -060073
74 echo "${armclang_path}/armclang"
75}
Fathi Boudra422bf772019-12-02 11:10:16 +020076
Leonardo Sandovalc4dfbb02020-08-17 10:21:44 -050077# mbed TLS variables
78MBED_TLS_DIR=mbedtls
79MBED_TLS_URL_REPO=https://github.com/ARMmbed/mbedtls.git
80
Sandrine Bailleuxdf823892022-04-22 13:27:45 +020081# mbed TLS source tag to checkout when building Trusted Firmware with
82# cryptography support (e.g. for Trusted Board Boot feature).
Daniel Boulbyb63dd8c2022-09-23 11:55:20 +010083MBED_TLS_SOURCES_TAG="mbedtls-2.28.1"
Fathi Boudra422bf772019-12-02 11:10:16 +020084
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060085ARMCLANG_PATH="$(set_armclang_toolchain)"
86
Fathi Boudra422bf772019-12-02 11:10:16 +020087CRYPTOCELL_LIB_PATH=/arm/projectscratch/ssg/trusted-fw/dummy-crypto-lib
Leonardo Sandovaled5da5b2020-11-18 12:02:14 -060088
89TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls"
90ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa"