Issue #31002 Enable RPC for all-clusters-app (#31006)
* Issue #31002 Enable RPC for all-clusters-app
* Restyled by gn
---------
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn
index 65d00a6..b0fdcd4 100644
--- a/examples/all-clusters-app/linux/BUILD.gn
+++ b/examples/all-clusters-app/linux/BUILD.gn
@@ -19,6 +19,14 @@
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
+import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
+
+if (chip_enable_pw_rpc) {
+ import("//build_overrides/pigweed.gni")
+ import("$dir_pw_build/target_types.gni")
+ import("${chip_root}/examples/common/pigweed/rpc_config.gni")
+}
+
source_set("chip-all-clusters-common") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
@@ -77,7 +85,19 @@
"${chip_root}/examples/energy-management-app/energy-management-common/include",
]
- cflags = [ "-Wconversion" ]
+ if (chip_enable_pw_rpc) {
+ defines = rpc_defines
+ sources += rpc_sources
+ deps += rpc_deps
+
+ deps += pw_build_LINK_DEPS
+
+ include_dirs += [ "${chip_root}/examples/common" ]
+ } else {
+ # The system_rpc_server.cc file is in pigweed and doesn't compile with
+ # -Wconversion, remove check for RPC build only.
+ cflags = [ "-Wconversion" ]
+ }
if (chip_build_libshell) {
defines = [ "ENABLE_CHIP_SHELL" ]
diff --git a/examples/all-clusters-app/linux/with_pw_rpc.gni b/examples/all-clusters-app/linux/with_pw_rpc.gni
new file mode 100644
index 0000000..0f1ab1e
--- /dev/null
+++ b/examples/all-clusters-app/linux/with_pw_rpc.gni
@@ -0,0 +1,42 @@
+# 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.
+
+# add this gni as import in your build args to use pigweed in the example
+# 'import("//with_pw_rpc.gni")'
+
+import("//build_overrides/chip.gni")
+
+import("${chip_root}/config/standalone/args.gni")
+
+import("//build_overrides/pigweed.gni")
+
+pw_log_BACKEND = "$dir_pw_log_basic"
+pw_assert_BACKEND = "$dir_pw_assert_log:check_backend"
+pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
+pw_trace_BACKEND = "$dir_pw_trace_tokenized"
+pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
+pw_rpc_system_server_BACKEND = "${chip_root}/config/linux/lib/pw_rpc:pw_rpc"
+dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo"
+pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
+pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"
+pw_thread_YIELD_BACKEND = "$dir_pw_thread_stl:yield"
+pw_thread_SLEEP_BACKEND = "$dir_pw_thread_stl:sleep"
+
+pw_build_LINK_DEPS = [
+ "$dir_pw_assert:impl",
+ "$dir_pw_log:impl",
+]
+
+chip_enable_pw_rpc = true
+chip_use_pw_logging = true
diff --git a/examples/common/pigweed/rpc_config.gni b/examples/common/pigweed/rpc_config.gni
new file mode 100644
index 0000000..ddd6b08
--- /dev/null
+++ b/examples/common/pigweed/rpc_config.gni
@@ -0,0 +1,53 @@
+# 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.
+
+import("//build_overrides/chip.gni")
+import("//build_overrides/pigweed.gni")
+
+rpc_defines = [
+ "PW_RPC_ENABLED",
+ "PW_RPC_ATTRIBUTE_SERVICE=1",
+ "PW_RPC_BUTTON_SERVICE=1",
+ "PW_RPC_DESCRIPTOR_SERVICE=1",
+ "PW_RPC_DEVICE_SERVICE=1",
+ "PW_RPC_LIGHTING_SERVICE=1",
+ "PW_RPC_TRACING_SERVICE=1",
+]
+
+rpc_sources = [
+ "${chip_root}/examples/platform/linux/Rpc.cpp",
+ "${chip_root}/examples/platform/linux/system_rpc_server.cc",
+]
+
+rpc_deps = [
+ "$dir_pw_hdlc:pw_rpc",
+ "$dir_pw_hdlc:rpc_channel_output",
+ "$dir_pw_log",
+ "$dir_pw_rpc:server",
+ "$dir_pw_rpc/system_server:facade",
+ "$dir_pw_rpc/system_server:socket",
+ "$dir_pw_stream:socket_stream",
+ "$dir_pw_stream:sys_io_stream",
+ "$dir_pw_sync:mutex",
+ "$dir_pw_trace",
+ "$dir_pw_trace_tokenized",
+ "$dir_pw_trace_tokenized:trace_rpc_service",
+ "${chip_root}/config/linux/lib/pw_rpc:pw_rpc",
+ "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
+ "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
+ "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc",
+ "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
+ "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
+ "${chip_root}/examples/common/pigweed:rpc_services",
+]