From 0d5660fbde8fe343d1bf4b4a351f78c7dd1217a7 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 4 Dec 2018 22:04:00 +0800 Subject: [PATCH 1/2] cmake: fix error in converting project variables to namespaced ones Closes https://github.com/espressif/esp-idf/issues/2764 --- tools/cmake/project.cmake | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 04459a1e8..f90847b84 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -18,25 +18,31 @@ endfunction() macro(project name) - # Bridge existing documented variable names with library namespaced variables in order for old projects to work. + # Bridge existing documented variable names with library namespaced + # variables in order for old projects to work. + if(COMPONENT_DIRS) spaces2list(COMPONENT_DIRS) foreach(component_dir ${COMPONENT_DIRS}) - get_filename_component(full_path ${component_dir} ABSOLUTE) - get_filename_component(idf_path "${IDF_PATH}/components" ABSOLUTE) - - if(NOT full_path STREQUAL idf_path) - set(IDF_EXTRA_COMPONENT_DIRS "${IDF_EXTRA_COMPONENT_DIRS} ${component_dir}") - endif() + get_filename_component(component_dir ${component_dir} ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR}) + list(APPEND IDF_COMPONENT_DIRS "${component_dir}") endforeach() - else() - if(MAIN_SRCS) - set(IDF_EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} ${CMAKE_SOURCE_DIR}/components") - else() - set(IDF_EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} \ - ${CMAKE_SOURCE_DIR}/components ${CMAKE_SOURCE_DIR}/main") - endif() + endif() + + if(EXTRA_COMPONENT_DIRS) + spaces2list(EXTRA_COMPONENT_DIRS) + + foreach(component_dir ${EXTRA_COMPONENT_DIRS}) + get_filename_component(component_dir ${component_dir} ABSOLUTE BASE_DIR ${CMAKE_SOURCE_DIR}) + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${component_dir}") + endforeach() + endif() + + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/components") + + if(NOT MAIN_SRCS) + list(APPEND IDF_EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/main") endif() if(COMPONENTS) From b11238df4d8d6c65c388804d2884f2d2746b9a3e Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Wed, 5 Dec 2018 10:44:14 +0800 Subject: [PATCH 2/2] ci: add test for setting EXTRA_COMPONENT_DIRS --- tools/ci/test_build_system_cmake.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 7f138d561..f12eeae5e 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -266,6 +266,18 @@ function run_tests() mv CMakeLists.bak CMakeLists.txt assert_built ${APP_BINS} ${BOOTLOADER_BINS} ${PARTITION_BIN} + print_status "Setting EXTRA_COMPONENT_DIRS works" + clean_build_dir + 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" + 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 "All tests completed" if [ -n "${FAILURES}" ]; then echo "Some failures were detected:"