2020-07-15 12:18:33 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Usage: build_template_app.sh [-p]
|
|
|
|
# -p: optional, if specified, do a fast build for every chip target with cmake and only the default
|
|
|
|
# config. Otherwise permutations of (chip target, build system, configs) which were not built in
|
|
|
|
# the fast build will be built.
|
|
|
|
#
|
|
|
|
# Needs to be called under IDF root folder
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2024-03-20 01:19:53 -04:00
|
|
|
TEMPLATE_APP_PATH="esp-idf-template"
|
|
|
|
|
2020-07-15 12:18:33 -04:00
|
|
|
gen_configs() {
|
|
|
|
# CONFIG_COMPILER_OPTIMIZATION_NONE with flag -O0
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_COMPILER_OPTIMIZATION_NONE=y" > ${TEMPLATE_APP_PATH}/sdkconfig.ci.O0
|
2021-04-15 02:13:40 -04:00
|
|
|
|
2020-07-15 12:18:33 -04:00
|
|
|
# CONFIG_COMPILER_OPTIMIZATION_SIZE with flag -Os
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_COMPILER_OPTIMIZATION_SIZE=y" > ${TEMPLATE_APP_PATH}/sdkconfig.ci.Os
|
|
|
|
echo "CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.Os
|
2021-04-15 02:13:40 -04:00
|
|
|
|
2020-07-15 12:18:33 -04:00
|
|
|
# CONFIG_COMPILER_OPTIMIZATION_PERF with flag -O2
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_COMPILER_OPTIMIZATION_PERF=y" > ${TEMPLATE_APP_PATH}/sdkconfig.ci.O2
|
|
|
|
echo "CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.O2
|
2022-11-24 01:05:40 -05:00
|
|
|
# -O2 makes the bootloader too large to fit in the default space, otherwise(!)
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.O2
|
2020-07-15 12:18:33 -04:00
|
|
|
|
2020-09-24 10:49:12 -04:00
|
|
|
# This part will be built in earlier stage (pre_build job) with only cmake. Built with make in later stage
|
2023-06-02 03:16:50 -04:00
|
|
|
# CONFIG_COMPILER_OPTIMIZATION_DEBUG with flag -Og
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_COMPILER_OPTIMIZATION_DEBUG=y" > ${TEMPLATE_APP_PATH}/sdkconfig.ci2.Og
|
|
|
|
echo "CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG=y" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci2.Og
|
2022-02-11 02:30:54 -05:00
|
|
|
# -Og makes the bootloader too large to fit in the default space, otherwise(!)
|
2024-03-20 01:19:53 -04:00
|
|
|
echo "CONFIG_PARTITION_TABLE_OFFSET=0x10000" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci2.Og
|
2020-07-15 12:18:33 -04:00
|
|
|
|
|
|
|
# Needs to be built with specific extra flags
|
|
|
|
# Same as O2, but also disable assertions.
|
2024-03-20 01:19:53 -04:00
|
|
|
cp ${TEMPLATE_APP_PATH}/sdkconfig.ci.O2 ${TEMPLATE_APP_PATH}/sdkconfig.ci3.no_assert
|
|
|
|
echo "CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci3.no_assert
|
2020-07-15 12:18:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
get_config_str() {
|
|
|
|
CONFIG_STR=
|
|
|
|
until [ $# -eq 0 ]
|
|
|
|
do
|
|
|
|
CONFIG_STR+=" --config $1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
echo ${CONFIG_STR}
|
|
|
|
}
|
|
|
|
|
|
|
|
build_stage2() {
|
|
|
|
CONFIG_STR=$(get_config_str sdkconfig.ci.*=)
|
|
|
|
|
|
|
|
# Override EXTRA_CFLAGS and EXTRA_CXXFLAGS in the environment
|
|
|
|
export EXTRA_CFLAGS=${PEDANTIC_CFLAGS/-Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function/}
|
|
|
|
export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS/-Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function/}
|
2022-07-12 22:34:02 -04:00
|
|
|
python -m idf_build_apps build -vv \
|
2024-03-20 01:19:53 -04:00
|
|
|
-p ${TEMPLATE_APP_PATH} \
|
2022-07-12 22:34:02 -04:00
|
|
|
-t all \
|
|
|
|
${CONFIG_STR} \
|
|
|
|
--work-dir ${BUILD_PATH}/cmake \
|
|
|
|
--build-dir ${BUILD_DIR} \
|
|
|
|
--build-log ${BUILD_LOG_CMAKE} \
|
|
|
|
--size-file size.json \
|
2024-01-09 06:08:58 -05:00
|
|
|
--keep-going \
|
2022-07-12 22:34:02 -04:00
|
|
|
--collect-size-info size_info.txt \
|
2024-03-13 02:24:43 -04:00
|
|
|
--default-build-targets esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32c61
|
2020-07-15 12:18:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
build_stage1() {
|
|
|
|
CONFIG_STR=$(get_config_str sdkconfig.ci2.*=)
|
2022-07-12 22:34:02 -04:00
|
|
|
python -m idf_build_apps build -vv \
|
2024-03-20 01:19:53 -04:00
|
|
|
-p ${TEMPLATE_APP_PATH} \
|
2022-07-12 22:34:02 -04:00
|
|
|
-t all \
|
|
|
|
${CONFIG_STR} \
|
|
|
|
--work-dir ${BUILD_PATH}/cmake \
|
|
|
|
--build-dir ${BUILD_DIR} \
|
|
|
|
--build-log ${BUILD_LOG_CMAKE} \
|
|
|
|
--size-file size.json \
|
|
|
|
--collect-size-info size_info.txt \
|
2024-03-13 02:24:43 -04:00
|
|
|
--default-build-targets esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32c61
|
2020-07-15 12:18:33 -04:00
|
|
|
}
|
|
|
|
|
2024-03-20 01:19:53 -04:00
|
|
|
# TODO: IDF-9197 remove the additional test for esp32c5 beta3
|
|
|
|
build_c5beta3() {
|
|
|
|
# Update the config to select C5 beta3
|
|
|
|
C5BETA3_CFG="CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION=y\nCONFIG_IDF_TARGET_ESP32C5_MP_VERSION=n"
|
|
|
|
if [ $1 = 1 ]
|
|
|
|
then
|
|
|
|
echo "${C5BETA3_CFG}" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci2.Og
|
|
|
|
CONFIG_STR=$(get_config_str sdkconfig.ci2.*=)
|
|
|
|
KEEP_GOING=""
|
|
|
|
else
|
|
|
|
echo "${C5BETA3_CFG}" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.O0
|
|
|
|
echo "${C5BETA3_CFG}" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.Os
|
|
|
|
echo "${C5BETA3_CFG}" >> ${TEMPLATE_APP_PATH}/sdkconfig.ci.O2
|
|
|
|
CONFIG_STR=$(get_config_str sdkconfig.ci.*=)
|
|
|
|
KEEP_GOING=" --keep-going"
|
|
|
|
fi
|
|
|
|
python -m idf_build_apps build -vv \
|
|
|
|
-p ${TEMPLATE_APP_PATH} \
|
|
|
|
-t esp32c5 \
|
|
|
|
${CONFIG_STR} \
|
|
|
|
--work-dir ${BUILD_PATH}/cmake \
|
|
|
|
--build-dir ${BUILD_DIR} \
|
|
|
|
--build-log ${BUILD_LOG_CMAKE} \
|
|
|
|
--size-file size.json \
|
|
|
|
${KEEP_GOING} \
|
|
|
|
--collect-size-info size_info.txt \
|
|
|
|
--default-build-targets esp32c5
|
|
|
|
}
|
|
|
|
|
2020-07-15 12:18:33 -04:00
|
|
|
# Default arguments
|
|
|
|
# STAGE:
|
|
|
|
# 1 (-p): fast build, 2 (default): regular build
|
|
|
|
STAGE=2
|
|
|
|
|
|
|
|
# Parse arguments: -p for STAGE
|
|
|
|
for arg in $*
|
|
|
|
do
|
|
|
|
if [ ${arg} = "-p" ]; then
|
|
|
|
STAGE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p ${BUILD_PATH}/cmake
|
|
|
|
mkdir -p ${LOG_PATH}
|
|
|
|
rm -f scan.json
|
|
|
|
|
|
|
|
gen_configs
|
|
|
|
|
|
|
|
if [ ${STAGE} = 1 ]
|
|
|
|
then
|
|
|
|
build_stage1
|
|
|
|
else
|
|
|
|
build_stage2
|
2020-11-10 02:40:01 -05:00
|
|
|
fi
|
2024-03-20 01:19:53 -04:00
|
|
|
|
|
|
|
# TODO: IDF-9197 remove the additional test for esp32c5 beta3
|
|
|
|
echo "Build ESP32-C5 beta3 additionally"
|
|
|
|
build_c5beta3 ${STAGE}
|