From 9362434c47e4fa9bfc92a7694a7513dc29d05f93 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 17 May 2022 15:13:30 +0800 Subject: [PATCH] build-system: add property for architecture (riscv/xtensa) riscv/xtensa is now a common component. --- components/esp32/CMakeLists.txt | 2 +- components/esp32c2/CMakeLists.txt | 2 +- components/esp32c3/CMakeLists.txt | 2 +- components/esp32h2/CMakeLists.txt | 2 +- components/esp32s2/CMakeLists.txt | 2 +- components/esp32s3/CMakeLists.txt | 2 +- components/riscv/CMakeLists.txt | 5 +++-- components/xtensa/CMakeLists.txt | 4 ++-- docs/en/api-guides/build-system.rst | 2 +- tools/cmake/build.cmake | 11 +++++++++++ 10 files changed, 23 insertions(+), 11 deletions(-) diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 1bede95f22..44c945184f 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES xtensa "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32) diff --git a/components/esp32c2/CMakeLists.txt b/components/esp32c2/CMakeLists.txt index f082e84edd..612b761e89 100644 --- a/components/esp32c2/CMakeLists.txt +++ b/components/esp32c2/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES riscv "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32c2) diff --git a/components/esp32c3/CMakeLists.txt b/components/esp32c3/CMakeLists.txt index bb327c4d89..9f7579e9b2 100644 --- a/components/esp32c3/CMakeLists.txt +++ b/components/esp32c3/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES riscv "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32c3) diff --git a/components/esp32h2/CMakeLists.txt b/components/esp32h2/CMakeLists.txt index 14103a5e51..dac0cddf4b 100644 --- a/components/esp32h2/CMakeLists.txt +++ b/components/esp32h2/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES riscv "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32h2) diff --git a/components/esp32s2/CMakeLists.txt b/components/esp32s2/CMakeLists.txt index b42c50b321..061e8e7fe7 100644 --- a/components/esp32s2/CMakeLists.txt +++ b/components/esp32s2/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES xtensa "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32s2) diff --git a/components/esp32s3/CMakeLists.txt b/components/esp32s3/CMakeLists.txt index f6f392a371..10dea19224 100644 --- a/components/esp32s3/CMakeLists.txt +++ b/components/esp32s3/CMakeLists.txt @@ -9,5 +9,5 @@ if(NOT BOOTLOADER_BUILD) set(legacy_reqs soc) endif() -idf_component_register(REQUIRES xtensa "${legacy_reqs}" +idf_component_register(REQUIRES "${legacy_reqs}" REQUIRED_IDF_TARGETS esp32s3) diff --git a/components/riscv/CMakeLists.txt b/components/riscv/CMakeLists.txt index 594345b6ea..e8a37ed461 100644 --- a/components/riscv/CMakeLists.txt +++ b/components/riscv/CMakeLists.txt @@ -1,10 +1,11 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(arch IDF_TARGET_ARCH) -# should test arch here not target: IDF-1754 -if(NOT "${target}" STREQUAL "esp32c3" AND NOT "${target}" STREQUAL "esp32h2" AND NOT "${target}" STREQUAL "esp32c2") +if(NOT "${arch}" STREQUAL "riscv") return() endif() + if(BOOTLOADER_BUILD) set(priv_requires soc) else() diff --git a/components/xtensa/CMakeLists.txt b/components/xtensa/CMakeLists.txt index e167b7c4d7..3d8522a9ae 100644 --- a/components/xtensa/CMakeLists.txt +++ b/components/xtensa/CMakeLists.txt @@ -1,7 +1,7 @@ idf_build_get_property(target IDF_TARGET) +idf_build_get_property(arch IDF_TARGET_ARCH) -# should test arch here not target: IDF-1754 -if("${target}" STREQUAL "esp32c3" OR "${target}" STREQUAL "esp32h2" OR "${target}" STREQUAL "esp32c2") +if(NOT "${arch}" STREQUAL "xtensa") return() endif() diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index d1fcda1061..ef762c9028 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -548,7 +548,7 @@ Common component requirements To avoid duplication, every component automatically requires some "common" IDF components even if they are not mentioned explicitly. Headers from these components can always be included. -The list of common components is: cxx, newlib, freertos, esp_hw_support, heap, log, soc, hal, esp_rom, esp_common, esp_system. +The list of common components is: cxx, newlib, freertos, esp_hw_support, heap, log, soc, hal, esp_rom, esp_common, esp_system, xtensa/riscv. Including components in the build ---------------------------------- diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 2449773b50..d4c64c6a58 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -401,6 +401,15 @@ macro(idf_build_process target) idf_build_set_property(IDF_TARGET ${target}) + if("${target}" STREQUAL "esp32" OR "${target}" STREQUAL "esp32s2" OR "${target}" STREQUAL "esp32s3") + idf_build_set_property(IDF_TARGET_ARCH "xtensa") + elseif("${target}" STREQUAL "linux") + # No arch specified for linux host builds at the moment + idf_build_set_property(IDF_TARGET_ARCH "") + else() + idf_build_set_property(IDF_TARGET_ARCH "riscv") + endif() + __build_set_default(PROJECT_DIR ${CMAKE_SOURCE_DIR}) __build_set_default(PROJECT_NAME ${CMAKE_PROJECT_NAME}) __build_set_default(PROJECT_VER 1) @@ -415,9 +424,11 @@ macro(idf_build_process target) __build_check_python() idf_build_get_property(target IDF_TARGET) + idf_build_get_property(arch IDF_TARGET_ARCH) if(NOT "${target}" STREQUAL "linux") idf_build_set_property(__COMPONENT_REQUIRES_COMMON ${target} APPEND) + idf_build_set_property(__COMPONENT_REQUIRES_COMMON ${arch} APPEND) endif() # Call for component manager to download dependencies for all components