blob: 9c2d2f59ed2d34983ab4e472807f8a37095ad7f1 [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
Xinyu Zhangff5d7712022-01-14 13:48:59 +080032# Export specific compiler path to env PATH
33compiler_path="${COMPILER_VERSION}_PATH"
34export PATH=$PATH:"${!compiler_path}"
35# Show compiler version
36if [ $COMPILER_VERSION =~ "ARMCLANG" ] ; then
37 armclang --version
38else
39 arm-none-eabi-gcc --version
40fi
41
Karl Zhang4a45dac2020-06-10 14:03:10 +080042set -ex
Dean Birchd0f9f8c2020-03-26 11:10:33 +000043build_commands=$(python3 tf-m-ci-scripts/configs.py -b -g all $CONFIG_NAME)
44
Karl Zhangf6f467e2020-07-10 16:24:45 +080045if [ $CODE_COVERAGE_EN = "TRUE" ] && [[ $CONFIG_NAME =~ "GNUARM" ]] ; then
Karl Zhangb0c9d692021-01-08 16:30:31 +080046 build_commands=${build_commands/toolchain_GNUARM.cmake/toolchain_GNUARM.cmake -DTFM_CODE_COVERAGE=True}
Karl Zhangf6f467e2020-07-10 16:24:45 +080047 echo "Flag: Add compiler flag for build with code coverage supported."
48 echo $build_commands
49fi
50
Dean Birchd0f9f8c2020-03-26 11:10:33 +000051if [ -z "$build_commands" ] ; then
52 echo "No build commands found."
53 exit 1
54fi
55
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080056cnt=$(ls trusted-firmware-m/lib/ext/mbedcrypto/*.patch 2> /dev/null | wc -l)
57if [ "$cnt" != "0" ] ; then
58 cd mbedtls
59 git apply ../trusted-firmware-m/lib/ext/mbedcrypto/*.patch
60 cd -
61fi
Xinyu Zhangb708f572020-09-15 11:43:46 +080062
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080063cnt=$(ls trusted-firmware-m/lib/ext/psa_arch_tests/*.patch 2> /dev/null | wc -l)
64if [ "$cnt" != "0" ] ; then
65 cd psa-arch-tests
66 git apply ../trusted-firmware-m/lib/ext/psa_arch_tests/*.patch
67 cd -
68fi
69
Xinyu Zhangc9e44ca2021-12-01 14:52:50 +080070psa_qcbor_link="https://github.com/laurencelundblade/QCBOR.git"
71psa_qcbor_path="$(pwd)/psa_qcbor"
72psa_qcbor_cfg_cmake="psa-arch-tests/api-tests/tools/cmake/common/CMakeExternal.cmake"
73sed -i "s#$psa_qcbor_link#$psa_qcbor_path#g" $psa_qcbor_cfg_cmake
74
Xinyu Zhange0aa69c2021-03-13 13:33:55 +080075rm -rf trusted-firmware-m/build
76mkdir trusted-firmware-m/build
77cd trusted-firmware-m/build
Dean Birchd0f9f8c2020-03-26 11:10:33 +000078
79eval "set -ex ; $build_commands"