1# Copyright 2020 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@rules_python//python:defs.bzl", "py_library") 16load("//pw_build:python.bzl", "pw_py_binary", "pw_py_test") 17 18package(default_visibility = ["//visibility:public"]) 19 20licenses(["notice"]) 21 22filegroup( 23 name = "pw_rpc_common_sources", 24 srcs = [ 25 "pw_rpc/callback_client/__init__.py", 26 "pw_rpc/callback_client/call.py", 27 "pw_rpc/callback_client/errors.py", 28 "pw_rpc/callback_client/impl.py", 29 "pw_rpc/codegen.py", 30 "pw_rpc/codegen_nanopb.py", 31 "pw_rpc/codegen_pwpb.py", 32 "pw_rpc/codegen_raw.py", 33 "pw_rpc/console_tools/__init__.py", 34 "pw_rpc/console_tools/console.py", 35 "pw_rpc/console_tools/functions.py", 36 "pw_rpc/console_tools/watchdog.py", 37 "pw_rpc/descriptors.py", 38 "pw_rpc/ids.py", 39 "pw_rpc/packets.py", 40 "pw_rpc/plugin.py", 41 "pw_rpc/plugin_nanopb.py", 42 "pw_rpc/plugin_pwpb.py", 43 "pw_rpc/plugin_raw.py", 44 ], 45) 46 47pw_py_binary( 48 name = "plugin_raw", 49 srcs = [":pw_rpc_common_sources"], 50 imports = ["."], 51 main = "pw_rpc/plugin_raw.py", 52 python_version = "PY3", 53 deps = [ 54 "//pw_protobuf/py:plugin_library", 55 "//pw_protobuf_compiler/py:pw_protobuf_compiler", 56 "//pw_status/py:pw_status", 57 "@com_google_protobuf//:protobuf_python", 58 ], 59) 60 61pw_py_binary( 62 name = "plugin_nanopb", 63 srcs = [":pw_rpc_common_sources"], 64 imports = ["."], 65 main = "pw_rpc/plugin_nanopb.py", 66 python_version = "PY3", 67 deps = [ 68 "//pw_protobuf/py:plugin_library", 69 "//pw_protobuf_compiler/py:pw_protobuf_compiler", 70 "//pw_status/py:pw_status", 71 "@com_google_protobuf//:protobuf_python", 72 ], 73) 74 75pw_py_binary( 76 name = "plugin_pwpb", 77 srcs = [":pw_rpc_common_sources"], 78 imports = ["."], 79 main = "pw_rpc/plugin_pwpb.py", 80 python_version = "PY3", 81 deps = [ 82 "//pw_protobuf/py:plugin_library", 83 "//pw_protobuf_compiler/py:pw_protobuf_compiler", 84 "//pw_status/py:pw_status", 85 "@com_google_protobuf//:protobuf_python", 86 ], 87) 88 89py_library( 90 name = "pw_rpc", 91 srcs = [ 92 "pw_rpc/__init__.py", 93 "pw_rpc/client.py", 94 "pw_rpc/client_utils.py", 95 ":pw_rpc_common_sources", 96 ], 97 imports = ["."], 98 deps = [ 99 "//pw_protobuf/py:pw_protobuf", 100 "//pw_protobuf_compiler/py:pw_protobuf_compiler", 101 "//pw_rpc:internal_packet_proto_pb2", 102 "//pw_status/py:pw_status", 103 "//pw_stream/py:pw_stream", 104 ], 105) 106 107pw_py_test( 108 name = "callback_client_test", 109 size = "small", 110 srcs = [ 111 "tests/callback_client_test.py", 112 ], 113 data = [ 114 "@com_google_protobuf//:protoc", 115 ], 116 env = { 117 "PROTOC": "$(location @com_google_protobuf//:protoc)", 118 }, 119 deps = [ 120 ":pw_rpc", 121 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 122 "//pw_rpc:internal_packet_proto_pb2", 123 "//pw_status/py:pw_status", 124 ], 125) 126 127pw_py_test( 128 name = "client_test", 129 size = "small", 130 srcs = [ 131 "tests/client_test.py", 132 ], 133 data = [ 134 "@com_google_protobuf//:protoc", 135 ], 136 env = { 137 "PROTOC": "$(location @com_google_protobuf//:protoc)", 138 }, 139 deps = [ 140 ":pw_rpc", 141 "//pw_rpc:internal_packet_proto_pb2", 142 "//pw_status/py:pw_status", 143 ], 144) 145 146pw_py_test( 147 name = "descriptors_test", 148 size = "small", 149 srcs = [ 150 "tests/descriptors_test.py", 151 ], 152 data = [ 153 "@com_google_protobuf//:protoc", 154 ], 155 env = { 156 "PROTOC": "$(location @com_google_protobuf//:protoc)", 157 }, 158 deps = [ 159 ":pw_rpc", 160 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 161 "@com_google_protobuf//:protobuf_python", 162 ], 163) 164 165pw_py_test( 166 name = "ids_test", 167 size = "small", 168 srcs = [ 169 "tests/ids_test.py", 170 ], 171 deps = [ 172 ":pw_rpc", 173 "//pw_build/py:pw_build", 174 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 175 ], 176) 177 178pw_py_test( 179 name = "packets_test", 180 size = "small", 181 srcs = [ 182 "tests/packets_test.py", 183 ], 184 deps = [ 185 ":pw_rpc", 186 "//pw_rpc:internal_packet_proto_pb2", 187 "//pw_status/py:pw_status", 188 ], 189) 190 191pw_py_test( 192 name = "console_tools_test", 193 size = "small", 194 srcs = [ 195 "tests/console_tools/console_tools_test.py", 196 ], 197 data = [ 198 "@com_google_protobuf//:protoc", 199 ], 200 env = { 201 "PROTOC": "$(location @com_google_protobuf//:protoc)", 202 }, 203 deps = [ 204 ":pw_rpc", 205 ], 206) 207 208pw_py_test( 209 name = "functions_test", 210 size = "small", 211 srcs = [ 212 "tests/console_tools/functions_test.py", 213 ], 214 deps = [ 215 ":pw_rpc", 216 ], 217) 218 219pw_py_test( 220 name = "watchdog_test", 221 size = "small", 222 srcs = [ 223 "tests/console_tools/watchdog_test.py", 224 ], 225 deps = [ 226 ":pw_rpc", 227 ], 228) 229