Ver código fonte

asio coap: If LWIP IPV6 is disabled, automatically don't build asio & coap

- Removes need to manually exclude these components as shown at
  https://github.com/espressif/esp-idf/issues/3781#issuecomment-825742378

- Hide the config for these components if IPV6 is disabled

- The components are still included in the build, but with no source
  files
Angus Gratton 4 anos atrás
pai
commit
e305f29382

+ 8 - 0
components/asio/CMakeLists.txt

@@ -1,3 +1,11 @@
+if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION)
+    # note: the component is still included in the build so it can become visible again in config
+    # without needing to re-run CMake. However no source or header files are built.
+    message(STATUS "IPV6 support is disabled so the asio component will not be built")
+    idf_component_register()
+    return()
+endif()
+
 set(asio_sources "asio/asio/src/asio.cpp")
 
 if(CONFIG_ASIO_SSL_SUPPORT)

+ 2 - 0
components/asio/Kconfig

@@ -1,4 +1,6 @@
 menu "ESP-ASIO"
+    visible if LWIP_IPV6
+
     config ASIO_SSL_SUPPORT
         bool "Enable SSL/TLS support of ASIO"
         default n

+ 4 - 0
components/asio/component.mk

@@ -1,3 +1,5 @@
+ifdef CONFIG_LWIP_IPV6
+
 COMPONENT_ADD_INCLUDEDIRS := asio/asio/include port/include
 COMPONENT_PRIV_INCLUDEDIRS := private_include
 COMPONENT_SRCDIRS := asio/asio/src port/src
@@ -7,3 +9,5 @@ COMPONENT_OBJEXCLUDE := asio/asio/src/asio_ssl.o port/src/esp_asio_openssl_stubs
 endif
 
 COMPONENT_SUBMODULES += asio
+
+endif # CONFIG_LWIP_IPV6

+ 8 - 0
components/coap/CMakeLists.txt

@@ -1,3 +1,11 @@
+if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION)
+    message(STATUS "IPV6 support is disabled so the coap component will not be built")
+    # note: the component is still included in the build so it can become visible again in config
+    # without needing to re-run CMake. However no source or header files are built.
+    idf_component_register()
+    return()
+endif()
+
 set(include_dirs port/include port/include/coap libcoap/include libcoap/include/coap2)
 
 set(srcs

+ 1 - 0
components/coap/Kconfig

@@ -1,4 +1,5 @@
 menu "CoAP Configuration"
+    visible if LWIP_IPV6
 
     choice COAP_MBEDTLS_ENCRYPTION_MODE
         prompt "CoAP Encryption method"

+ 4 - 0
components/coap/component.mk

@@ -2,6 +2,8 @@
 # Component Makefile
 #
 
+ifdef CONFIG_LWIP_IPV6
+
 COMPONENT_ADD_INCLUDEDIRS := port/include port/include/coap libcoap/include libcoap/include/coap2
 
 COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o libcoap/src/coap_event.o libcoap/src/coap_hashkey.o libcoap/src/coap_session.o libcoap/src/coap_time.o port/coap_debug.o libcoap/src/encode.o libcoap/src/mem.o libcoap/src/net.o libcoap/src/option.o libcoap/src/pdu.o libcoap/src/resource.o libcoap/src/str.o libcoap/src/subscribe.o libcoap/src/uri.o port/coap_mbedtls.o libcoap/src/coap_io.o port/coap_notls.o
@@ -12,3 +14,5 @@ COMPONENT_SUBMODULES += libcoap
 
 # Silence format truncation warning, until it is fixed upstream
 port/coap_debug.o: CFLAGS += -Wno-format-truncation
+
+endif  # CONFIG_LWIP_IPV6

+ 2 - 3
components/lwip/Kconfig

@@ -324,9 +324,8 @@ menu "LWIP"
         default y
         help
             Enable IPv6 function. If not use IPv6 function, set this option to n.
-            If disable LWIP_IPV6, not adding coap and asio component into the build.
-            Please assign them to EXCLUDE_COMPONENTS in the make or cmake file in your
-            project directory, so that the component will not be compiled.
+            If disabling LWIP_IPV6 then some other components (coap and asio) will
+            no longer be available.
 
     config LWIP_IPV6_AUTOCONFIG
         bool "Enable IPV6 stateless address autoconfiguration (SLAAC)"

+ 0 - 1
examples/protocols/sockets/tcp_server/CMakeLists.txt

@@ -5,7 +5,6 @@ cmake_minimum_required(VERSION 3.5)
 # (Not part of the boilerplate)
 # This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
 set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
-set(EXCLUDE_COMPONENTS "coap" "asio")
 
 include($ENV{IDF_PATH}/tools/cmake/project.cmake)
 project(tcp_server)

+ 0 - 1
examples/protocols/sockets/tcp_server/Makefile

@@ -6,6 +6,5 @@
 PROJECT_NAME := tcp_server
 
 EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common
-EXCLUDE_COMPONENTS = coap asio
 
 include $(IDF_PATH)/make/project.mk