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_binary", "py_library", "py_test") 16load("//pw_build:selects.bzl", "TARGET_COMPATIBLE_WITH_HOST_SELECT") 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 47py_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 61py_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 75py_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_common_sources", 95 ], 96 imports = ["."], 97 deps = [ 98 "//pw_protobuf/py:pw_protobuf", 99 "//pw_protobuf_compiler/py:pw_protobuf_compiler", 100 "//pw_rpc:internal_packet_proto_pb2", 101 "//pw_status/py:pw_status", 102 ], 103) 104 105py_test( 106 name = "callback_client_test", 107 size = "small", 108 srcs = [ 109 "tests/callback_client_test.py", 110 ], 111 data = [ 112 "@com_google_protobuf//:protoc", 113 ], 114 env = { 115 "PROTOC": "$(location @com_google_protobuf//:protoc)", 116 }, 117 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 118 deps = [ 119 ":pw_rpc", 120 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 121 "//pw_rpc:internal_packet_proto_pb2", 122 "//pw_status/py:pw_status", 123 ], 124) 125 126py_test( 127 name = "client_test", 128 size = "small", 129 srcs = [ 130 "tests/client_test.py", 131 ], 132 data = [ 133 "@com_google_protobuf//:protoc", 134 ], 135 env = { 136 "PROTOC": "$(location @com_google_protobuf//:protoc)", 137 }, 138 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 139 deps = [ 140 ":pw_rpc", 141 "//pw_rpc:internal_packet_proto_pb2", 142 "//pw_status/py:pw_status", 143 ], 144) 145 146py_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 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 159 deps = [ 160 ":pw_rpc", 161 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 162 "@com_google_protobuf//:protobuf_python", 163 ], 164) 165 166py_test( 167 name = "ids_test", 168 size = "small", 169 srcs = [ 170 "tests/ids_test.py", 171 ], 172 deps = [ 173 ":pw_rpc", 174 "//pw_build/py:pw_build", 175 "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2", 176 ], 177) 178 179py_test( 180 name = "packets_test", 181 size = "small", 182 srcs = [ 183 "tests/packets_test.py", 184 ], 185 deps = [ 186 ":pw_rpc", 187 "//pw_rpc:internal_packet_proto_pb2", 188 "//pw_status/py:pw_status", 189 ], 190) 191