blob: 669c15e9c33d6f575bc3e19e137bedd29a8109d8 [file] [log] [blame]
Gustavo Henrique Nihei38453f62021-11-03 15:00:19 -03001#!/usr/bin/env bash
2# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3# SPDX-License-Identifier: Apache-2.0
4
5SCRIPT_ROOTDIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
6MCUBOOT_ROOTDIR=$(realpath "${SCRIPT_ROOTDIR}/..")
7ESPRESSIF_ROOT="${MCUBOOT_ROOTDIR}/boot/espressif"
8IDF_PATH="${ESPRESSIF_ROOT}/hal/esp-idf"
9
10set -eo pipefail
11
Gustavo Henrique Nihei67b73d32021-12-09 17:05:10 -030012prepare_environment() {
Gustavo Henrique Nihei38453f62021-11-03 15:00:19 -030013 # Prepare the environment for ESP-IDF
14
15 . "${IDF_PATH}"/export.sh
Gustavo Henrique Nihei67b73d32021-12-09 17:05:10 -030016}
17
18build_mcuboot() {
19 local target=${MCUBOOT_TARGET}
20 local feature=${1}
21 local toolchain_file="${ESPRESSIF_ROOT}/tools/toolchain-${target}.cmake"
22 local mcuboot_config="${ESPRESSIF_ROOT}/bootloader.conf"
23 local build_dir=".build-${target}"
24
25 if [ -n "${feature}" ]; then
26 mcuboot_config="${ESPRESSIF_ROOT}/secureboot-${feature}.conf"
27 build_dir=".build-${target}-${feature}"
28 fi
Gustavo Henrique Nihei38453f62021-11-03 15:00:19 -030029
30 # Build MCUboot for selected target
31
32 cd "${MCUBOOT_ROOTDIR}" &>/dev/null
33 cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" \
34 -DMCUBOOT_TARGET="${target}" \
35 -DMCUBOOT_CONFIG_FILE="${mcuboot_config}" \
36 -DIDF_PATH="${IDF_PATH}" \
37 -B "${build_dir}" \
38 "${ESPRESSIF_ROOT}"
39 cmake --build "${build_dir}"/
40}
41
Gustavo Henrique Nihei67b73d32021-12-09 17:05:10 -030042prepare_environment
43
44if [ -n "${MCUBOOT_FEATURES}" ]; then
45 IFS=','
46 read -ra feature_list <<< "${MCUBOOT_FEATURES}"
47 for feature in "${feature_list[@]}"; do
48 echo "Building MCUboot with support for \"${feature}\""
49 build_mcuboot "${feature}"
50 done
51fi