From 12514ccdfc65dcaac7dbbcb4cb638c6e3f295330 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 22 Jun 2021 20:05:32 +0200 Subject: [PATCH] Use libshell under examples/platform/linux/AppMain.cpp only if chip_build_libshell is true (#7813) --- examples/platform/linux/AppMain.cpp | 12 +++++++++++- examples/platform/linux/BUILD.gn | 7 ++++--- scripts/tests/test_suites.sh | 1 + src/lib/BUILD.gn | 5 +---- src/lib/lib.gni | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/lib/lib.gni diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index d0e942746960e9..45729a3c2ee8b6 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -25,12 +25,15 @@ #include #include #include -#include #include #include #include #include +#if defined(ENABLE_CHIP_SHELL) +#include +#endif + #if defined(PW_RPC_ENABLED) #include #endif @@ -41,7 +44,10 @@ using namespace chip; using namespace chip::Inet; using namespace chip::Transport; using namespace chip::DeviceLayer; + +#if defined(ENABLE_CHIP_SHELL) using chip::Shell::Engine; +#endif namespace { void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg) @@ -116,11 +122,15 @@ int ChipLinuxAppInit(int argc, char ** argv) void ChipLinuxAppMainLoop() { +#if defined(ENABLE_CHIP_SHELL) std::thread shellThread([]() { Engine::Root().RunMainLoop(); }); +#endif // Init ZCL Data Model and CHIP App Server InitServer(); chip::DeviceLayer::PlatformMgr().RunEventLoop(); +#if defined(ENABLE_CHIP_SHELL) shellThread.join(); +#endif } diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn index 719faa898d5382..3b1c6c3eaaefaa 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/common_flags.gni") +import("${chip_root}/src/lib/lib.gni") config("app-main-config") { include_dirs = [ "." ] @@ -38,6 +39,9 @@ source_set("app-main") { # BLE and on-network. Code defaults to BLE if this is not set. defines += [ "CONFIG_RENDEZVOUS_MODE=6" ] } + if (chip_build_libshell) { + defines += [ "ENABLE_CHIP_SHELL" ] + } public_deps = [ "${chip_root}/src/app/server", @@ -46,8 +50,5 @@ source_set("app-main") { "${chip_root}/src/lib/shell:shell_core", ] - public_deps += [ - ] - public_configs = [ ":app-main-config" ] } diff --git a/scripts/tests/test_suites.sh b/scripts/tests/test_suites.sh index 35a7ed082765ce..a8404345451c3b 100755 --- a/scripts/tests/test_suites.sh +++ b/scripts/tests/test_suites.sh @@ -73,6 +73,7 @@ for j in "${iter_array[@]}"; do # Clear out our temp files so we don't accidentally do a stale # read from them before we write to them. rm -rf /tmp/all-clusters-log + touch /tmp/all-clusters-log rm -rf /tmp/pid ( stdbuf -o0 out/debug/standalone/chip-all-clusters-app & diff --git a/src/lib/BUILD.gn b/src/lib/BUILD.gn index b63e040d2bac76..baf56f56a5149f 100644 --- a/src/lib/BUILD.gn +++ b/src/lib/BUILD.gn @@ -13,10 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") - -declare_args() { - chip_build_libshell = false -} +import("lib.gni") config("includes") { include_dirs = [ "." ] diff --git a/src/lib/lib.gni b/src/lib/lib.gni new file mode 100644 index 00000000000000..7ced93de8138ef --- /dev/null +++ b/src/lib/lib.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2021 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() { + # Enable libshell support. + chip_build_libshell = false +}