blob: ecc10ce5d04b8dba92287604591fc5f811d1dc6a [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
Dean Birchd0f9f8c2020-03-26 11:10:33 +000033build_commands=$(python3 tf-m-ci-scripts/configs.py -b -g all $CONFIG_NAME)
34
Xinyu Zhang433771e2022-04-01 16:49:17 +080035if [ $CODE_COVERAGE_EN = "TRUE" ] && [[ $CONFIG_NAME =~ "GCC" ]] ; then
Karl Zhangb0c9d692021-01-08 16:30:31 +080036 build_commands=${build_commands/toolchain_GNUARM.cmake/toolchain_GNUARM.cmake -DTFM_CODE_COVERAGE=True}
Karl Zhangf6f467e2020-07-10 16:24:45 +080037 echo "Flag: Add compiler flag for build with code coverage supported."
38 echo $build_commands
39fi
40
Dean Birchd0f9f8c2020-03-26 11:10:33 +000041if [ -z "$build_commands" ] ; then
42 echo "No build commands found."
43 exit 1
44fi
45
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080046cnt=$(ls trusted-firmware-m/lib/ext/mbedcrypto/*.patch 2> /dev/null | wc -l)
47if [ "$cnt" != "0" ] ; then
48 cd mbedtls
49 git apply ../trusted-firmware-m/lib/ext/mbedcrypto/*.patch
50 cd -
51fi
Xinyu Zhangb708f572020-09-15 11:43:46 +080052
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080053cnt=$(ls trusted-firmware-m/lib/ext/psa_arch_tests/*.patch 2> /dev/null | wc -l)
54if [ "$cnt" != "0" ] ; then
55 cd psa-arch-tests
56 git apply ../trusted-firmware-m/lib/ext/psa_arch_tests/*.patch
57 cd -
58fi
59
Xinyu Zhangab9d1ea2022-12-23 17:11:22 +080060cd trusted-firmware-m
61git apply ../tf-m-ci-scripts/build_helper/platform_settings/*.patch
62cd -
63
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080064rm -rf trusted-firmware-m/build
65mkdir trusted-firmware-m/build
66cd trusted-firmware-m/build
Dean Birchd0f9f8c2020-03-26 11:10:33 +000067
68eval "set -ex ; $build_commands"