1# Copyright 2024 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"""Rule for generating raw C++ RPC proto libraries.""" 15 16load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "use_cpp_toolchain") 17load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo") 18load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") 19load("//pw_protobuf_compiler/private:proto.bzl", "compile_proto", "proto_compiler_aspect") 20 21def raw_rpc_proto_library(*, name, deps, **kwargs): 22 """A raw C++ RPC proto library.""" 23 _pw_raw_rpc_proto_library( 24 name = name, 25 protos = deps, 26 deps = [ 27 Label("//pw_rpc"), 28 Label("//pw_rpc/raw:client_api"), 29 Label("//pw_rpc/raw:server_api"), 30 ], 31 **kwargs 32 ) 33 34_pw_raw_rpc_proto_compiler_aspect = proto_compiler_aspect( 35 ["raw_rpc.pb.h"], 36 "//pw_rpc/py:plugin_raw", 37 ["--no-legacy-namespace"], 38) 39 40_pw_raw_rpc_proto_library = rule( 41 implementation = compile_proto, 42 attrs = { 43 "deps": attr.label_list( 44 providers = [CcInfo], 45 ), 46 "protos": attr.label_list( 47 providers = [ProtoInfo], 48 aspects = [_pw_raw_rpc_proto_compiler_aspect], 49 ), 50 }, 51 fragments = ["cpp"], 52 toolchains = use_cpp_toolchain(), 53) 54