blob: d3db1ff4a6d9ace36396dba3f5aec24478a0b0d8 [file] [log] [blame]
Dean Birch62c4f082020-01-17 16:13:26 +00001#!/bin/bash
2#-------------------------------------------------------------------------------
Xinyu Zhangff5d7712022-01-14 13:48:59 +08003# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
Dean Birch62c4f082020-01-17 16:13:26 +00004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
9#
10# Builds a single configuration on Trusted Firmware M.
11# Relies on environment variables pre-populated.
12# These variables can be obtained using configs.py.
13# Expected to have trusted-firmware-m cloned to same level as this git tree
14#
15
16set -ex
Dean Birchd0f9f8c2020-03-26 11:10:33 +000017
18if [ -z "$CONFIG_NAME" ] ; then
19 echo "Set CONFIG_NAME to run a build."
20 exit 1
21fi
22
Karl Zhang4a45dac2020-06-10 14:03:10 +080023set +e
24echo "output current build environment"
25cat /etc/issue
26uname -a
27grep -c ^processor /proc/cpuinfo
Karl Zhang4a45dac2020-06-10 14:03:10 +080028cmake --version
29python --version
30make --version
31
32set -ex
Paul Sokolovskyd35b69f2023-04-19 13:29:11 +030033build_commands=$(python3 tf-m-ci-scripts/configs.py -b -g all -j ${BUILD_JOBS:-2} $CONFIG_NAME)
Dean Birchd0f9f8c2020-03-26 11:10:33 +000034
Paul Sokolovsky99078c12023-04-10 22:59:28 +030035if [ -n "$BUILD_TARGET" ]; then
36 build_commands=$(echo "$build_commands" | head -4)
37 build_commands=${build_commands/-- install/-- $BUILD_TARGET}
38fi
39
Xinyu Zhang433771e2022-04-01 16:49:17 +080040if [ $CODE_COVERAGE_EN = "TRUE" ] && [[ $CONFIG_NAME =~ "GCC" ]] ; then
Karl Zhangb0c9d692021-01-08 16:30:31 +080041 build_commands=${build_commands/toolchain_GNUARM.cmake/toolchain_GNUARM.cmake -DTFM_CODE_COVERAGE=True}
Karl Zhangf6f467e2020-07-10 16:24:45 +080042 echo "Flag: Add compiler flag for build with code coverage supported."
43 echo $build_commands
44fi
45
Dean Birchd0f9f8c2020-03-26 11:10:33 +000046if [ -z "$build_commands" ] ; then
47 echo "No build commands found."
48 exit 1
49fi
50
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080051cnt=$(ls trusted-firmware-m/lib/ext/mbedcrypto/*.patch 2> /dev/null | wc -l)
52if [ "$cnt" != "0" ] ; then
53 cd mbedtls
54 git apply ../trusted-firmware-m/lib/ext/mbedcrypto/*.patch
55 cd -
56fi
Xinyu Zhangb708f572020-09-15 11:43:46 +080057
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080058cnt=$(ls trusted-firmware-m/lib/ext/psa_arch_tests/*.patch 2> /dev/null | wc -l)
59if [ "$cnt" != "0" ] ; then
60 cd psa-arch-tests
61 git apply ../trusted-firmware-m/lib/ext/psa_arch_tests/*.patch
62 cd -
63fi
64
Xinyu Zhangab9d1ea2022-12-23 17:11:22 +080065cd trusted-firmware-m
66git apply ../tf-m-ci-scripts/build_helper/platform_settings/*.patch
67cd -
68
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080069rm -rf trusted-firmware-m/build
70mkdir trusted-firmware-m/build
71cd trusted-firmware-m/build
Dean Birchd0f9f8c2020-03-26 11:10:33 +000072
73eval "set -ex ; $build_commands"