esp-idf/components/esp_wifi/CMakeLists.txt
Ivan Grokhotkov 47659be5b8
build system: remove lwip from common requirements
lwip was added to common requirements list to provide "sys/socket.h"
header to all components without additional requirements specified.

However, lwip pulls in a lot of dependencies on other components.
This commit removes lwip from common requirements to reduce the number
of components in G1-only apps.

To compensate for this removal, the following changes are made:
- newlib (which is a common requirement) has a public dependency on
  lwip if lwip is present in the build. This ensures that sys/socket.h
  is available as long as lwip component is included into the build.
- lwip is now a public requirement of esp-tls since esp_tls.h includes
  sys/socket.h header.
- lwip is now a public requirement o esp_http_client because
  sys/socket.h is included from esp_http_client.h
- lwip is now a private requirement of esp_wifi for "smartconfig_ack"
- lwip is now a private requirement of mqtt for socket functions
- lwip is now a public requirement of tcp_transport because
  esp_transport_tcp.h includes sys/socket.h header.
- mbedtls checks if lwip component is present in the build. If yes,
  net_sockets.c is added to the build, along with the dependency on
  lwip. Previously lwip was a public requirement of mbedtls
  unconditionally.

system/g1_components test app is updated to reflect the changes

Default public dependencies of a component before and after this
change, except common requirements:

- esp_timer (public dependency of freertos)
- bootloader_support (public dependency of esp_hw_support)
- vfs (public dependency of lwip)
- esp_wifi (public dependency of lwip)
- esp_event (public dependency of esp_wifi)
- esp_netif (public dependency of esp_event)
- esp_eth (public dependency of esp_netif)
- esp_phy (public dependency of esp_wifi)

After:

- esp_timer (public dependency of freertos)
- bootloader_support (public dependency of esp_hw_support)

Altogether, the following components have been always added as
public requirements to all other components, and are not added now
([breaking-change]):

- lwip
- vfs
- esp_wifi
- esp_event
- esp_netif
- esp_eth
- esp_phy

Application components now need to explicitly declare dependencies on
these components.
2022-05-02 20:47:17 +02:00

56 lines
1.8 KiB
CMake

if(CONFIG_ESP32_WIFI_ENABLED)
idf_build_get_property(idf_target IDF_TARGET)
if(CONFIG_APP_NO_BLOBS)
set(link_binary_libs 0)
set(ldfragments)
else()
set(link_binary_libs 1)
set(ldfragments "linker.lf")
endif()
if(IDF_TARGET_ESP32)
# dport workaround headers are in esp32 component
set(extra_priv_requires esp32)
else()
set(extra_priv_requires)
endif()
set(srcs
"src/coexist.c"
"src/mesh_event.c"
"src/smartconfig.c"
"src/smartconfig_ack.c"
"src/wifi_init.c"
"src/wifi_default.c"
"src/wifi_netif.c"
"${idf_target}/esp_adapter.c")
endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
REQUIRES esp_event esp_phy
PRIV_REQUIRES driver esptool_py esp_netif esp_pm esp_timer nvs_flash
wpa_supplicant hal lwip ${extra_priv_requires}
LDFRAGMENTS "${ldfragments}")
if(CONFIG_ESP32_WIFI_ENABLED)
idf_build_get_property(build_dir BUILD_DIR)
set(target_name "${idf_target}")
target_link_libraries(${COMPONENT_LIB} PUBLIC "-L \"${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}\"")
if(link_binary_libs)
set(blobs coexist core espnow mesh net80211 pp smartconfig wapi)
foreach(blob ${blobs})
add_prebuilt_library(${blob} "${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}/lib${blob}.a"
REQUIRES ${COMPONENT_NAME})
set(blob_reqs ${blobs})
list(REMOVE_ITEM blob_reqs ${blob}) # remove itself from requirements
set_property(TARGET ${blob} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${blob_reqs})
target_link_libraries(${COMPONENT_LIB} PUBLIC ${blob})
endforeach()
endif()
endif()