From 4d14cec349c4f523034163acbcac35e50326df07 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Fri, 17 Nov 2023 17:38:57 +0200 Subject: [PATCH] CMake: use idf_component_register Documentation for ESP-IDF versions 4.4, 4.5, 5.0 and 5.1 do not contain any references to register_component(). This seems to be the way how things where done in ESP-IDF version 3.x. For some reason this picks up a bunch of components we don't use. Exclude those. The net result is more lines of CMake code, but if at some point Espressif drops support for register_component() we are prepared. Total sizes before: Used stat D/IRAM: 180122 bytes ( 165734 remain, 52.1% used) .data size: 30524 bytes .bss size: 25760 bytes .text size: 122811 bytes .vectors size: 1027 bytes Used Flash size : 2061331 bytes .text: 1497211 bytes .rodata: 563864 bytes Total image size: 2215693 bytes (.bin may be padded larger) Total sizes after: Total sizes: Used stat D/IRAM: 180122 bytes ( 165734 remain, 52.1% used) .data size: 30524 bytes .bss size: 25760 bytes .text size: 122811 bytes .vectors size: 1027 bytes Used Flash size : 2061335 bytes .text: 1497215 bytes .rodata: 563864 bytes Total image size: 2215697 bytes (.bin may be padded larger) --- CMakeLists.txt | 35 +++++++++++++++++++++++-- main/CMakeLists.txt | 62 +++++++++++++++++---------------------------- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59c447f1..7f17ce06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,6 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(COMPONENTS main) - if($ENV{CI}) message("CI detected, disabling MultiNet support") else() @@ -16,6 +14,39 @@ else() add_definitions(-DWILLOW_USER_AGENT="Willow/0.1") endif() +set(EXCLUDE_COMPONENTS + "adf_utils" + "app_trace" + "battery_service" + "bluetooth_service" + "cmock" + "coredump_upload_service" + "esp_codec_dev" + "esp_eth" + "esp_event_cast" + "esp_gdbstub" + "esp_hid" + "esp_http_server" + "esp_https_ota" + "esp_https_server" + "esp_local_ctrl" + "espcoredump" + "idf_test" + "ieee802154" + "mqtt" + "openthread" + "ota_service" + "perfmon" + "playlist" + "protobuf-c" + "protocomm" + "touch_element" + "ulp" + "unity" + "usb" + "wifi_provisioning" +) + include($ENV{ADF_PATH}/CMakeLists.txt) include($ENV{IDF_PATH}/tools/cmake/project.cmake) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index e30a687a..975aa0b6 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,45 +1,29 @@ -set(COMPONENT_SRCS - "audio.c" - "config.c" - "display.c" - "endpoint/hass.c" - "endpoint/openhab.c" - "endpoint/rest.c" - "http.c" - "input.c" - "log.c" - "lv_img_hand_left.c" - "network.c" - "ota.c" - "slvgl.c" - "system.c" - "tasks.c" - "timer.c" - "ui.c" - "was.c" - "main.c" -) -set(COMPONENT_ADD_INCLUDEDIRS .) -set(COMPONENT_PRIV_REQUIRES - app_update - audio_board - audio_hal - audio_pipeline - audio_recorder - audio_sal - audio_stream - esp_http_client - esp_peripherals - esp_websocket_client - input_key_service - spiffs -) - if(CONFIG_WILLOW_ETHERNET) - set(COMPONENT_SRCS ${COMPONENT_SRCS} "net/ethernet.c") + set(WILLOW_ETHERNET_SRC_DIRS "net") endif() -register_component() +idf_component_register( + SRC_DIRS + "." + "endpoint" + "${WILLOW_ETHERNET_SRC_DIRS}" + INCLUDE_DIRS + "." + "${WILLOW_ETHERNET_SRC_DIRS}" + PRIV_REQUIRES + app_update + audio_board + audio_hal + audio_pipeline + audio_recorder + audio_sal + audio_stream + esp_http_client + esp_peripherals + esp_websocket_client + input_key_service + spiffs +) spiffs_create_partition_image(user ../spiffs/user FLASH_IN_PROJECT)