• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18load("//pw_build:python.bzl", "pw_py_binary", "pw_py_test")
19
20package(default_visibility = ["//visibility:public"])
21
22licenses(["notice"])
23
24filegroup(
25    name = "pw_rpc_common_sources",
26    srcs = [
27        "pw_rpc/callback_client/__init__.py",
28        "pw_rpc/callback_client/call.py",
29        "pw_rpc/callback_client/errors.py",
30        "pw_rpc/callback_client/impl.py",
31        "pw_rpc/codegen.py",
32        "pw_rpc/codegen_nanopb.py",
33        "pw_rpc/codegen_pwpb.py",
34        "pw_rpc/codegen_raw.py",
35        "pw_rpc/console_tools/__init__.py",
36        "pw_rpc/console_tools/console.py",
37        "pw_rpc/console_tools/functions.py",
38        "pw_rpc/console_tools/watchdog.py",
39        "pw_rpc/descriptors.py",
40        "pw_rpc/ids.py",
41        "pw_rpc/packets.py",
42        "pw_rpc/plugin.py",
43        "pw_rpc/plugin_nanopb.py",
44        "pw_rpc/plugin_pwpb.py",
45        "pw_rpc/plugin_raw.py",
46    ],
47)
48
49pw_py_binary(
50    name = "plugin_raw",
51    srcs = [":pw_rpc_common_sources"],
52    imports = ["."],
53    main = "pw_rpc/plugin_raw.py",
54    python_version = "PY3",
55    deps = [
56        "//pw_protobuf/py:plugin_library",
57        "//pw_protobuf_compiler/py:pw_protobuf_compiler",
58        "//pw_status/py:pw_status",
59        "@com_google_protobuf//:protobuf_python",
60    ],
61)
62
63pw_py_binary(
64    name = "plugin_nanopb",
65    srcs = [":pw_rpc_common_sources"],
66    imports = ["."],
67    main = "pw_rpc/plugin_nanopb.py",
68    python_version = "PY3",
69    deps = [
70        "//pw_protobuf/py:plugin_library",
71        "//pw_protobuf_compiler/py:pw_protobuf_compiler",
72        "//pw_status/py:pw_status",
73        "@com_google_protobuf//:protobuf_python",
74    ],
75)
76
77pw_py_binary(
78    name = "plugin_pwpb",
79    srcs = [":pw_rpc_common_sources"],
80    imports = ["."],
81    main = "pw_rpc/plugin_pwpb.py",
82    python_version = "PY3",
83    deps = [
84        "//pw_protobuf/py:plugin_library",
85        "//pw_protobuf_compiler/py:pw_protobuf_compiler",
86        "//pw_status/py:pw_status",
87        "@com_google_protobuf//:protobuf_python",
88    ],
89)
90
91py_library(
92    name = "pw_rpc",
93    srcs = [
94        "pw_rpc/__init__.py",
95        "pw_rpc/client.py",
96        "pw_rpc/client_utils.py",
97        ":pw_rpc_common_sources",
98    ],
99    imports = ["."],
100    deps = [
101        "//pw_protobuf/py:pw_protobuf",
102        "//pw_protobuf_compiler/py:pw_protobuf_compiler",
103        "//pw_rpc:internal_packet_proto_pb2",
104        "//pw_status/py:pw_status",
105        "//pw_stream/py:pw_stream",
106    ],
107)
108
109pw_py_test(
110    name = "callback_client_test",
111    size = "small",
112    srcs = [
113        "tests/callback_client_test.py",
114    ],
115    data = [
116        "@com_google_protobuf//:protoc",
117    ],
118    env = {
119        "PROTOC": "$(rootpath @com_google_protobuf//:protoc)",
120    },
121    deps = [
122        ":pw_rpc",
123        "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2",
124        "//pw_rpc:internal_packet_proto_pb2",
125        "//pw_status/py:pw_status",
126    ],
127)
128
129pw_py_test(
130    name = "client_test",
131    size = "small",
132    srcs = [
133        "tests/client_test.py",
134    ],
135    data = [
136        "@com_google_protobuf//:protoc",
137    ],
138    env = {
139        "PROTOC": "$(rootpath @com_google_protobuf//:protoc)",
140    },
141    deps = [
142        ":pw_rpc",
143        "//pw_rpc:internal_packet_proto_pb2",
144        "//pw_status/py:pw_status",
145    ],
146)
147
148pw_py_test(
149    name = "descriptors_test",
150    size = "small",
151    srcs = [
152        "tests/descriptors_test.py",
153    ],
154    data = [
155        "@com_google_protobuf//:protoc",
156    ],
157    env = {
158        "PROTOC": "$(rootpath @com_google_protobuf//:protoc)",
159    },
160    deps = [
161        ":pw_rpc",
162        "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2",
163        "@com_google_protobuf//:protobuf_python",
164    ],
165)
166
167pw_py_test(
168    name = "ids_test",
169    size = "small",
170    srcs = [
171        "tests/ids_test.py",
172    ],
173    deps = [
174        ":pw_rpc",
175        "//pw_build/py:pw_build",
176        "//pw_protobuf_compiler:pw_protobuf_compiler_protos_py_pb2",
177    ],
178)
179
180pw_py_test(
181    name = "packets_test",
182    size = "small",
183    srcs = [
184        "tests/packets_test.py",
185    ],
186    deps = [
187        ":pw_rpc",
188        "//pw_rpc:internal_packet_proto_pb2",
189        "//pw_status/py:pw_status",
190    ],
191)
192
193pw_py_test(
194    name = "console_tools_test",
195    size = "small",
196    srcs = [
197        "tests/console_tools/console_tools_test.py",
198    ],
199    data = [
200        "@com_google_protobuf//:protoc",
201    ],
202    env = {
203        "PROTOC": "$(rootpath @com_google_protobuf//:protoc)",
204    },
205    deps = [
206        ":pw_rpc",
207    ],
208)
209
210pw_py_test(
211    name = "functions_test",
212    size = "small",
213    srcs = [
214        "tests/console_tools/functions_test.py",
215    ],
216    deps = [
217        ":pw_rpc",
218    ],
219)
220
221pw_py_test(
222    name = "watchdog_test",
223    size = "small",
224    srcs = [
225        "tests/console_tools/watchdog_test.py",
226    ],
227    deps = [
228        ":pw_rpc",
229    ],
230)
231
232sphinx_docs_library(
233    name = "docs",
234    srcs = [
235        "docs.rst",
236    ],
237    target_compatible_with = incompatible_with_mcu(),
238)
239