forked from espressif/esp-idf
refactor(lwip): Added on/off switch for LwIP stack
* This switch allows applications to replace lwip with a different IP stack or just make it build if it is a dependency but not actually needed.
This commit is contained in:
@@ -35,7 +35,7 @@ set_property(TARGET ${lwip} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 5)
|
||||
else()
|
||||
# Check if LWIP in the build for linux target to adapt esp-tls compatibility layer
|
||||
idf_build_get_property(build_components BUILD_COMPONENTS)
|
||||
if("lwip" IN_LIST build_components)
|
||||
if(CONFIG_LWIP_ENABLE)
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_TLS_WITH_LWIP=1)
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -1,10 +1,12 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
|
||||
if(CONFIG_LWIP_ENABLE)
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
# ESP platform targets share the same port folder
|
||||
set(target esp32xx)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(include_dirs
|
||||
set(include_dirs
|
||||
include
|
||||
include/apps
|
||||
include/apps/sntp
|
||||
@@ -16,7 +18,7 @@ set(include_dirs
|
||||
port/${target}/include/sys
|
||||
)
|
||||
|
||||
set(srcs
|
||||
set(srcs
|
||||
"apps/sntp/sntp.c"
|
||||
"lwip/src/api/api_lib.c"
|
||||
"lwip/src/api/api_msg.c"
|
||||
@@ -100,7 +102,7 @@ set(srcs
|
||||
"port/sockets_ext.c"
|
||||
"port/freertos/sys_arch.c")
|
||||
|
||||
if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
list(APPEND srcs
|
||||
"lwip/src/netif/ppp/auth.c"
|
||||
"lwip/src/netif/ppp/ccp.c"
|
||||
@@ -132,35 +134,39 @@ if(CONFIG_LWIP_PPP_SUPPORT)
|
||||
"lwip/src/netif/ppp/polarssl/md4.c"
|
||||
"lwip/src/netif/ppp/polarssl/md5.c"
|
||||
"lwip/src/netif/ppp/polarssl/sha1.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
# Support for vfs and linker fragments only for target builds
|
||||
set(priv_requires vfs)
|
||||
set(linker_fragments linker.lf)
|
||||
if(CONFIG_VFS_SUPPORT_IO)
|
||||
list(APPEND srcs "port/${target}/vfs_lwip.c")
|
||||
else()
|
||||
list(APPEND srcs "port/${target}/no_vfs_syscalls.c")
|
||||
endif()
|
||||
else()
|
||||
else()
|
||||
# This wraps some posix IO functions to conditionally pass control to lwip
|
||||
list(APPEND srcs "port/${target}/vfs_lwip.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_LWIP_ICMP)
|
||||
if(CONFIG_LWIP_ICMP)
|
||||
list(APPEND srcs
|
||||
"apps/ping/esp_ping.c"
|
||||
"apps/ping/ping.c"
|
||||
"apps/ping/ping_sock.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_LWIP_DHCPS)
|
||||
if(CONFIG_LWIP_DHCPS)
|
||||
list(APPEND srcs "apps/dhcpserver/dhcpserver.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_LWIP_DHCP_RESTORE_LAST_IP)
|
||||
if(CONFIG_LWIP_DHCP_RESTORE_LAST_IP)
|
||||
list(APPEND srcs "port/esp32xx/netif/dhcp_state.c")
|
||||
endif()
|
||||
endif() # CONFIG_LWIP_ENABLE
|
||||
|
||||
if(NOT ${target} STREQUAL "linux")
|
||||
set(priv_requires vfs)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
@@ -168,43 +174,44 @@ idf_component_register(SRCS "${srcs}"
|
||||
LDFRAGMENTS ${linker_fragments}
|
||||
PRIV_REQUIRES ${priv_requires})
|
||||
|
||||
# lots of LWIP source files evaluate macros that check address of stack variables
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_LWIP_COMPONENT_BUILD)
|
||||
if(CONFIG_LWIP_ENABLE)
|
||||
# lots of LWIP source files evaluate macros that check address of stack variables
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-address)
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_LWIP_COMPONENT_BUILD)
|
||||
|
||||
set_source_files_properties(
|
||||
set_source_files_properties(
|
||||
lwip/src/netif/ppp/pppos.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-type-limits
|
||||
)
|
||||
# "comparison is always false due to limited range of data type" warning
|
||||
# when setting CONFIG_LWIP_TCP_WND_DEFAULT to 65535
|
||||
set_source_files_properties(
|
||||
# "comparison is always false due to limited range of data type" warning
|
||||
# when setting CONFIG_LWIP_TCP_WND_DEFAULT to 65535
|
||||
set_source_files_properties(
|
||||
lwip/src/core/tcp.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-type-limits
|
||||
)
|
||||
)
|
||||
|
||||
# ignore some declaration mismatches
|
||||
set_source_files_properties(
|
||||
# ignore some declaration mismatches
|
||||
set_source_files_properties(
|
||||
lwip/src/netif/ppp/chap_ms.c
|
||||
PROPERTIES COMPILE_FLAGS
|
||||
-Wno-array-parameter
|
||||
)
|
||||
)
|
||||
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
idf_component_optional_requires(PRIVATE openthread)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_ETH_ENABLED)
|
||||
if(CONFIG_ETH_ENABLED)
|
||||
idf_component_optional_requires(PRIVATE esp_eth)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_LWIP_DHCP_RESTORE_LAST_IP)
|
||||
if(CONFIG_LWIP_DHCP_RESTORE_LAST_IP)
|
||||
idf_component_optional_requires(PRIVATE nvs_flash)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${target} STREQUAL "linux")
|
||||
if(${target} STREQUAL "linux")
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads)
|
||||
@@ -217,4 +224,5 @@ if(${target} STREQUAL "linux")
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __wrap_${wrap}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -1,4 +1,15 @@
|
||||
menu "LWIP"
|
||||
config LWIP_ENABLE
|
||||
bool "Enable LwIP stack"
|
||||
default y if !IDF_TARGET_LINUX
|
||||
default n if IDF_TARGET_LINUX
|
||||
help
|
||||
Builds normally if selected. Excludes LwIP from build if unselected, even if it is a
|
||||
dependency of a component or application.
|
||||
Some applications can switch their IP stacks, e.g., when switching between chip
|
||||
and Linux targets (LwIP stack vs. Linux IP stack). Since the LwIP dependency cannot
|
||||
easily be excluded based on a Kconfig option, it has to be a dependency in all cases.
|
||||
This switch allows the LwIP stack to be built selectively, even if it is a dependency.
|
||||
|
||||
config LWIP_LOCAL_HOSTNAME
|
||||
string "Local netif hostname"
|
||||
|
@@ -134,8 +134,7 @@ endif()
|
||||
|
||||
# net_sockets.c should only be compiled if BSD socket functions are available.
|
||||
# Do this by checking if lwip component is included into the build.
|
||||
idf_build_get_property(build_components BUILD_COMPONENTS)
|
||||
if(lwip IN_LIST build_components)
|
||||
if(CONFIG_LWIP_ENABLE)
|
||||
list(APPEND mbedtls_target_sources "${COMPONENT_DIR}/port/net_sockets.c")
|
||||
idf_component_get_property(lwip_lib lwip COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} ${linkage_type} ${lwip_lib})
|
||||
|
@@ -1,3 +1,4 @@
|
||||
CONFIG_IDF_TARGET="linux"
|
||||
CONFIG_EXAMPLE_IPV4_ADDR="127.0.0.1"
|
||||
CONFIG_EXAMPLE_CONNECT_LWIP_TAPIF=n
|
||||
CONFIG_LWIP_ENABLE=y
|
||||
|
@@ -0,0 +1 @@
|
||||
CONFIG_LWIP_ENABLE=y
|
Reference in New Issue
Block a user