From 95299a6c04069c0a1e2be5ca548513a500b16c91 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 16 Sep 2020 02:51:44 -0400 Subject: [PATCH 1/2] Allow building CHIP without lwip checked out This used to work prior to #2325, which added an unconditional dependency on lwip even if we're using sockets. Make it conditional. --- src/BUILD.gn | 10 ++++++---- src/inet/BUILD.gn | 6 +++++- src/lwip/BUILD.gn | 3 +++ src/lwip/lwip.gni | 18 ++++++++++++++++++ src/lwip/tests/BUILD.gn | 3 ++- src/system/system.gni | 6 +++++- 6 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 src/lwip/lwip.gni diff --git a/src/BUILD.gn b/src/BUILD.gn index d635cb69b7d9d3..37ebca86fbd7a4 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/gn/chip/tests.gni") +import("${chip_root}/src/lwip/lwip.gni") config("includes") { include_dirs = [ @@ -46,11 +47,12 @@ if (chip_build_tests) { "${chip_root}/src/transport/tests", ] + if (chip_with_lwip) { + deps += [ "${chip_root}/src/lwip/tests" ] + } + if (current_os != "zephyr") { - deps += [ - "${chip_root}/src/lib/shell/tests", - "${chip_root}/src/lwip/tests", - ] + deps += [ "${chip_root}/src/lib/shell/tests" ] } } } diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 66197d3c24be42..950889304cacab 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -19,6 +19,7 @@ import("//build_overrides/nlio.gni") import("${chip_root}/gn/chip/buildconfig_header.gni") import("${chip_root}/gn/chip/tests.gni") +import("${chip_root}/src/lwip/lwip.gni") import("${chip_root}/src/platform/device.gni") import("inet.gni") @@ -97,11 +98,14 @@ static_library("inet") { public_deps = [ ":inet_config_header", "${chip_root}/src/lib/support", - "${chip_root}/src/lwip", "${chip_root}/src/system", "${nlio_root}:nlio", ] + if (chip_with_lwip) { + public_deps += [ "${chip_root}/src/lwip" ] + } + if (chip_inet_config_enable_raw_endpoint) { sources += [ "RawEndPoint.cpp", diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index aeca641f38691a..f279a66e4fe489 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -16,8 +16,11 @@ import("//build_overrides/chip.gni") import("//build_overrides/lwip.gni") import("${chip_root}/gn/chip/buildconfig_header.gni") +import("${chip_root}/src/lwip/lwip.gni") import("${lwip_root}/lwip.gni") +assert(chip_with_lwip) + declare_args() { # lwIP platform: standalone, freertos. lwip_platform = "" diff --git a/src/lwip/lwip.gni b/src/lwip/lwip.gni new file mode 100644 index 00000000000000..a864f160eb9e84 --- /dev/null +++ b/src/lwip/lwip.gni @@ -0,0 +1,18 @@ +# 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. + +declare_args() { + # Have the the lwIP library available. + chip_with_lwip = current_os != "zephyr" +} diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn index 7fa2d9eba7504b..71c06be8f416e0 100644 --- a/src/lwip/tests/BUILD.gn +++ b/src/lwip/tests/BUILD.gn @@ -16,8 +16,9 @@ import("//build_overrides/chip.gni") import("${chip_root}/gn/chip/chip_test.gni") import("${chip_root}/gn/chip/chip_test_group.gni") +import("${chip_root}/src/lwip/lwip.gni") -assert(current_os != "zephyr") +assert(chip_with_lwip) chip_test("TestLwIP") { sources = [ "tests.c" ] diff --git a/src/system/system.gni b/src/system/system.gni index 63a4cee04134ec..72744392f314e3 100644 --- a/src/system/system.gni +++ b/src/system/system.gni @@ -12,9 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + +import("${chip_root}/src/lwip/lwip.gni") + declare_args() { # Use the lwIP library. - chip_system_config_use_lwip = current_os == "freertos" + chip_system_config_use_lwip = chip_with_lwip && current_os == "freertos" # Use BSD/POSIX socket API. chip_system_config_use_sockets = current_os != "freertos" From 02d9f3c7f989765a7c0d63391604f5f4a7acfd48 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 16 Sep 2020 17:51:57 -0400 Subject: [PATCH 2/2] Fix typo --- src/lwip/lwip.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lwip/lwip.gni b/src/lwip/lwip.gni index a864f160eb9e84..3d0fc789697f63 100644 --- a/src/lwip/lwip.gni +++ b/src/lwip/lwip.gni @@ -13,6 +13,6 @@ # limitations under the License. declare_args() { - # Have the the lwIP library available. + # Have the lwIP library available. chip_with_lwip = current_os != "zephyr" }