From 05220d9cda064e5b852dcbe16a88346b5322476c Mon Sep 17 00:00:00 2001 From: Sagar Bijwe Date: Fri, 11 Jan 2019 11:59:59 +0530 Subject: [PATCH] CMake: Make IDF_PATH available to Kconfiglib when not explicitly set. When IDF_PATH is not set by the user, cmake infers the same through other means and sets it as an environment variable. However, some sub-invocation of cmake may not see this variable as it is not set in the parent. This change adds a custom command for exporting IDF_PATH just before invoking ldgen so that IDF_PATH can be used in Kconfig without any errors. --- tools/ci/test_build_system_cmake.sh | 15 +++++++++++++++ tools/cmake/ldgen.cmake | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index b19f1f0a3e..a8886d68b7 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -236,6 +236,21 @@ function run_tests() mv CMakeLists.txt.bak CMakeLists.txt assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} + print_status "Can build with IDF_PATH unset and inferred by cmake when Kconfig needs it to be set" + clean_build_dir + sed -i.bak 's/ENV{IDF_PATH}/{IDF_PATH}/' CMakeLists.txt + export IDF_PATH_BACKUP="$IDF_PATH" + mv main/Kconfig.projbuild main/Kconfig.projbuild_bak + echo "source \"\$IDF_PATH/examples/wifi/getting_started/station/main/Kconfig.projbuild\"" > main/Kconfig.projbuild + (unset IDF_PATH && + cd build && + cmake -G Ninja .. -DIDF_PATH=${IDF_PATH_BACKUP} && + ninja) || failure "Ninja build failed" + mv CMakeLists.txt.bak CMakeLists.txt + mv main/Kconfig.projbuild_bak main/Kconfig.projbuild + assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} + + # Next two tests will use this fake 'esp31b' target export fake_target=esp31b mkdir -p components/$fake_target diff --git a/tools/cmake/ldgen.cmake b/tools/cmake/ldgen.cmake index 09d580ea58..b8e58c0ee1 100644 --- a/tools/cmake/ldgen.cmake +++ b/tools/cmake/ldgen.cmake @@ -63,6 +63,7 @@ function(ldgen_process_template template output) --env "COMPONENT_KCONFIGS=${COMPONENT_KCONFIGS}" --env "COMPONENT_KCONFIGS_PROJBUILD=${COMPONENT_KCONFIGS_PROJBUILD}" --env "IDF_CMAKE=y" + --env "IDF_PATH=${IDF_PATH}" --env "IDF_TARGET=${IDF_TARGET}" DEPENDS ${template} $ ${SDKCONFIG} ldgen_section_infos ) @@ -79,4 +80,4 @@ function(ldgen_add_dependencies) if(IDF_PROJECT_EXECUTABLE) add_dependencies(${IDF_PROJECT_EXECUTABLE} ldgen) endif() -endfunction() \ No newline at end of file +endfunction()