Skip to content

Commit

Permalink
RPC support in the example tool chef linux build (project-chip#18294)
Browse files Browse the repository at this point in the history
Port RPC server enabled logic into example tool chef

the usage example:
  $ ./chef.py -zbr -t linux -d lighting-app --pid 0x8000
  • Loading branch information
MtTsai authored and cpagravel committed Jun 15, 2022
1 parent da514da commit 89afa72
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
7 changes: 5 additions & 2 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def main(argv: Sequence[str]) -> None:
with open(f"{_CHEF_SCRIPT_PATH}/linux/args.gni", "w") as f:
f.write(textwrap.dedent(f"""\
import("//build_overrides/chip.gni")
import("\\${{chip_root}}/config/standalone/args.gni")
import("${{chip_root}}/config/standalone/args.gni")
chip_shell_cmd_server = false
target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={'1' if options.do_rpc else '0'}"]
"""))
Expand All @@ -344,7 +344,10 @@ def main(argv: Sequence[str]) -> None:
"""))
if options.do_clean:
shell.run_cmd(f"rm -rf out")
shell.run_cmd("gn gen out")
if options.do_rpc:
shell.run_cmd("gn gen out --args='import(\"//with_pw_rpc.gni\")'")
else:
shell.run_cmd("gn gen out --args=''")
shell.run_cmd("ninja -C out")

#
Expand Down
24 changes: 12 additions & 12 deletions examples/chef/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/openthread.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/chip_data_model.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/app/common_flags.gni")

assert(chip_build_tools)

Expand All @@ -34,39 +33,33 @@ project_dir = "./.."

chip_data_model("chef-data-model") {
zap_file = "${project_dir}/devices/${sample_zap_file}"

zap_pregenerated_dir =
"${chip_root}/examples/chef/out/${sample_name}/zap-generated/"
is_server = true
}

executable("${sample_name}") {
sources = [
"${project_dir}/common/stubs.cpp",
"${project_dir}/linux/main.cpp",
]
sources = [ "${project_dir}/linux/main.cpp" ]

deps = [
":chef-data-model",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/controller",
"${chip_root}/src/credentials",
"${chip_root}/src/lib",
"${chip_root}/src/lib",
"${chip_root}/src/lib/shell",
"${chip_root}/src/platform",
"${project_dir}/shell_common:shell_common",
]

include_dirs = [ "include" ]

if (chip_enable_pw_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",
]

sources += [
Expand All @@ -83,6 +76,9 @@ executable("${sample_name}") {
"$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",
Expand All @@ -93,6 +89,10 @@ executable("${sample_name}") {
]

deps += pw_build_LINK_DEPS

cflags = [ "-Wno-gnu-designator" ]

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.
Expand Down
5 changes: 5 additions & 0 deletions examples/chef/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cpp_standard = "gnu++17"
pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log"
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"
Expand All @@ -38,3 +39,7 @@ pw_build_LINK_DEPS = [
]

chip_enable_pw_rpc = true
<<<<<<< HEAD
=======
chip_build_pw_trace_lib = true
>>>>>>> 1eb092115 (RPC support in the example tool chef linux build (#18294))

0 comments on commit 89afa72

Please sign in to comment.