Skip to content

Commit

Permalink
Use libshell under examples/platform/linux/AppMain.cpp only if chip_b…
Browse files Browse the repository at this point in the history
…uild_libshell is true (#7813)
  • Loading branch information
vivien-apple authored Jun 22, 2021
1 parent 59e4a16 commit 12514cc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
12 changes: 11 additions & 1 deletion examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <core/CHIPError.h>
#include <lib/shell/Engine.h>
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>
#include <support/CHIPMem.h>
#include <support/RandUtils.h>

#if defined(ENABLE_CHIP_SHELL)
#include <lib/shell/Engine.h>
#endif

#if defined(PW_RPC_ENABLED)
#include <CommonRpc.h>
#endif
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions examples/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [ "." ]
Expand All @@ -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",
Expand All @@ -46,8 +50,5 @@ source_set("app-main") {
"${chip_root}/src/lib/shell:shell_core",
]

public_deps += [
]

public_configs = [ ":app-main-config" ]
}
1 change: 1 addition & 0 deletions scripts/tests/test_suites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
5 changes: 1 addition & 4 deletions src/lib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [ "." ]
Expand Down
18 changes: 18 additions & 0 deletions src/lib/lib.gni
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 12514cc

Please sign in to comment.