1 """upb_minitable_proto_library() exposes upb's generated minitables (foo.upb_minitable.h)"""
3 load("//bazel/common:proto_info.bzl", "ProtoInfo")
4 load("//bazel/private:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
5 load("//bazel/private:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
6 load("//bazel/private:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
8 UpbMinitableCcInfo = provider(
9 "Provider for cc_info for protos",
13 _UpbWrappedGeneratedSrcsInfo = provider(
14 "Provider for generated sources",
18 def _upb_minitable_proto_library_aspect_impl(target, ctx):
19 return upb_proto_aspect_impl(
22 generator = "upb_minitable",
23 cc_provider = UpbMinitableCcInfo,
24 dep_cc_provider = None,
25 file_provider = _UpbWrappedGeneratedSrcsInfo,
28 def _get_upb_minitable_proto_library_aspect_provides():
31 _UpbWrappedGeneratedSrcsInfo,
34 if hasattr(cc_common, "CcSharedLibraryHintInfo"):
35 provides.append(cc_common.CcSharedLibraryHintInfo)
36 elif hasattr(cc_common, "CcSharedLibraryHintInfo_6_X_getter_do_not_use"):
37 # This branch can be deleted once 6.X is not supported by upb rules
38 provides.append(cc_common.CcSharedLibraryHintInfo_6_X_getter_do_not_use)
42 upb_minitable_proto_library_aspect = aspect(
45 default = "//upb:upb_proto_library_copts__for_generated_code_only_do_not_use",
47 "_upb_minitable_toolchain": attr.label(
48 default = Label("//upb_generator/minitable:toolchain"),
50 "_cc_toolchain": attr.label(
51 default = "@bazel_tools//tools/cpp:current_cc_toolchain",
53 "_fasttable_enabled": attr.label(default = "//upb:fasttable_enabled"),
55 implementation = _upb_minitable_proto_library_aspect_impl,
56 provides = _get_upb_minitable_proto_library_aspect_provides(),
57 attr_aspects = ["deps"],
59 toolchains = upb_use_cpp_toolchain(),
61 "proto_compiler": exec_group(),
65 def _upb_minitable_proto_library_rule_impl(ctx):
66 return upb_proto_rule_impl(ctx, UpbMinitableCcInfo, _UpbWrappedGeneratedSrcsInfo)
68 upb_minitable_proto_library = rule(
69 implementation = _upb_minitable_proto_library_rule_impl,
71 "deps": attr.label_list(
72 aspects = [upb_minitable_proto_library_aspect],
73 allow_rules = ["proto_library"],
74 providers = [ProtoInfo],