Skip to content

Commit

Permalink
RPC console enhancement - echo service and build script (#10490)
Browse files Browse the repository at this point in the history
* Add PW RPC protos to chip_rpc console

* Build RPC console script implementation
Add default RPC console build directory to gitignore

* Create echo_service library
Add echo_service to RPC console

* Improve rpc_console script to use with source command

* Improve setting current directory in rpc_console script

* Change output dir for rpc_console building script
Changes restyle

* RPC console script cleanup

* Remove rpc_console_out dir from gitignore

* Replace shell script to build rpc console by Python builder

* Changes restyle

* Update build test data

* Set clang compilation for rpc-consoel also

* Fix testdata

* Set RPC console wheels files as build outputs

* Changes restyle
  • Loading branch information
ATmobica authored and pull[bot] committed Oct 26, 2021
1 parent e4cc2ec commit 1155047
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 13 deletions.
8 changes: 8 additions & 0 deletions examples/common/pigweed/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_protobuf_compiler/proto.gni")

pw_proto_library("echo_service") {
sources = [ "$dir_pw_rpc/echo.proto" ]
inputs = [ "$dir_pw_rpc/echo.options" ]
deps = [ "$dir_pw_protobuf:common_protos" ]
strip_prefix = "$dir_pw_rpc"
prefix = "echo_service"
}

pw_proto_library("device_service") {
sources = [ "protos/device_service.proto" ]
inputs = [ "protos/device_service.options" ]
Expand Down
1 change: 1 addition & 0 deletions examples/common/pigweed/rpc_console/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pw_python_package("chip_rpc") {
"$dir_pw_rpc/py",
"${chip_root}/examples/common/pigweed:button_service.python",
"${chip_root}/examples/common/pigweed:device_service.python",
"${chip_root}/examples/common/pigweed:echo_service.python",
"${chip_root}/examples/common/pigweed:lighting_service.python",
"${chip_root}/examples/common/pigweed:locking_service.python",
"${chip_root}/examples/ipv6only-app/common:wifi_service.python",
Expand Down
4 changes: 3 additions & 1 deletion examples/common/pigweed/rpc_console/py/chip_rpc/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from lighting_service import lighting_service_pb2
from locking_service import locking_service_pb2
from wifi_service import wifi_service_pb2
from echo_service import echo_pb2

_LOG = logging.getLogger(__name__)
_DEVICE_LOG = logging.getLogger('rpc_device')
Expand All @@ -68,7 +69,8 @@
lighting_service_pb2,
locking_service_pb2,
wifi_service_pb2,
device_service_pb2]
device_service_pb2,
echo_pb2]


def _parse_args():
Expand Down
5 changes: 4 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ def HostTargets():
'all-clusters', app=HostApp.ALL_CLUSTERS))
app_targets.append(target.Extend('chip-tool', app=HostApp.CHIP_TOOL))
app_targets.append(target.Extend('thermostat', app=HostApp.THERMOSTAT))
app_targets.append(target.Extend(
'rpc-console', app=HostApp.RPC_CONSOLE))

for target in app_targets:
yield target
yield target.Extend('ipv6only', enable_ipv4=False)
if ('rpc-console' not in target.name):
yield target.Extend('ipv6only', enable_ipv4=False)


def Esp32Targets():
Expand Down
50 changes: 39 additions & 11 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HostApp(Enum):
ALL_CLUSTERS = auto()
CHIP_TOOL = auto()
THERMOSTAT = auto()
RPC_CONSOLE = auto()

def ExamplePath(self):
if self == HostApp.ALL_CLUSTERS:
Expand All @@ -32,6 +33,8 @@ def ExamplePath(self):
return 'chip-tool'
elif self == HostApp.THERMOSTAT:
return 'thermostat/linux'
elif self == HostApp.RPC_CONSOLE:
return 'common/pigweed/rpc_console'
else:
raise Exception('Unknown app type: %r' % self)

Expand All @@ -42,6 +45,8 @@ def BinaryName(self):
return 'chip-tool'
elif self == HostApp.THERMOSTAT:
return 'thermostat-app'
elif self == HostApp.RPC_CONSOLE:
return 'rpc-console'
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -91,19 +96,29 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip
self.board = board
self.extra_gn_options = []

if not enable_ipv4:
if 'rpc-console' not in self.app_name and not enable_ipv4:
self.extra_gn_options.append('chip_inet_config_enable_ipv4=false')

def GnBuildArgs(self):
if self.board == HostBoard.NATIVE:
return self.extra_gn_options
elif self.board == HostBoard.ARM64:
return self.extra_gn_options + [
'target_cpu="arm64"',
'is_clang=true',
'chip_crypto="mbedtls"',
'sysroot="%s"' % self.SysRootPath('SYSROOT_AARCH64'),
]
self.extra_gn_options.extend(
[
'target_cpu="arm64"',
'is_clang=true'
]
)

if 'rpc-console' not in self.app_name:
self.extra_gn_options.extend(
[
'chip_crypto="mbedtls"',
'sysroot="%s"' % self.SysRootPath('SYSROOT_AARCH64')
]
)

return self.extra_gn_options
else:
raise Exception('Unknown host board type: %r' % self)

Expand All @@ -123,7 +138,20 @@ def SysRootPath(self, name):
return os.environ[name]

def build_outputs(self):
return {
self.app_name: os.path.join(self.output_dir, self.app_name),
self.map_name: os.path.join(self.output_dir, self.map_name)
}
outputs = {}
if 'rpc-console' not in self.app_name:
outputs.update(
{
self.app_name: os.path.join(self.output_dir, self.app_name),
self.map_name: os.path.join(self.output_dir, self.map_name)
}
)
else:
outputs.update(
{
self.app_name: os.path.join(
self.output_dir, "chip_rpc_console_wheels")
}
)

return outputs
14 changes: 14 additions & 0 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-ipv6only'

# Generating linux-arm64-rpc-console
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --root={root}/examples/common/pigweed/rpc_console '"'"'--args=target_cpu="arm64" is_clang=true'"'"' {out}/linux-arm64-rpc-console'

# Generating linux-arm64-thermostat
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
Expand All @@ -43,6 +48,9 @@ gn gen --check --fail-on-unused-args --root={root}/examples/chip-tool {out}/linu
# Generating linux-x64-chip-tool-ipv6only
gn gen --check --fail-on-unused-args --root={root}/examples/chip-tool --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-chip-tool-ipv6only

# Generating linux-x64-rpc-console
gn gen --check --fail-on-unused-args --root={root}/examples/common/pigweed/rpc_console {out}/linux-x64-rpc-console

# Generating linux-x64-thermostat
gn gen --check --fail-on-unused-args --root={root}/examples/thermostat/linux {out}/linux-x64-thermostat

Expand All @@ -61,6 +69,9 @@ ninja -C {out}/linux-arm64-chip-tool
# Building linux-arm64-chip-tool-ipv6only
ninja -C {out}/linux-arm64-chip-tool-ipv6only

# Building linux-arm64-rpc-console
ninja -C {out}/linux-arm64-rpc-console

# Building linux-arm64-thermostat
ninja -C {out}/linux-arm64-thermostat

Expand All @@ -79,6 +90,9 @@ ninja -C {out}/linux-x64-chip-tool
# Building linux-x64-chip-tool-ipv6only
ninja -C {out}/linux-x64-chip-tool-ipv6only

# Building linux-x64-rpc-console
ninja -C {out}/linux-x64-rpc-console

# Building linux-x64-thermostat
ninja -C {out}/linux-x64-thermostat

Expand Down

0 comments on commit 1155047

Please sign in to comment.