diff --git a/.github/workflows/asio__build-target-test.yml b/.github/workflows/asio__build-target-test.yml index c6bd2cda32..55c60cc503 100644 --- a/.github/workflows/asio__build-target-test.yml +++ b/.github/workflows/asio__build-target-test.yml @@ -13,7 +13,7 @@ jobs: name: Build strategy: matrix: - idf_ver: ["latest", "release-v5.0"] + idf_ver: ["latest", "release-v5.0", "release-v5.1"] idf_target: ["esp32", "esp32s2"] example: ["asio_chat", "async_request", "socks4", "ssl_client_server", "tcp_echo_server", "udp_echo_server"] runs-on: ubuntu-20.04 diff --git a/components/asio/CMakeLists.txt b/components/asio/CMakeLists.txt index 3366545970..3ec69bac48 100644 --- a/components/asio/CMakeLists.txt +++ b/components/asio/CMakeLists.txt @@ -7,38 +7,40 @@ if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION) endif() set(asio_sources "asio/asio/src/asio.cpp") +set(asio_requires lwip) if(CONFIG_ASIO_SSL_SUPPORT) - if(CONFIG_ASIO_USE_ESP_OPENSSL) - list(APPEND asio_sources - "port/src/asio_ssl_impl.cpp" - "port/mbedtls/src/mbedtls_context.cpp" - "port/mbedtls/src/mbedtls_engine.cpp") - set(asio_priv_includes "port/mbedtls/include") - endif() - - if(CONFIG_ASIO_USE_ESP_WOLFSSL) - list(APPEND asio_sources - "asio/asio/src/asio_ssl.cpp") - endif() + list(APPEND asio_sources + "port/src/asio_ssl_impl.cpp" + "port/mbedtls/src/mbedtls_context.cpp" + "port/mbedtls/src/mbedtls_engine.cpp") + set(asio_priv_includes "port/mbedtls/include") endif() idf_component_register(SRCS ${asio_sources} INCLUDE_DIRS "asio/asio/include" "port/include" PRIV_INCLUDE_DIRS ${asio_priv_includes} - REQUIRES lwip) + PRIV_REQUIRES ${asio_requires}) -if(CONFIG_ASIO_SSL_SUPPORT) - if(CONFIG_ASIO_USE_ESP_WOLFSSL) - idf_component_get_property(wolflib esp-wolfssl COMPONENT_LIB) - idf_component_get_property(wolfdir esp-wolfssl COMPONENT_DIR) +target_compile_definitions(${COMPONENT_LIB} PUBLIC SA_RESTART=0x01 + SA_NOCLDSTOP=0x2 + SA_NOCLDWAIT=0x4 + ASIO_DISABLE_SERIAL_PORT + ASIO_SEPARATE_COMPILATION + ASIO_STANDALONE + ASIO_HAS_PTHREADS + OPENSSL_NO_ENGINE +) + +if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS) + target_compile_definitions(${COMPONENT_LIB} PUBLIC ASIO_NO_EXCEPTIONS) +endif() - target_link_libraries(${COMPONENT_LIB} PUBLIC ${wolflib}) - target_include_directories(${COMPONENT_LIB} PUBLIC ${wolfdir}/wolfssl/wolfssl) - endif() +if(NOT CONFIG_COMPILER_RTTI) + target_compile_definitions(${COMPONENT_LIB} PUBLIC ASIO_NO_TYPEID) +endif() - if(CONFIG_ASIO_USE_ESP_OPENSSL) +if(CONFIG_ASIO_SSL_SUPPORT) idf_component_get_property(mbedtls mbedtls COMPONENT_LIB) target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls}) - endif() endif() diff --git a/components/asio/Kconfig b/components/asio/Kconfig index 6754e1aa2f..8b46ae0652 100644 --- a/components/asio/Kconfig +++ b/components/asio/Kconfig @@ -6,23 +6,6 @@ menu "ESP-ASIO" default n help Enable support for basic SSL/TLS features, available for mbedTLS/OpenSSL - as well as wolfSSL TLS library. - - choice ASIO_SSL_LIBRARY_CHOICE - prompt "Choose SSL/TLS library for ESP-TLS (See help for more Info)" - default ASIO_USE_ESP_OPENSSL - depends on ASIO_SSL_SUPPORT - help - The ASIO support multiple backend TLS libraries. Currently the mbedTLS with a thin ESP-OpenSSL - port layer (default choice) and WolfSSL are supported. - Different TLS libraries may support different features and have different resource - usage. Consult the ESP-TLS documentation in ESP-IDF Programming guide for more details. - config ASIO_USE_ESP_OPENSSL - bool "esp-openssl" - config ASIO_USE_ESP_WOLFSSL - depends on TLS_STACK_WOLFSSL - bool "wolfSSL (License info in wolfSSL directory README)" - endchoice config ASIO_SSL_BIO_SIZE int "Size of BIO object" diff --git a/components/asio/asio b/components/asio/asio index 58384fb6af..9cf116aa63 160000 --- a/components/asio/asio +++ b/components/asio/asio @@ -1 +1 @@ -Subproject commit 58384fb6af92e7952b1534acb3004924f7ea0565 +Subproject commit 9cf116aa630b252fce8261143df755fe3256cbe9 diff --git a/components/asio/examples/asio_chat/main/idf_component.yml b/components/asio/examples/asio_chat/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/asio_chat/main/idf_component.yml +++ b/components/asio/examples/asio_chat/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/async_request/main/idf_component.yml b/components/asio/examples/async_request/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/async_request/main/idf_component.yml +++ b/components/asio/examples/async_request/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/async_request/sdkconfig.defaults b/components/asio/examples/async_request/sdkconfig.defaults new file mode 100644 index 0000000000..94184e28c9 --- /dev/null +++ b/components/asio/examples/async_request/sdkconfig.defaults @@ -0,0 +1,8 @@ +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 +CONFIG_COMPILER_CXX_EXCEPTIONS=y + +# +# Partition Table +# +# Leave some room for larger apps without needing to reduce other features +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y diff --git a/components/asio/examples/socks4/main/idf_component.yml b/components/asio/examples/socks4/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/socks4/main/idf_component.yml +++ b/components/asio/examples/socks4/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/ssl_client_server/main/idf_component.yml b/components/asio/examples/ssl_client_server/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/ssl_client_server/main/idf_component.yml +++ b/components/asio/examples/ssl_client_server/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/ssl_client_server/sdkconfig.defaults b/components/asio/examples/ssl_client_server/sdkconfig.defaults index 30bba61d40..8dffe267d0 100644 --- a/components/asio/examples/ssl_client_server/sdkconfig.defaults +++ b/components/asio/examples/ssl_client_server/sdkconfig.defaults @@ -2,6 +2,7 @@ CONFIG_ASIO_SSL_SUPPORT=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_COMPILER_CXX_EXCEPTIONS=y # # Partition Table diff --git a/components/asio/examples/tcp_echo_server/main/idf_component.yml b/components/asio/examples/tcp_echo_server/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/tcp_echo_server/main/idf_component.yml +++ b/components/asio/examples/tcp_echo_server/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/tcp_echo_server/sdkconfig.defaults b/components/asio/examples/tcp_echo_server/sdkconfig.defaults index b02a3a3ef6..94184e28c9 100644 --- a/components/asio/examples/tcp_echo_server/sdkconfig.defaults +++ b/components/asio/examples/tcp_echo_server/sdkconfig.defaults @@ -1,4 +1,5 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 +CONFIG_COMPILER_CXX_EXCEPTIONS=y # # Partition Table diff --git a/components/asio/examples/udp_echo_server/main/idf_component.yml b/components/asio/examples/udp_echo_server/main/idf_component.yml index 4a017ab77e..1a02b5d708 100644 --- a/components/asio/examples/udp_echo_server/main/idf_component.yml +++ b/components/asio/examples/udp_echo_server/main/idf_component.yml @@ -1,4 +1,6 @@ dependencies: ## Required IDF version idf: ">=5.0" - espressif/asio: ">=1.0.1" + espressif/asio: + version: "^1.14.1" + override_path: '../../../' diff --git a/components/asio/examples/udp_echo_server/sdkconfig.defaults b/components/asio/examples/udp_echo_server/sdkconfig.defaults index b02a3a3ef6..94184e28c9 100644 --- a/components/asio/examples/udp_echo_server/sdkconfig.defaults +++ b/components/asio/examples/udp_echo_server/sdkconfig.defaults @@ -1,4 +1,5 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 +CONFIG_COMPILER_CXX_EXCEPTIONS=y # # Partition Table diff --git a/components/asio/port/include/esp_asio_config.h b/components/asio/port/include/esp_asio_config.h index cf42183a3e..2ad9c79c76 100644 --- a/components/asio/port/include/esp_asio_config.h +++ b/components/asio/port/include/esp_asio_config.h @@ -1,45 +1,12 @@ /* - * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _ESP_ASIO_CONFIG_H_ #define _ESP_ASIO_CONFIG_H_ -// -// Enabling exceptions only when they are enabled in menuconfig -// -# include -# ifndef CONFIG_COMPILER_CXX_EXCEPTIONS -# define ASIO_NO_EXCEPTIONS -# endif // CONFIG_COMPILER_CXX_EXCEPTIONS - -# ifndef CONFIG_COMPILER_RTTI -# define ASIO_NO_TYPEID -# endif // CONFIG_COMPILER_RTTI - -// -// Use system sockets -// -# include "sys/socket.h" - -// -// Specific ASIO feature flags -// -# define ASIO_DISABLE_SERIAL_PORT -# define ASIO_SEPARATE_COMPILATION -# define ASIO_STANDALONE -# define ASIO_HAS_PTHREADS -# define ASIO_DISABLE_CONCEPTS - -# ifdef CONFIG_ASIO_USE_ESP_OPENSSL -# define ASIO_USE_ESP_OPENSSL -# define OPENSSL_NO_ENGINE -# define ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP -# include "openssl_stub.hpp" - -# elif CONFIG_ASIO_USE_ESP_WOLFSSL -# define ASIO_USE_WOLFSSL -# endif // CONFIG_ASIO_USE_ESP_OPENSSL +#define ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP +#include "openssl_stub.hpp" #endif // _ESP_ASIO_CONFIG_H_ diff --git a/components/asio/port/include/esp_exception.h b/components/asio/port/include/esp_exception.h deleted file mode 100644 index 41cc99b139..0000000000 --- a/components/asio/port/include/esp_exception.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef _ESP_EXCEPTION_H_ -#define _ESP_EXCEPTION_H_ - -// -// This exception stub is enabled only if exceptions are disabled in menuconfig -// -#if !defined(CONFIG_COMPILER_CXX_EXCEPTIONS) && defined (ASIO_NO_EXCEPTIONS) - -#include "esp_log.h" - -// -// asio exception stub -// -namespace asio { -namespace detail { -template -void throw_exception(const Exception &e) -{ - ESP_LOGE("esp32_asio_exception", "Caught exception: %s!", e.what()); - abort(); -} -} -} -#endif // CONFIG_COMPILER_CXX_EXCEPTIONS==1 && defined (ASIO_NO_EXCEPTIONS) - -#endif // _ESP_EXCEPTION_H_