mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/optimize_some_build_system_tests' into 'master'
cmake: some optimizations to build system tests See merge request espressif/esp-idf!6972
This commit is contained in:
commit
3b52eddf6b
@ -38,7 +38,5 @@ idf_component_register(SRCS "${srcs}"
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-coverage")
|
||||
|
||||
# Force app_trace to also appear later than gcov in link line
|
||||
add_library(gcov_apptrace INTERFACE)
|
||||
idf_component_get_property(app_trace app_trace COMPONENT_LIB)
|
||||
target_link_libraries(gcov_apptrace INTERFACE $<TARGET_FILE:${app_trace}> gcov $<TARGET_FILE:${app_trace}>)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC gcov_apptrace ${LIBC})
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${app_trace}> gcov $<TARGET_FILE:${app_trace}> ${LIBC})
|
||||
|
@ -28,10 +28,8 @@ idf_component_register(SRCS "${srcs}"
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
|
||||
# Toolchain libraries require code defined in this component
|
||||
add_library(extra INTERFACE)
|
||||
idf_component_get_property(newlib newlib COMPONENT_LIB)
|
||||
target_link_libraries(extra INTERFACE ${LIBC} ${LIBM} gcc "$<TARGET_FILE:${newlib}>")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC extra)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE ${LIBC} ${LIBM} gcc "$<TARGET_FILE:${newlib}>")
|
||||
|
||||
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
||||
|
||||
|
@ -119,19 +119,11 @@ function run_tests()
|
||||
rm -f ${TESTDIR}/template/version.txt
|
||||
|
||||
print_status "Get the version of app from git describe. Project is not inside IDF and do not have a tag only a hash commit."
|
||||
idf.py build >> log.log || failure "Failed to build"
|
||||
idf.py reconfigure >> log.log || failure "Failed to build"
|
||||
version="Project version: "
|
||||
version+=$(git describe --always --tags --dirty)
|
||||
grep "${version}" log.log || failure "Project version should have a hash commit"
|
||||
|
||||
print_status "Can set COMPONENT_SRCS with spaces"
|
||||
clean_build_dir
|
||||
touch main/main2.c
|
||||
${SED} -i 's/^set(COMPONENT_SRCS.*/set(COMPONENT_SRCS "main.c main2.c")/' main/CMakeLists.txt
|
||||
idf.py build || failure "Set COMPONENT_SRCS with spaces build failed"
|
||||
git checkout -- main/CMakeLists.txt
|
||||
rm main/main2.c
|
||||
|
||||
print_status "Moving BUILD_DIR_BASE out of tree"
|
||||
clean_build_dir
|
||||
OUTOFTREE_BUILD=${TESTDIR}/alt_build
|
||||
@ -276,6 +268,31 @@ function run_tests()
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
|
||||
|
||||
print_status "can build with phy_init_data"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with PHY_INIT_DATA"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} ${PHY_INIT_BIN}
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
print_status "can build with ethernet component disabled"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ETH_USE_SPI_ETHERNET=" >> sdkconfig.defaults
|
||||
echo "CONFIG_ETH_USE_ESP32_EMAC=" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with ethernet component disabled"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
# Next two tests will use this fake 'esp31b' target
|
||||
export fake_target=esp31b
|
||||
mkdir -p components/$fake_target
|
||||
@ -320,13 +337,6 @@ function run_tests()
|
||||
mv CMakeLists.txt.bak CMakeLists.txt
|
||||
rm -rf components sdkconfig build
|
||||
|
||||
print_status "Can find toolchain file in component directory"
|
||||
clean_build_dir
|
||||
mv ${IDF_PATH}/tools/cmake/toolchain-esp32.cmake ${IDF_PATH}/components/esp32/
|
||||
idf.py build || failure "Failed to build with toolchain file in component directory"
|
||||
mv ${IDF_PATH}/components/esp32/toolchain-esp32.cmake ${IDF_PATH}/tools/cmake/
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
|
||||
print_status "Can build with auto generated CMakeLists.txt"
|
||||
clean_build_dir
|
||||
mv CMakeLists.txt CMakeLists.bak
|
||||
@ -335,17 +345,23 @@ function run_tests()
|
||||
mv CMakeLists.bak CMakeLists.txt
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
|
||||
print_status "Can find toolchain file in component directory"
|
||||
clean_build_dir
|
||||
mv ${IDF_PATH}/tools/cmake/toolchain-esp32.cmake ${IDF_PATH}/components/esp32/
|
||||
(idf.py reconfigure > /dev/null && grep "${IDF_PATH}/components/esp32/toolchain-esp32.cmake" build/CMakeCache.txt) || failure "Failed to find toolchain file in component directory"
|
||||
mv ${IDF_PATH}/components/esp32/toolchain-esp32.cmake ${IDF_PATH}/tools/cmake/
|
||||
|
||||
print_status "Setting EXTRA_COMPONENT_DIRS works"
|
||||
clean_build_dir
|
||||
(idf.py reconfigure | grep "$PWD/main") || failure "Failed to verify original `main` directory"
|
||||
mkdir -p main/main/main # move main component contents to another directory
|
||||
mv main/* main/main/main
|
||||
cp CMakeLists.txt CMakeLists.bak # set EXTRA_COMPONENT_DIRS to point to the other directory
|
||||
${SED} -i "s%cmake_minimum_required(VERSION \([0-9]\+\).\([0-9]\+\))%cmake_minimum_required(VERSION \1.\2)\nset(EXTRA_COMPONENT_DIRS main/main/main)%" CMakeLists.txt
|
||||
idf.py build || failure "Build with EXTRA_COMPONENT_DIRS set failed"
|
||||
(idf.py reconfigure | grep "$PWD/main/main/main") || failure "Failed to set EXTRA_COMPONENT_DIRS"
|
||||
mv CMakeLists.bak CMakeLists.txt # revert previous modifications
|
||||
mv main/main/main/* main
|
||||
rm -rf main/main
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
|
||||
print_status "sdkconfig should have contents of all files: sdkconfig, sdkconfig.defaults, sdkconfig.defaults.IDF_TARGET"
|
||||
idf.py clean > /dev/null
|
||||
@ -361,31 +377,6 @@ function run_tests()
|
||||
grep "CONFIG_PARTITION_TABLE_TWO_OTA=y" sdkconfig || failure "The define from sdkconfig should be into sdkconfig"
|
||||
rm sdkconfig sdkconfig.defaults sdkconfig.defaults.esp32
|
||||
|
||||
print_status "can build with phy_init_data"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION=y" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with PHY_INIT_DATA"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} ${PHY_INIT_BIN}
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
print_status "can build with ethernet component disabled"
|
||||
idf.py clean > /dev/null
|
||||
idf.py fullclean > /dev/null
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "CONFIG_ETH_USE_SPI_ETHERNET=" >> sdkconfig.defaults
|
||||
echo "CONFIG_ETH_USE_ESP32_EMAC=" >> sdkconfig.defaults
|
||||
idf.py reconfigure > /dev/null
|
||||
idf.py build || failure "Failed to build with ethernet component disabled"
|
||||
assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN}
|
||||
rm sdkconfig
|
||||
rm sdkconfig.defaults
|
||||
|
||||
print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround"
|
||||
# Test for libraries compiled within ESP-IDF
|
||||
rm -rf build
|
||||
@ -426,7 +417,7 @@ EOF
|
||||
rm -f sdkconfig.defaults
|
||||
rm -f sdkconfig
|
||||
echo "" > ${IDF_PATH}/sdkconfig.rename
|
||||
idf.py build > /dev/null
|
||||
idf.py reconfigure > /dev/null
|
||||
echo "CONFIG_TEST_OLD_OPTION=y" >> sdkconfig
|
||||
echo "CONFIG_TEST_OLD_OPTION CONFIG_TEST_NEW_OPTION" >> ${IDF_PATH}/sdkconfig.rename
|
||||
echo -e "\n\
|
||||
@ -437,7 +428,7 @@ menu \"test\"\n\
|
||||
help\n\
|
||||
TEST_NEW_OPTION description\n\
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
idf.py build > /dev/null
|
||||
idf.py reconfigure > /dev/null
|
||||
grep "CONFIG_TEST_OLD_OPTION=y" sdkconfig || failure "CONFIG_TEST_OLD_OPTION should be in sdkconfig for backward compatibility"
|
||||
grep "CONFIG_TEST_NEW_OPTION=y" sdkconfig || failure "CONFIG_TEST_NEW_OPTION should be now in sdkconfig"
|
||||
grep "#define CONFIG_TEST_NEW_OPTION 1" build/config/sdkconfig.h || failure "sdkconfig.h should contain the new macro"
|
||||
@ -463,7 +454,7 @@ menu \"test\"\n\
|
||||
help\n\
|
||||
TEST_NEW_OPTION description\n\
|
||||
endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
idf.py build > /dev/null
|
||||
idf.py reconfigure > /dev/null
|
||||
grep "CONFIG_TEST_OLD_OPTION=7" sdkconfig || failure "CONFIG_TEST_OLD_OPTION=7 should be in sdkconfig for backward compatibility"
|
||||
grep "CONFIG_TEST_NEW_OPTION=7" sdkconfig || failure "CONFIG_TEST_NEW_OPTION=7 should be in sdkconfig"
|
||||
rm -f sdkconfig.defaults
|
||||
@ -487,7 +478,7 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
|
||||
print_status "Custom bootloader overrides original"
|
||||
clean_build_dir
|
||||
(mkdir components && cd components && cp -r $IDF_PATH/components/bootloader .)
|
||||
idf.py build
|
||||
idf.py bootloader
|
||||
grep "$PWD/components/bootloader/subproject/main/bootloader_start.c" build/bootloader/compile_commands.json \
|
||||
|| failure "Custom bootloader source files should be built instead of the original's"
|
||||
rm -rf components
|
||||
|
Loading…
Reference in New Issue
Block a user