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

Use libshell under examples/platform/linux/AppMain.cpp only if chip_b… #7813

Merged
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine, but should this default to true on Linux to preserve current behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine to enable it back into examples/platform/linux/BUILD.gn for Linux platform if required. I have disabled it mostly because chip_build_libshell was false by default in src/lib/BUILD.gn and other platforms enable it conditionally.
Furthermore, I've tried to see what it does by typing commands in and there is not much commands at the moment, so I'm not sure how much it is used. Again if someone insist, I will add it back.

For references the commands are:

help
help
  base64          Base64 encode / decode utilities
  exit            Exit the shell application
  help            List out all top level commands
  version         Output the software version
  config          Dump device configuration. Usage: config [param_name]
Done

}