From 17876d3d738a4bf7266a9cfe0187200559ace3b7 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 10 Dec 2019 19:17:34 +0800 Subject: [PATCH 1/2] cmake: some optimizations to build system tests --- tools/ci/test_build_system_cmake.sh | 85 +++++++++++++---------------- 1 file changed, 38 insertions(+), 47 deletions(-) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 1495d57ad2..f809ee8962 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -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 From f7668661672352b5ddd44f10625e74fdff2288d0 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Wed, 11 Dec 2019 09:55:06 +0800 Subject: [PATCH 2/2] cmake: remove intermediary libraries for some component --- components/app_trace/CMakeLists.txt | 4 +--- components/newlib/CMakeLists.txt | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index 1ef753dd61..e982d19115 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -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 $ gcov $) -target_link_libraries(${COMPONENT_LIB} PUBLIC gcov_apptrace ${LIBC}) +target_link_libraries(${COMPONENT_LIB} INTERFACE $ gcov $ ${LIBC}) diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index 90a0c24a8f..2738e130d9 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -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_link_libraries(${COMPONENT_LIB} PUBLIC extra) +target_link_libraries(${COMPONENT_LIB} INTERFACE ${LIBC} ${LIBM} gcc "$") set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)