Skip to content

Commit

Permalink
Make wholesale replacement of lwIP more straightforward
Browse files Browse the repository at this point in the history
Instead of everyone directly adjusting the definintions in src/lwip,
which only works in-tree, clean up the dependencies so that overriding
lwip_root works cleanly (ie, without introducing dependencies on
$chip_root/src/lwip).
  • Loading branch information
mspang committed Dec 14, 2023
1 parent 7cade8e commit dfdbef3
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 12 deletions.
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
11 changes: 8 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,10 @@ buildconfig_header("lwip_buildconfig") {
if (current_os == "zephyr" || current_os == "mbed") {
group("lwip") {
}
} else if (lwip_platform == "silabs") {
group("lwip") {
public_deps = [ "${lwip_root}:lwip" ]
}
} else if (lwip_platform == "external" || lwip_platform == "mw320") {
group("lwip") {
public_deps = [ ":lwip_buildconfig" ]
Expand All @@ -118,6 +121,8 @@ 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" ]
}
Expand Down Expand Up @@ -176,6 +181,8 @@ if (current_os == "zephyr" || current_os == "mbed") {
]
}
} else {
import("${lwip_root}/lwip.gni")

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

Expand Down Expand Up @@ -213,8 +220,6 @@ if (current_os == "zephyr" || current_os == "mbed") {
public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ]
sources +=
[ "${chip_root}/third_party/lwip/repo/lwip/src/apps/mdns/mdns.c" ]
} else if (lwip_platform == "silabs") {
public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ]
} else if (lwip_platform == "standalone") {
public_deps += [ "${chip_root}/src/lib/support" ]
} else if (lwip_platform == "k32w0") {
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
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
62 changes: 62 additions & 0 deletions third_party/lwip/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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 this 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 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" ]
}
45 changes: 45 additions & 0 deletions third_party/mt793x_sdk/mt793x_lwip/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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/perf.h",
"${chip_root}/src/lwip/mt793x/arch/cc.h",
"${chip_root}/src/lwip/mt793x/lwipopts.h",
]

sources = [
]

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

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 @@ -15,8 +15,9 @@
import("//build_overrides/chip.gni")
import("//build_overrides/mbedtls.gni")
import("//build_overrides/mt793x_sdk.gni")
import("//build_overrides/lwip.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/crypto/crypto.gni")
import("${chip_root}/src/platform/mt793x/args.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 @@ -17,6 +17,7 @@ import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/jlink.gni")
import("//build_overrides/openthread.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/lwip/lwip.gni")
import("${efr32_sdk_build_root}/silabs_board.gni")

if (wifi_soc == true) { # CCP board
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
49 changes: 49 additions & 0 deletions third_party/silabs/silabs_lwip/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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/chip.gni")
import("//build_overrides/efr32_sdk.gni")

import("../lwip.gni")

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

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

sources = [
"${chip_root}/src/lwip/freertos/sys_arch.c",
]

public_deps = [
"${efr32_sdk_build_root}:efr32_sdk",
"${chip_root}/src/lwip:lwip_buildconfig",
]

public_configs = [
":lwip_config",
"${chip_root}/src:includes",
]
}

0 comments on commit dfdbef3

Please sign in to comment.