Merge branch 'bugfix/remove_lwip_from_common_requirements' into 'master'

build system: remove lwip from common component requirements

Closes IDF-1258

See merge request espressif/esp-idf!17785
This commit is contained in:
Ivan Grokhotkov 2022-05-03 17:34:34 +08:00
commit 2f7935666d
18 changed files with 74 additions and 62 deletions

View File

@ -12,8 +12,10 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS . esp-tls-crypto INCLUDE_DIRS . esp-tls-crypto
PRIV_INCLUDE_DIRS "private_include" PRIV_INCLUDE_DIRS "private_include"
REQUIRES mbedtls # lwip and mbedtls are public requirements becasue esp_tls.h
PRIV_REQUIRES lwip http_parser) # includes sys/socket.h and mbedtls header files.
REQUIRES mbedtls lwip
PRIV_REQUIRES http_parser)
if(CONFIG_ESP_TLS_USING_WOLFSSL) if(CONFIG_ESP_TLS_USING_WOLFSSL)
idf_component_get_property(wolfssl esp-wolfssl COMPONENT_LIB) idf_component_get_property(wolfssl esp-wolfssl COMPONENT_LIB)

View File

@ -4,5 +4,6 @@ idf_component_register(SRCS "esp_http_client.c"
"lib/http_utils.c" "lib/http_utils.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "lib/include" PRIV_INCLUDE_DIRS "lib/include"
REQUIRES http_parser # lwip is a public requirement because esp_http_client.h includes sys/socket.h
REQUIRES http_parser lwip
PRIV_REQUIRES tcp_transport) PRIV_REQUIRES tcp_transport)

View File

@ -95,3 +95,11 @@ idf_component_optional_requires(PRIVATE app_update)
if(CONFIG_PM_ENABLE) if(CONFIG_PM_ENABLE)
idf_component_optional_requires(PRIVATE pm) idf_component_optional_requires(PRIVATE pm)
endif() endif()
if(CONFIG_VFS_SUPPORT_IO)
idf_component_optional_requires(PRIVATE vfs)
endif()
if(CONFIG_SW_COEXIST_ENABLE OR CONFIG_EXTERNAL_COEX_ENABLE)
idf_component_optional_requires(PRIVATE esp_wifi)
endif()

View File

@ -26,7 +26,6 @@
#include "esp_spi_flash.h" #include "esp_spi_flash.h"
#include "esp_flash_internal.h" #include "esp_flash_internal.h"
#include "esp_newlib.h" #include "esp_newlib.h"
#include "esp_vfs_dev.h"
#include "esp_timer.h" #include "esp_timer.h"
#include "esp_efuse.h" #include "esp_efuse.h"
#include "esp_flash_encrypt.h" #include "esp_flash_encrypt.h"
@ -41,7 +40,9 @@
/***********************************************/ /***********************************************/
// Headers for other components init functions // Headers for other components init functions
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
#include "esp_coexist_internal.h" #include "esp_coexist_internal.h"
#endif
#if CONFIG_ESP_COREDUMP_ENABLE #if CONFIG_ESP_COREDUMP_ENABLE
#include "esp_core_dump.h" #include "esp_core_dump.h"
@ -58,8 +59,12 @@
#include "esp_private/pm_impl.h" #include "esp_private/pm_impl.h"
#endif #endif
#include "esp_pthread.h" #if CONFIG_VFS_SUPPORT_IO
#include "esp_vfs_dev.h"
#include "esp_vfs_console.h" #include "esp_vfs_console.h"
#endif
#include "esp_pthread.h"
#include "esp_private/esp_clk.h" #include "esp_private/esp_clk.h"
#include "esp_private/brownout.h" #include "esp_private/brownout.h"

View File

@ -31,7 +31,7 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
REQUIRES esp_event esp_phy REQUIRES esp_event esp_phy
PRIV_REQUIRES driver esptool_py esp_netif esp_pm esp_timer nvs_flash PRIV_REQUIRES driver esptool_py esp_netif esp_pm esp_timer nvs_flash
wpa_supplicant hal ${extra_priv_requires} wpa_supplicant hal lwip ${extra_priv_requires}
LDFRAGMENTS "${ldfragments}") LDFRAGMENTS "${ldfragments}")
if(CONFIG_ESP32_WIFI_ENABLED) if(CONFIG_ESP32_WIFI_ENABLED)

View File

@ -17,10 +17,17 @@ endif()
idf_component_register(SRCS "${mbedtls_srcs}" idf_component_register(SRCS "${mbedtls_srcs}"
INCLUDE_DIRS "${mbedtls_include_dirs}" INCLUDE_DIRS "${mbedtls_include_dirs}"
REQUIRES lwip
PRIV_REQUIRES "${priv_requires}" PRIV_REQUIRES "${priv_requires}"
) )
# Determine the type of mbedtls component library
if(mbedtls_srcs STREQUAL "")
# For no sources in component library we must use "INTERFACE"
set(linkage_type INTERFACE)
else()
set(linkage_type PUBLIC)
endif()
if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE) if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE)
set(bundle_name "x509_crt_bundle") set(bundle_name "x509_crt_bundle")
@ -103,8 +110,7 @@ endif()
set(mbedtls_targets mbedtls mbedcrypto mbedx509) set(mbedtls_targets mbedtls mbedcrypto mbedx509)
set(mbedtls_target_sources "${COMPONENT_DIR}/port/mbedtls_debug.c" set(mbedtls_target_sources "${COMPONENT_DIR}/port/mbedtls_debug.c")
"${COMPONENT_DIR}/port/net_sockets.c")
if(CONFIG_MBEDTLS_DYNAMIC_BUFFER) if(CONFIG_MBEDTLS_DYNAMIC_BUFFER)
set(mbedtls_target_sources ${mbedtls_target_sources} set(mbedtls_target_sources ${mbedtls_target_sources}
@ -114,6 +120,15 @@ set(mbedtls_target_sources ${mbedtls_target_sources}
"${COMPONENT_DIR}/port/dynamic/esp_ssl_tls.c") "${COMPONENT_DIR}/port/dynamic/esp_ssl_tls.c")
endif() 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)
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})
endif()
# Add port files to mbedtls targets # Add port files to mbedtls targets
target_sources(mbedtls PRIVATE ${mbedtls_target_sources}) target_sources(mbedtls PRIVATE ${mbedtls_target_sources})
@ -240,14 +255,6 @@ set_property(TARGET mbedcrypto APPEND PROPERTY LINK_INTERFACE_LIBRARIES mbedtls)
set_property(TARGET mbedcrypto APPEND PROPERTY LINK_LIBRARIES idf::driver idf::${target}) set_property(TARGET mbedcrypto APPEND PROPERTY LINK_LIBRARIES idf::driver idf::${target})
set_property(TARGET mbedcrypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES idf::driver idf::${target}) set_property(TARGET mbedcrypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES idf::driver idf::${target})
# Link mbedtls libraries to component library
if(mbedtls_srcs STREQUAL "")
# For no sources in component library we must use "INTERFACE"
set(linkage_type INTERFACE)
else()
set(linkage_type PUBLIC)
endif()
target_link_libraries(${COMPONENT_LIB} ${linkage_type} ${mbedtls_targets}) target_link_libraries(${COMPONENT_LIB} ${linkage_type} ${mbedtls_targets})
if(CONFIG_ESP_TLS_USE_DS_PERIPHERAL) if(CONFIG_ESP_TLS_USE_DS_PERIPHERAL)

View File

@ -4,6 +4,7 @@ idf_component_register(SRCS "esp-mqtt/mqtt_client.c"
"esp-mqtt/lib/platform_esp32_idf.c" "esp-mqtt/lib/platform_esp32_idf.c"
INCLUDE_DIRS esp-mqtt/include INCLUDE_DIRS esp-mqtt/include
PRIV_INCLUDE_DIRS "esp-mqtt/lib/include" PRIV_INCLUDE_DIRS "esp-mqtt/lib/include"
PRIV_REQUIRES lwip
) )
if(TEST_BUILD) if(TEST_BUILD)

View File

@ -53,3 +53,7 @@ if(CONFIG_NEWLIB_NANO_FORMAT)
endif() endif()
add_subdirectory(port) add_subdirectory(port)
# if lwip is included in the build, add it as a public requirement so that
# #include <sys/socket.h> works without any special provisions.
idf_component_optional_requires(PUBLIC lwip)

View File

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
@ -59,6 +51,10 @@ ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
break; break;
} }
} }
if (received == 0) {
errno = EWOULDBLOCK;
return -1;
}
return received; return received;
} }
__errno_r(r) = EBADF; __errno_r(r) = EBADF;

View File

@ -11,4 +11,4 @@ endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "private_include" PRIV_INCLUDE_DIRS "private_include"
REQUIRES esp-tls) REQUIRES esp-tls lwip)

View File

@ -548,7 +548,7 @@ Common component requirements
To avoid duplication, every component automatically requires some "common" IDF components even if they are not mentioned explicitly. Headers from these components can always be included. To avoid duplication, every component automatically requires some "common" IDF components even if they are not mentioned explicitly. Headers from these components can always be included.
The list of common components is: cxx, newlib, freertos, esp_hw_support, heap, log, lwip, soc, hal, esp_rom, esp_common, esp_system. The list of common components is: cxx, newlib, freertos, esp_hw_support, heap, log, soc, hal, esp_rom, esp_common, esp_system.
Including components in the build Including components in the build
---------------------------------- ----------------------------------

View File

@ -19,6 +19,13 @@ In previous versions of ESP-IDF, some components were always added as public req
* ``driver`` * ``driver``
* ``efuse`` * ``efuse``
* ``esp_timer`` * ``esp_timer``
* ``lwip``
* ``vfs``
* ``esp_wifi``
* ``esp_event``
* ``esp_netif``
* ``esp_eth``
* ``esp_phy``
This means that it was possible to include header files of those components without specifying them as requirements in ``idf_component_register``. This means that it was possible to include header files of those components without specifying them as requirements in ``idf_component_register``.

View File

@ -634,7 +634,7 @@ Spark Plug 组件
为避免重复性工作,各组件都用自动依赖一些“通用” IDF 组件,即使它们没有被明确提及。这些组件的头文件会一直包含在构建系统中。 为避免重复性工作,各组件都用自动依赖一些“通用” IDF 组件,即使它们没有被明确提及。这些组件的头文件会一直包含在构建系统中。
通用组件包括cxx、newlib、freertos、esp_hw_support、heap、log、lwip、soc、hal、esp_rom、esp_common、esp_system。 通用组件包括cxx、newlib、freertos、esp_hw_support、heap、log、soc、hal、esp_rom、esp_common、esp_system。
在构建中导入组件 在构建中导入组件
----------------- -----------------

View File

@ -1090,7 +1090,6 @@ components/newlib/poll.c
components/newlib/priv_include/esp_time_impl.h components/newlib/priv_include/esp_time_impl.h
components/newlib/pthread.c components/newlib/pthread.c
components/newlib/reent_init.c components/newlib/reent_init.c
components/newlib/syscalls.c
components/newlib/termios.c components/newlib/termios.c
components/newlib/test/test_atomic.c components/newlib/test/test_atomic.c
components/newlib/test/test_locks.c components/newlib/test/test_locks.c

View File

@ -162,9 +162,8 @@ function(__build_init idf_path)
else() else()
# Set components required by all other components in the build # Set components required by all other components in the build
# #
# - lwip is here so that #include <sys/socket.h> works without any special provisions
# - esp_hw_support is here for backward compatibility # - esp_hw_support is here for backward compatibility
set(requires_common cxx newlib freertos esp_hw_support heap log lwip soc hal esp_rom esp_common esp_system) set(requires_common cxx newlib freertos esp_hw_support heap log soc hal esp_rom esp_common esp_system)
idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${requires_common}") idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${requires_common}")
endif() endif()

View File

@ -41,15 +41,6 @@ set(extra_components_which_shouldnt_be_included
# Figure out if these components can exist without a dependency on efuse. # Figure out if these components can exist without a dependency on efuse.
# If not, see if esp_hw_support can provide minimal efuse component replacement in G1 build. # If not, see if esp_hw_support can provide minimal efuse component replacement in G1 build.
efuse efuse
# esp_eth is a dependency of esp_netif, esp_event, lwip
# Once they are removed from G1, esp_eth will be removed as well.
esp_eth
# esp_event is a dependency of esp_wifi, esp_eth. Both should be removed from G1.
esp_event
# esp_netif is a dependency of lwip and esp_event, should disappear once lwip is removed.
esp_netif
# esp_phy is a dependency of esp_wifi.
esp_phy
# esp_pm is pulled in by freertos, can be made a weak dependency # esp_pm is pulled in by freertos, can be made a weak dependency
# conditional on related Kconfig option. It is also used by esp_wifi, driver, mbedtls, # conditional on related Kconfig option. It is also used by esp_wifi, driver, mbedtls,
# all of which should be removed from G1-only build. # all of which should be removed from G1-only build.
@ -59,30 +50,17 @@ set(extra_components_which_shouldnt_be_included
# esp_timer is a dependency of freertos, esp_event, esp_wifi, driver. # esp_timer is a dependency of freertos, esp_event, esp_wifi, driver.
# For freertos, it can be made a weak dependency conditional on FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER # For freertos, it can be made a weak dependency conditional on FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
esp_timer esp_timer
# esp_wifi is a dependency of lwip.
# [refactor-todo]: investigate making esp_wifi a conditional dependency.
esp_wifi
# esptool_py is a dependency of bootloader, esp_wifi, app_update, partition_table, all of which # esptool_py is a dependency of bootloader, esp_wifi, app_update, partition_table, all of which
# should be removed from G1-only build. # should be removed from G1-only build.
esptool_py esptool_py
# lwip is a common component due to "sys/socket.h" header.
# [refactor-todo] consider adding a system-level sys/socket.h in newlib instead
lwip
# mbedtls is a dependency of bootloader_support (plus other easier-to-remove ones) # mbedtls is a dependency of bootloader_support (plus other easier-to-remove ones)
# it is hard to make it conditional, need to remove bootloader_support. # it is hard to make it conditional, need to remove bootloader_support.
mbedtls mbedtls
# nvs_flash is required by:
# esp_wifi, esp_phy both should be removed
nvs_flash
# partition_table is pulled in by app_update, esptool_py, bootloader; all to be removed # partition_table is pulled in by app_update, esptool_py, bootloader; all to be removed
partition_table partition_table
# pthread is required by esp_system (for initialization only, can be made a weak dependency) # pthread is required by esp_system (for initialization only, can be made a weak dependency)
# and cxx. See also [refactor-todo] about cxx, can it work without pthread? # and cxx. See also [refactor-todo] about cxx, can it work without pthread?
pthread pthread
# vfs is a dependency of lwip. It can be made conditional, while lwip is still a common component.
vfs
# wpa_supplicant is a dependency of esp_wifi, which is to be removed from G1-only build
wpa_supplicant
) )
set(expected_components set(expected_components

View File

@ -194,12 +194,17 @@ static const char* get_test_name(void)
c = getchar(); c = getchar();
if (c == EOF) { if (c == EOF) {
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelay(pdMS_TO_TICKS(10));
} else if (c == '\r') { } else if ((c == '\r' || c == '\n') && p != test_name_str) {
continue; /* terminate the line */
} else if (c == '\n') { puts("\n\r");
fflush(stdout);
*p = '\0'; *p = '\0';
break; break;
} else { } else {
/* echo the received character */
putchar(c);
fflush(stdout);
/* and save it */
*p = c; *p = c;
++p; ++p;
} }

View File

@ -26,4 +26,4 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS include INCLUDE_DIRS include
PRIV_INCLUDE_DIRS private_include PRIV_INCLUDE_DIRS private_include
REQUIRES spi_flash idf_test cmock REQUIRES spi_flash idf_test cmock
PRIV_REQUIRES perfmon driver) PRIV_REQUIRES perfmon driver esp_netif)