1 """upb_c_proto_library() exposes upb's generated C API for protobuf (foo.upb.h)"""
3 load("//bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
4 load("//bazel/common:proto_info.bzl", "ProtoInfo")
5 load("//bazel/private:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
6 load("//bazel/private:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
7 load("//bazel/private:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
9 UpbWrappedCcInfo = provider(
10 "Provider for cc_info for protos",
14 _UpbWrappedGeneratedSrcsInfo = provider(
15 "Provider for generated sources",
19 def _upb_c_proto_library_aspect_impl(target, ctx):
20 return upb_proto_aspect_impl(
24 cc_provider = UpbWrappedCcInfo,
25 dep_cc_provider = UpbMinitableCcInfo,
26 file_provider = _UpbWrappedGeneratedSrcsInfo,
27 provide_cc_shared_library_hints = False,
30 upb_c_proto_library_aspect = aspect(
33 default = "//upb:upb_proto_library_copts__for_generated_code_only_do_not_use",
35 "_upb_toolchain": attr.label(
36 default = Label("//upb_generator/c:toolchain"),
38 "_cc_toolchain": attr.label(
39 default = "@bazel_tools//tools/cpp:current_cc_toolchain",
42 implementation = _upb_c_proto_library_aspect_impl,
43 requires = [upb_minitable_proto_library_aspect],
44 required_aspect_providers = [UpbMinitableCcInfo],
47 _UpbWrappedGeneratedSrcsInfo,
49 attr_aspects = ["deps"],
51 toolchains = upb_use_cpp_toolchain(),
53 "proto_compiler": exec_group(),
57 def _upb_c_proto_library_rule_impl(ctx):
58 return upb_proto_rule_impl(ctx, UpbWrappedCcInfo, _UpbWrappedGeneratedSrcsInfo)
60 upb_c_proto_library = rule(
61 implementation = _upb_c_proto_library_rule_impl,
63 "deps": attr.label_list(
64 aspects = [upb_c_proto_library_aspect],
65 allow_rules = ["proto_library"],
66 providers = [ProtoInfo],