diff --git a/components/esp_rom/host_test/rom_test/CMakeLists.txt b/components/esp_rom/host_test/rom_test/CMakeLists.txt index 4b5320016b..c84747fef4 100644 --- a/components/esp_rom/host_test/rom_test/CMakeLists.txt +++ b/components/esp_rom/host_test/rom_test/CMakeLists.txt @@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(test_rom_host) diff --git a/components/esp_rom/host_test/rom_test/sdkconfig.defaults b/components/esp_rom/host_test/rom_test/sdkconfig.defaults index c18d7771a4..89c65632c9 100644 --- a/components/esp_rom/host_test/rom_test/sdkconfig.defaults +++ b/components/esp_rom/host_test/rom_test/sdkconfig.defaults @@ -1,2 +1,3 @@ CONFIG_IDF_TARGET="linux" CONFIG_COMPILER_CXX_EXCEPTIONS=y +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n diff --git a/components/log/CMakeLists.txt b/components/log/CMakeLists.txt index 9f9e11d644..b57770a234 100644 --- a/components/log/CMakeLists.txt +++ b/components/log/CMakeLists.txt @@ -1,12 +1,10 @@ idf_build_get_property(target IDF_TARGET) set(srcs "log.c") set(priv_requires "") -set(requires "") if(${target} STREQUAL "linux") - # We leave log buffers out for now on Linux since it's rarely used. Excplicitely add esp_rom to Linux target + # We leave log buffers out for now on Linux since it's rarely used. Explicitely add esp_rom to Linux target # since we don't have the common components there yet. list(APPEND srcs "log_linux.c") - list(APPEND requires esp_rom) else() list(APPEND srcs "log_buffers.c") list(APPEND priv_requires soc) @@ -15,7 +13,6 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS "include" LDFRAGMENTS linker.lf - REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) if(NOT ${target} STREQUAL "linux") diff --git a/components/log/host_test/log_test/CMakeLists.txt b/components/log/host_test/log_test/CMakeLists.txt index 087f96fe7e..7d53a82335 100644 --- a/components/log/host_test/log_test/CMakeLists.txt +++ b/components/log/host_test/log_test/CMakeLists.txt @@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(test_log_host) diff --git a/components/log/host_test/log_test/sdkconfig.defaults b/components/log/host_test/log_test/sdkconfig.defaults index b1e1b9b77a..a35fc5148f 100644 --- a/components/log/host_test/log_test/sdkconfig.defaults +++ b/components/log/host_test/log_test/sdkconfig.defaults @@ -5,3 +5,4 @@ CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y CONFIG_LOG_DEFAULT_LEVEL=5 CONFIG_LOG_MAXIMUM_LEVEL=5 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n diff --git a/components/nvs_flash/CMakeLists.txt b/components/nvs_flash/CMakeLists.txt index 04f10bd46c..7134f8eb16 100644 --- a/components/nvs_flash/CMakeLists.txt +++ b/components/nvs_flash/CMakeLists.txt @@ -15,12 +15,6 @@ set(srcs "src/nvs_api.cpp" set(public_req "spi_flash") -# Current linux-based builds don't have common components. -# Add the necessary ones manually: -if(${target} STREQUAL "linux") - list(APPEND public_req "esp_rom" "esp_common" "log") -endif() - set(include_dirs "include") idf_component_register(SRCS "${srcs}" diff --git a/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt b/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt index 4ab7323a9a..976484eb85 100644 --- a/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_page_test/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(COMPONENTS main) idf_component_set_property(spi_flash USE_MOCK 1) +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/") +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") idf_build_set_property(COMPILE_DEFINITIONS "-DNO_DEBUG_STORAGE" APPEND) project(host_nvs_page_test) diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index a5691ac106..69a2a604f1 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -30,17 +30,14 @@ if(${spi_flash_mock}) "${MOCK_GEN_DIR}/Mockesp_spi_flash.c" "${MOCK_GEN_DIR}/Mockesp_flash.c") - set(requires "cmock") - if(${target} STREQUAL "linux") list(APPEND include_dirs "${CMAKE_CURRENT_SOURCE_DIR}/../spi_flash/sim/stubs/soc/include") - list(APPEND requires "esp_common") endif() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" - REQUIRES "${requires}") + REQUIRES "cmock") add_custom_command( OUTPUT ruby_found SYMBOLIC diff --git a/components/unity/CMakeLists.txt b/components/unity/CMakeLists.txt index 4dcfcb8389..14184db294 100644 --- a/components/unity/CMakeLists.txt +++ b/components/unity/CMakeLists.txt @@ -1,3 +1,5 @@ +idf_build_get_property(target IDF_TARGET) + set(srcs "unity/src/unity.c") @@ -20,9 +22,7 @@ if(CONFIG_UNITY_ENABLE_FIXTURE) list(APPEND includes "unity/extras/fixture/src") endif() -if(${IDF_TARGET} STREQUAL "linux") - list(APPEND requires "esp_common") -else() +if(NOT "${target}" STREQUAL "linux") list(APPEND srcs "unity_port_esp32.c") endif() @@ -30,7 +30,7 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${includes} REQUIRES ${requires}) -if(NOT ${IDF_TARGET} STREQUAL "linux") +if(NOT "${target}" STREQUAL "linux") target_compile_definitions(${COMPONENT_LIB} PUBLIC -DUNITY_INCLUDE_CONFIG_H ) diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/CMakeLists.txt b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/CMakeLists.txt index 5a2a6bf745..6f8842cefb 100644 --- a/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/CMakeLists.txt +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/CMakeLists.txt @@ -10,4 +10,4 @@ idf_component_register(SRCS "gpio_cxx_test.cpp" "${cpp_component}/include" "${cpp_component}/test" # FIXME for unity_cxx.hpp, make it generally available instead $ENV{IDF_PATH}/tools/catch - REQUIRES driver cmock esp_common) + REQUIRES driver cmock) diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 9b6503a5af..f67aaf991b 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -126,6 +126,9 @@ endfunction() # properties used for the processing phase of the build. # function(__build_init idf_path) + + set(target ${IDF_TARGET}) + # Create the build target, to which the ESP-IDF build properties, dependencies are attached to. # Must be global so as to be accessible from any subdirectory in custom projects. add_library(__idf_build_target STATIC IMPORTED GLOBAL) @@ -155,9 +158,10 @@ function(__build_init idf_path) endif() endforeach() - - idf_build_get_property(target IDF_TARGET) - if(NOT target STREQUAL "linux") + if("${target}" STREQUAL "linux") + set(requires_common freertos log esp_rom esp_common) + idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${requires_common}") + else() # Set components required by all other components in the build # # - lwip is here so that #include works without any special provisions @@ -411,10 +415,8 @@ macro(idf_build_process target) idf_build_get_property(target IDF_TARGET) - if(NOT target STREQUAL "linux") + if(NOT "${target}" STREQUAL "linux") idf_build_set_property(__COMPONENT_REQUIRES_COMMON ${target} APPEND) - else() - idf_build_set_property(__COMPONENT_REQUIRES_COMMON "") endif() # Call for component manager to download dependencies for all components diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 11b6f45c30..5b9595342d 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -1,6 +1,11 @@ # Designed to be included from an IDF app's CMakeLists.txt file cmake_minimum_required(VERSION 3.5) +include(${CMAKE_CURRENT_LIST_DIR}/targets.cmake) +# Initialize build target for this build using the environment variable or +# value passed externally. +__target_init() + # The mere inclusion of this CMake file sets up some interal build properties. # These properties can be modified in between this inclusion the the idf_build_process # call. @@ -33,10 +38,6 @@ else() idf_build_set_property(EXTRA_CMAKE_ARGS "") endif() -# Initialize build target for this build using the environment variable or -# value passed externally. -__target_init() - # # Get the project version from either a version file or the Git revision. This is passed # to the idf_build_process call. Dependencies are also set here for when the version file @@ -172,7 +173,6 @@ function(__project_init components_var test_components_var) endif() endfunction() - # Add component directories to the build, given the component filters, exclusions # extra directories, etc. passed from the root CMakeLists.txt. if(COMPONENT_DIRS)