Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wholesale replacement of lwIP more straightforward #31025

Merged
merged 6 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import("${build_root}/config/compiler/compiler.gni")

import("//src/crypto/crypto.gni")

if (chip_with_lwip) {
import("//build_overrides/lwip.gni")
}

if (current_toolchain != "${dir_pw_toolchain}/default:default") {
declare_args() {
chip_enable_python_modules =
Expand Down Expand Up @@ -152,7 +156,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}

if (chip_with_lwip) {
deps += [ "${chip_root}/src/lwip" ]
deps += [ "${lwip_root}:lwip" ]
}

if (chip_build_tools) {
Expand Down
1 change: 0 additions & 1 deletion src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import("${build_root}/config/compiler/compiler.gni")
import("${chip_root}/build/chip/java/config.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/ble/ble.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/tracing/tracing_args.gni")

Expand Down
7 changes: 5 additions & 2 deletions src/inet/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import("//build_overrides/nlio.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")
import("inet.gni")

if (chip_system_config_use_open_thread_inet_endpoints) {
import("//build_overrides/openthread.gni")
}

if (chip_system_config_use_lwip) {
import("//build_overrides/lwip.gni")
}

declare_args() {
# Extra header to include in SystemConfig.h for project.
chip_inet_project_config_include = ""
Expand Down Expand Up @@ -105,7 +108,7 @@ static_library("inet") {

if (chip_system_config_use_lwip) {
sources += [ "EndPointStateLwIP.cpp" ]
public_deps += [ "${chip_root}/src/lwip" ]
public_deps += [ "${lwip_root}:lwip" ]
}

if (chip_system_config_use_open_thread_inet_endpoints) {
Expand Down
1 change: 0 additions & 1 deletion src/inet/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import("//build_overrides/nlunit_test.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")

config("tests_config") {
Expand Down
23 changes: 20 additions & 3 deletions src/lwip/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import("//build_overrides/lwip.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${lwip_root}/lwip.gni")

assert(chip_with_lwip)

Expand Down Expand Up @@ -100,6 +99,12 @@ buildconfig_header("lwip_buildconfig") {
if (current_os == "zephyr" || current_os == "mbed") {
group("lwip") {
}
} else if (get_path_info(lwip_root, "abspath") !=
get_path_info("${chip_root}/third_party/lwip", "abspath")) {
# Redirect old dependencies on ${chip_root}/src/lwip onto ${lwip_root}:lwip
group("lwip") {
public_deps = [ "${lwip_root}:lwip" ]
}
} else if (lwip_platform == "external" || lwip_platform == "mw320") {
group("lwip") {
public_deps = [ ":lwip_buildconfig" ]
Expand All @@ -118,11 +123,13 @@ if (current_os == "zephyr" || current_os == "mbed") {
public_configs += [ "${psoc6_sdk_build_root}:psoc6_sdk_config" ]
}
} else if (lwip_platform == "qpg") {
import("${lwip_root}/lwip.gni")

config("lwip_config") {
include_dirs = [ "freertos" ]
}

lwip_target("lwip") {
lwip_target("legacy_lwip") {
public = [
"${qpg_sdk_root}/Components/ThirdParty/Lwip/arch/cc.h",
"${qpg_sdk_root}/Components/ThirdParty/Lwip/arch/perf.h",
Expand All @@ -139,6 +146,10 @@ if (current_os == "zephyr" || current_os == "mbed") {
"${chip_root}/src:includes",
]
}

group("lwip") {
public_deps = [ ":legacy_lwip" ]
}
} else if (lwip_platform == "bl602") {
group("lwip") {
public_deps = [ ":lwip_buildconfig" ]
Expand Down Expand Up @@ -176,6 +187,8 @@ if (current_os == "zephyr" || current_os == "mbed") {
]
}
} else {
import("${lwip_root}/lwip.gni")

config("lwip_config") {
include_dirs = [ lwip_platform ]

Expand All @@ -184,7 +197,7 @@ if (current_os == "zephyr" || current_os == "mbed") {
}
}

lwip_target("lwip") {
lwip_target("legacy_lwip") {
public = [
"${lwip_platform}/arch/cc.h",
"${lwip_platform}/arch/perf.h",
Expand Down Expand Up @@ -236,4 +249,8 @@ if (current_os == "zephyr" || current_os == "mbed") {
"${chip_root}/src:includes",
]
}

group("lwip") {
public_deps = [ ":legacy_lwip" ]
}
}
2 changes: 0 additions & 2 deletions src/platform/mt793x/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <platform/ConnectivityManager.h>
#include <platform/internal/BLEManager.h>

#include <app/server/Dnssd.h>

#include <lwip/dns.h>
#include <lwip/ip_addr.h>
#include <lwip/nd6.h>
Expand Down
2 changes: 2 additions & 0 deletions src/platform/mt793x/NetworkCommissioningWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace NetworkCommissioning {
namespace {
NetworkCommissioning::WiFiScanResponse * sScanResult;
GenioScanResponseIterator<NetworkCommissioning::WiFiScanResponse> mScanResponseIter(sScanResult);

using chip::app::Clusters::NetworkCommissioning::WiFiSecurityBitmap;
} // namespace

CHIP_ERROR GenioWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeCallback)
Expand Down
2 changes: 1 addition & 1 deletion src/platform/mt793x/NetworkCommissioningWiFiDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class GenioWiFiDriver final : public WiFiDriver

CHIP_ERROR ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen);

chip::BitFlags<WiFiSecurityBitmap> ConvertSecuritytype(wifi_auth_mode_t auth_mode);
chip::BitFlags<app::Clusters::NetworkCommissioning::WiFiSecurityBitmap> ConvertSecuritytype(wifi_auth_mode_t auth_mode);

void OnConnectWiFiNetwork();
static GenioWiFiDriver & GetInstance()
Expand Down
2 changes: 1 addition & 1 deletion src/platform/mt793x/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ lwip_platform = "mt793x"

# Use our porting instad of //third_party/lwip

lwip_root = "${chip_root}/third_party/mt793x_sdk/lwip"
lwip_root = "${mt793x_sdk_build_root}/mt793x_lwip"

chip_mdns = "platform"
chip_inet_config_enable_ipv4 = true
Expand Down
6 changes: 5 additions & 1 deletion src/platform/mt793x/lwip/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ config("lwip_config") {
]
}

lwip_target("lwip") {
lwip_target("mt793x_lwip") {
public = [ "${mt793x_sdk_root}/project/mt7933_hdk/apps/${mt793x_project_name}/inc/lwipopts.h" ]

sources = []
Expand All @@ -65,3 +65,7 @@ lwip_target("lwip") {
"${chip_root}/src:includes",
]
}

group("lwip") {
public_deps = [ ":mt793x_lwip" ]
}
2 changes: 1 addition & 1 deletion src/platform/silabs/wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (chip_crypto == "") {
chip_use_transitional_commissionable_data_provider = false

# Use GSDK lwip instead of CHIP
lwip_root = "${efr32_sdk_build_root}"
lwip_root = "${efr32_sdk_build_root}/silabs_lwip"

#lwip_platform = "external"
lwip_platform = "silabs"
Expand Down
6 changes: 5 additions & 1 deletion src/system/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/platform/device.gni")
import("system.gni")

if (chip_system_config_use_lwip) {
import("//build_overrides/lwip.gni")
}

declare_args() {
# Extra header to include in CHIPConfig.h for project.
# TODO - This should probably be in src/core but src/system also uses it.
Expand Down Expand Up @@ -175,7 +179,7 @@ source_set("system_config_header") {

if (target_cpu != "esp32") {
if (chip_system_config_use_lwip) {
public_deps += [ "${chip_root}/src/lwip" ]
public_deps += [ "${lwip_root}:lwip" ]
} else {
if (chip_device_platform == "efr32") {
public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ]
Expand Down
64 changes: 64 additions & 0 deletions third_party/lwip/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# 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.

import("//build_overrides/chip.gni")

# Re-export the Matter lwip integration as "lwip"
#
# To depend on lwip while keeping the implementation target
# encapsulated:
#
# import("//build_overrides/lwip.gni")
#
# source_set("foo") {
# public_deps = [
# "${lwip_root}:lwip",
# ...
# ]
# }
#
# and set up the build_overrides appropriately (a typical lwip_root
# would be //third_party/lwip).
#
# To help define the library, a reusable template is provided as
# lwip_target() in third_party/lwip/lwip.gni. Example usage:
#
# //example/lwip/BUILD.gn:
#
# config("lwip_config") {
# include_dirs = [ "include" ]
# }
#
# lwip_target("lwip") {
# public = [
# "include/lwipopts.h"
# ]
#
# sources = [ "sys_arch.c" ]
#
# public_configs = [
# ":lwip_config",
# ]
# }
#
# Then set lwip_root = "//example/lwip" in build_overrides (or,
# if declared as an argument in build_overrides, via args).
#
# Defining the library directly works too.
#
# If there's no include paths to add, defines to set, sources to
# compile, or libraries to link, then an empty group target suffices.
group("lwip") {
public_deps = [ "${chip_root}/src/lwip:lwip" ]
}
44 changes: 44 additions & 0 deletions third_party/mt793x_sdk/mt793x_lwip/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2023 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# 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.

import("//build_overrides/mt793x_sdk.gni")

import("${mt793x_sdk_build_root}/lwip/lwip.gni")

config("lwip_config") {
include_dirs = [
"${chip_root}/src/lwip/mt793x",
"${chip_root}/src/lwip/freertos",
]
}

lwip_target("lwip") {
public = [
"${chip_root}/src/lwip/mt793x/arch/cc.h",
"${chip_root}/src/lwip/mt793x/arch/perf.h",
"${chip_root}/src/lwip/mt793x/lwipopts.h",
]

sources = []

public_deps = [
"${chip_root}/src/lwip:lwip_buildconfig",
"${mt793x_sdk_build_root}:mt793x_sdk",
]

public_configs = [
":lwip_config",
"${chip_root}/src:includes",
]
}
3 changes: 2 additions & 1 deletion third_party/mt793x_sdk/mt793x_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
# limitations under the License.
#
import("//build_overrides/chip.gni")
import("//build_overrides/lwip.gni")
import("//build_overrides/mbedtls.gni")
import("//build_overrides/mt793x_sdk.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/platform/mt793x/args.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/platform/mt793x/lwip/lwip.gni")

#
Expand Down
7 changes: 7 additions & 0 deletions third_party/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/jlink.gni")
import("//build_overrides/openthread.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${chip_root}/src/platform/device.gni")
import("${efr32_sdk_build_root}/silabs_board.gni")

Expand Down Expand Up @@ -53,6 +54,12 @@ group("efr32_sdk") {
public_configs = [ ":silabs_config" ]
}

if (chip_with_lwip) {
group("lwip") {
public_deps = [ "silabs_lwip:lwip" ]
}
}

if (wifi_soc != true) { # CCP board
# Openthread GSDK libraries configurations

Expand Down
Loading
Loading