Files
esp-idf/components/esp_netif/CMakeLists.txt
Guillaume Souchere d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00

63 lines
1.6 KiB
CMake

set(srcs_lwip
"lwip/esp_netif_lwip.c"
"lwip/esp_netif_sntp.c"
"lwip/esp_netif_lwip_defaults.c"
"lwip/netif/wlanif.c"
"lwip/netif/ethernetif.c"
"lwip/netif/esp_pbuf_ref.c")
set(srcs
"esp_netif_handlers.c"
"esp_netif_objects.c"
"esp_netif_defaults.c")
set(include_dirs "include")
set(priv_include_dirs "private_include")
if(CONFIG_PPP_SUPPORT)
list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c lwip/netif/ppp.c)
endif()
if(CONFIG_ESP_NETIF_L2_TAP)
list(APPEND srcs vfs_l2tap/esp_vfs_l2tap.c)
endif()
if(CONFIG_ESP_NETIF_BRIDGE_EN)
list(APPEND srcs_lwip lwip/esp_netif_br_glue.c)
endif()
if(CONFIG_ESP_NETIF_LOOPBACK)
list(APPEND srcs loopback/esp_netif_loopback.c)
elseif(CONFIG_ESP_NETIF_TCPIP_LWIP)
list(APPEND srcs ${srcs_lwip})
list(APPEND priv_include_dirs lwip)
endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
REQUIRES esp_event
PRIV_REQUIRES esp_netif_stack
LDFRAGMENTS linker.lf)
idf_define_esp_err_codes(HEADERS include/esp_netif_types.h)
if(CONFIG_ESP_NETIF_L2_TAP OR CONFIG_ESP_NETIF_BRIDGE_EN)
set(optional_requires "")
if(CONFIG_ESP_NETIF_L2_TAP)
list(APPEND optional_requires "vfs")
endif()
if(CONFIG_ESP_NETIF_BRIDGE_EN)
list(APPEND optional_requires "esp_wifi")
endif()
list(APPEND optional_requires "esp_eth")
idf_component_optional_requires(PRIVATE "${optional_requires}")
endif()
target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_NETIF_COMPONENT_BUILD)