Skip to content

Commit 4828e16

Browse files
authored
esp32: simplify CMakeLists file for chip component (#36883)
1 parent 4aea78d commit 4828e16

File tree

2 files changed

+12
-163
lines changed

2 files changed

+12
-163
lines changed

config/esp32/components/chip/CMakeLists.txt

+12-162
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ endif()
3131

3232
include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake)
3333

34-
set(CHIP_REQUIRE_COMPONENTS esp_eth freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash)
35-
36-
if(NOT "${IDF_TARGET}" STREQUAL "esp32h2")
37-
list(APPEND CHIP_REQUIRE_COMPONENTS mdns)
38-
endif()
34+
set(CHIP_REQUIRE_COMPONENTS esp_eth freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash mdns)
3935

4036
if (NOT CMAKE_BUILD_EARLY_EXPANSION)
4137
if (CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
@@ -420,170 +416,24 @@ target_include_directories(${COMPONENT_LIB} INTERFACE
420416
"${CHIP_ROOT}/config/esp32/${CONFIG_CHIP_EXTERNAL_PLATFORM_DIR}/../../"
421417
)
422418

423-
idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB)
424-
425-
idf_build_get_property(idf_target IDF_TARGET)
426-
set(target_name "${idf_target}")
427-
428-
if(CONFIG_BT_ENABLED)
429-
idf_component_get_property(bt_lib bt COMPONENT_LIB)
430-
if((target_name STREQUAL "esp32h2") OR (target_name STREQUAL "esp32c2") OR (target_name STREQUAL "esp32c6"))
431-
idf_component_get_property(bt_dir bt COMPONENT_DIR)
432-
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}>)
433-
if (EXISTS ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a)
434-
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
435-
elseif(EXISTS ${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/${target_name}/libble_app.a)
436-
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/${target_name}/libble_app.a")
437-
else()
438-
message(WARNING "There is no libble_app.a in the given path")
439-
endif()
440-
elseif(target_name STREQUAL "esp32p4")
441-
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}>)
442-
else()
443-
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}> -lbtdm_app)
444-
endif()
445-
endif()
446-
447-
if (CONFIG_ENABLE_CHIP_SHELL)
448-
idf_component_get_property(console_lib console COMPONENT_LIB)
449-
list(APPEND chip_libraries $<TARGET_FILE:${console_lib}>)
450-
endif()
451-
452-
if(CONFIG_OPENTHREAD_ENABLED)
453-
idf_component_get_property(openthread_lib openthread COMPONENT_LIB)
454-
list(APPEND chip_libraries $<TARGET_FILE:${openthread_lib}>)
455-
if (CONFIG_IEEE802154_ENABLED)
456-
idf_component_get_property(ieee802154_lib ieee802154 COMPONENT_LIB)
457-
list(APPEND chip_libraries $<TARGET_FILE:${ieee802154_lib}>)
458-
endif()
459-
endif()
460-
461-
if(NOT CONFIG_USE_MINIMAL_MDNS)
462-
idf_build_get_property(build_components BUILD_COMPONENTS)
463-
# For IDF v5.x, the mdns component was moved to idf_managed_components.
464-
# We should use 'espressif__mdns' for 'idf_component_get_property'.
465-
if("espressif__mdns" IN_LIST build_components)
466-
idf_component_get_property(mdns_lib espressif__mdns COMPONENT_LIB)
467-
list(APPEND chip_libraries $<TARGET_FILE:${mdns_lib}>)
468-
elseif("mdns" IN_LIST build_components)
469-
idf_component_get_property(mdns_lib mdns COMPONENT_LIB)
470-
list(APPEND chip_libraries $<TARGET_FILE:${mdns_lib}>)
471-
endif()
472-
endif()
473-
474-
if(CONFIG_OPENTHREAD_BORDER_ROUTER)
475-
idf_component_get_property(rcp_update_lib espressif__esp_rcp_update COMPONENT_LIB)
476-
list(APPEND chip_libraries $<TARGET_FILE:${rcp_update_lib}>)
477-
idf_component_get_property(serial_flasher_lib espressif__esp-serial-flasher COMPONENT_LIB)
478-
list(APPEND chip_libraries $<TARGET_FILE:${serial_flasher_lib}>)
479-
endif()
480-
481-
if (CONFIG_ENABLE_ENCRYPTED_OTA)
482-
idf_component_get_property(esp_encrypted_img_lib espressif__esp_encrypted_img COMPONENT_LIB)
483-
list(APPEND chip_libraries $<TARGET_FILE:${esp_encrypted_img_lib}>)
484-
endif()
485-
486-
# Let user set EXECUTABLE_COMPONENT_NAME and defaults to main if not specified
487-
if (NOT EXECUTABLE_COMPONENT_NAME)
488-
set(EXECUTABLE_COMPONENT_NAME "main")
489-
endif()
490-
491-
if (CONFIG_ENABLE_DELTA_OTA)
492-
idf_component_get_property(esp_delta_ota_lib espressif__esp_delta_ota COMPONENT_LIB)
493-
list(APPEND chip_libraries $<TARGET_FILE:${esp_delta_ota_lib}>)
494-
endif()
495-
496-
idf_component_get_property(main_lib ${EXECUTABLE_COMPONENT_NAME} COMPONENT_LIB)
497-
list(APPEND chip_libraries $<TARGET_FILE:${main_lib}>)
498-
499-
if (CONFIG_SEC_CERT_DAC_PROVIDER)
500-
idf_component_get_property(esp32_secure_cert_mgr_lib espressif__esp_secure_cert_mgr COMPONENT_LIB)
501-
list(APPEND chip_libraries $<TARGET_FILE:${esp32_secure_cert_mgr_lib}>)
502-
endif()
503-
504-
if (CONFIG_ENABLE_ESP_INSIGHTS_TRACE)
505-
idf_build_get_property(build_components BUILD_COMPONENTS)
506-
# esp_insights can be used as an independent component or through component manager so,
507-
# We should check and add the right component.
508-
if("espressif__esp_insights" IN_LIST build_components)
509-
idf_component_get_property(esp_insights_lib espressif__esp_insights COMPONENT_LIB)
510-
elseif("esp_insights" IN_LIST build_components)
511-
idf_component_get_property(esp_insights_lib esp_insights COMPONENT_LIB)
512-
endif()
513-
514-
list(APPEND chip_libraries $<TARGET_FILE:${esp_insights_lib}>)
515-
endif()
516-
517-
idf_component_get_property(lwip_lib lwip COMPONENT_LIB)
518-
list(APPEND chip_libraries $<TARGET_FILE:${lwip_lib}>)
519-
520-
if ("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3" OR CONFIG_ESP32_WIFI_ENABLED)
521-
idf_component_get_property(esp_wifi_lib esp_wifi COMPONENT_LIB)
522-
list(APPEND chip_libraries $<TARGET_FILE:${esp_wifi_lib}>)
523-
endif()
524-
525-
if (CONFIG_ESP32_WIFI_ENABLED)
526-
idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR)
527-
if (CONFIG_IDF_TARGET_ESP32C2)
528-
set(blobs core net80211 pp)
529-
else()
530-
set(blobs core mesh net80211 pp)
531-
endif()
532-
533-
foreach(blob ${blobs})
534-
list(APPEND chip_libraries "${esp_wifi_dir}/lib/${target_name}/lib${blob}.a")
535-
endforeach()
536-
537-
idf_component_get_property(wpa_supplicant_lib wpa_supplicant COMPONENT_LIB)
538-
list(APPEND chip_libraries $<TARGET_FILE:${wpa_supplicant_lib}>)
539-
endif()
540-
541-
if (CONFIG_ETH_ENABLED)
542-
idf_component_get_property(esp_eth_lib esp_eth COMPONENT_LIB)
543-
list(APPEND chip_libraries $<TARGET_FILE:${esp_eth_lib}>)
419+
set(matter_requires lwip freertos console bt)
420+
idf_build_get_property(build_components BUILD_COMPONENTS)
421+
if("espressif__mdns" IN_LIST build_components)
422+
list(APPEND matter_requires espressif__mdns)
423+
elseif("mdns" IN_LIST build_components)
424+
list(APPEND matter_requires mdns)
544425
endif()
545426

546-
idf_component_get_property(esp_netif_lib esp_netif COMPONENT_LIB)
547-
list(APPEND chip_libraries $<TARGET_FILE:${esp_netif_lib}>)
548-
549-
idf_component_get_property(esp_hw_support_lib esp_hw_support COMPONENT_LIB)
550-
list(APPEND chip_libraries $<TARGET_FILE:${esp_hw_support_lib}>)
551-
552-
if (NOT CONFIG_IDF_TARGET_ESP32P4)
553-
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
554-
idf_component_get_property(esp_phy_dir esp_phy COMPONENT_DIR)
555-
list(APPEND chip_libraries $<TARGET_FILE:${esp_phy_lib}>)
556-
557-
if (CONFIG_IDF_TARGET_ESP32)
558-
set(phy_blobs phy rtc)
559-
elseif (CONFIG_IDF_TARGET_ESP32S2)
560-
set(phy_blobs phy)
561-
else()
562-
set(phy_blobs phy btbb)
563-
endif()
564-
foreach(phy_blob ${phy_blobs})
565-
list(APPEND chip_libraries "${esp_phy_dir}/lib/${target_name}/lib${phy_blob}.a")
566-
endforeach()
427+
if (CONFIG_OPENTHREAD_BORDER_ROUTER)
428+
list(APPEND matter_requires espressif__esp_rcp_update)
567429
endif()
568430

569-
set(components_to_link esp_event hal esp_system soc efuse vfs driver freertos esp_timer)
570-
if (NOT CONFIG_IDF_TARGET_ESP32P4)
571-
list(APPEND components_to_link esp_coex)
572-
endif()
573-
idf_build_get_property(build_components BUILD_COMPONENTS)
574-
foreach(component ${components_to_link})
575-
# Some of the components are not present in IDF v4.x
576-
# So, Check if the component is in the list of build components
577-
if("${component}" IN_LIST build_components)
578-
idf_component_get_property(lib_name ${component} COMPONENT_LIB)
579-
list(APPEND chip_libraries $<TARGET_FILE:${lib_name}>)
580-
endif()
581-
endforeach()
431+
add_prebuilt_library(matterlib "${CMAKE_CURRENT_BINARY_DIR}/lib/libCHIP.a"
432+
REQUIRES ${matter_requires})
582433

583434
target_link_libraries(${COMPONENT_LIB} INTERFACE -Wl,--start-group
584435
${chip_libraries}
585-
$<TARGET_FILE:mbedcrypto> $<TARGET_FILE:mbedx509>
586-
$<TARGET_FILE:${mbedtls_lib}>
436+
matterlib
587437
-Wl,--end-group)
588438

589439
# Make the component dependent on our CHIP build

config/esp32/components/chip/idf_component.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ dependencies:
44
version: "^1.1.0"
55
rules:
66
- if: "idf_version >=5.0"
7-
- if: "target != esp32h2"
87

98
espressif/esp_secure_cert_mgr:
109
version: "^2.5.0"

0 commit comments

Comments
 (0)