• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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")
17
18package(default_visibility = ["//visibility:public"])
19
20licenses(["notice"])
21
22filegroup(
23    name = "pw_protobuf_common_sources",
24    srcs = [
25        "pw_protobuf/__init__.py",
26        "pw_protobuf/codegen_pwpb.py",
27        "pw_protobuf/edition_constants.py",
28        "pw_protobuf/options.py",
29        "pw_protobuf/output_file.py",
30        "pw_protobuf/plugin.py",
31        "pw_protobuf/proto_tree.py",
32        "pw_protobuf/symbol_name_mapping.py",
33    ],
34)
35
36py_library(
37    name = "plugin_library",
38    srcs = [":pw_protobuf_common_sources"],
39    imports = [
40        # For importing pw_protobuf
41        ".",
42        # For importing pw_protobuf_codegen_protos and pw_protobuf_protos
43        "..",
44    ],
45    deps = [
46        "//pw_protobuf:codegen_protos_pb2",
47        "//pw_protobuf:field_options_proto_pb2",
48        "@com_google_protobuf//:protobuf_python",
49    ],
50)
51
52pw_py_binary(
53    name = "plugin",
54    srcs = ["pw_protobuf/plugin.py"],
55    args = ["--exclude-legacy-snake-case-field-name-enums"],
56    imports = ["."],
57    python_version = "PY3",
58    deps = [
59        ":plugin_library",
60        "@com_google_protobuf//:protobuf_python",
61    ],
62)
63
64py_library(
65    name = "pw_protobuf",
66    srcs = [":pw_protobuf_common_sources"],
67    deps = ["//pw_cli/py:pw_cli"],
68)
69