diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 76ec22f40c8223..97df8a48b5051d 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -28,6 +28,7 @@ assert(chip_build_tools) config("config") { include_dirs = [ ".", + "${chip_root}/examples/common", "${chip_root}/zzz_generated/app-common/app-common", "${chip_root}/zzz_generated/chip-tool", "${chip_root}/src/lib", @@ -87,13 +88,11 @@ static_library("chip-tool-utils") { deps = [] if (config_use_interactive_mode) { - sources += [ - "commands/interactive/InteractiveCommands.cpp", - "commands/interactive/WebSocketServer.cpp", - "commands/interactive/WebSocketServer.h", - "commands/interactive/WebSocketServerDelegate.h", + sources += [ "commands/interactive/InteractiveCommands.cpp" ] + deps += [ + "${chip_root}/examples/common/websocket-server", + "${editline_root}:editline", ] - deps += [ "${editline_root}:editline" ] } if (config_enable_yaml_tests) { @@ -116,7 +115,6 @@ static_library("chip-tool-utils") { "${chip_root}/src/platform", "${chip_root}/third_party/inipp", "${chip_root}/third_party/jsoncpp", - "${chip_root}/third_party/libwebsockets", ] public_configs = [ ":config" ] diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.h b/examples/chip-tool/commands/interactive/InteractiveCommands.h index 5e611e6895d2b2..49e6432ccb7f01 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.h +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.h @@ -22,7 +22,7 @@ #include "../common/CHIPCommand.h" #include "../common/Commands.h" -#include "WebSocketServer.h" +#include class Commands; diff --git a/examples/common/websocket-server/BUILD.gn b/examples/common/websocket-server/BUILD.gn new file mode 100644 index 00000000000000..fdd17300cecd06 --- /dev/null +++ b/examples/common/websocket-server/BUILD.gn @@ -0,0 +1,31 @@ +# 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/build.gni") +import("//build_overrides/chip.gni") + +static_library("websocket-server") { + output_name = "libWebSocketServer" + + sources = [ + "WebSocketServer.cpp", + "WebSocketServer.h", + "WebSocketServerDelegate.h", + ] + + public_deps = [ + "${chip_root}/src/lib/support", + "${chip_root}/third_party/libwebsockets", + ] +} diff --git a/examples/chip-tool/commands/interactive/WebSocketServer.cpp b/examples/common/websocket-server/WebSocketServer.cpp similarity index 99% rename from examples/chip-tool/commands/interactive/WebSocketServer.cpp rename to examples/common/websocket-server/WebSocketServer.cpp index a41754716ae961..867180b976c012 100644 --- a/examples/chip-tool/commands/interactive/WebSocketServer.cpp +++ b/examples/common/websocket-server/WebSocketServer.cpp @@ -19,6 +19,7 @@ #include "WebSocketServer.h" #include +#include constexpr uint16_t kDefaultWebSocketServerPort = 9002; constexpr uint16_t kMaxMessageBufferLen = 8192; diff --git a/examples/chip-tool/commands/interactive/WebSocketServer.h b/examples/common/websocket-server/WebSocketServer.h similarity index 97% rename from examples/chip-tool/commands/interactive/WebSocketServer.h rename to examples/common/websocket-server/WebSocketServer.h index d18b68bee2b611..712cf185d8f4a0 100644 --- a/examples/chip-tool/commands/interactive/WebSocketServer.h +++ b/examples/common/websocket-server/WebSocketServer.h @@ -22,7 +22,6 @@ #include #include -#include class WebSocketServer { diff --git a/examples/chip-tool/commands/interactive/WebSocketServerDelegate.h b/examples/common/websocket-server/WebSocketServerDelegate.h similarity index 100% rename from examples/chip-tool/commands/interactive/WebSocketServerDelegate.h rename to examples/common/websocket-server/WebSocketServerDelegate.h