1 """Internal rule implementation for upb_*_proto_library() rules."""
3 def _filter_none(elems):
10 def upb_proto_rule_impl(ctx, cc_info_provider, srcs_provider):
11 """An implementation for upb_*proto_library() rules.
14 ctx: The rule `ctx` argument
15 cc_info_provider: The provider containing a wrapped CcInfo that will be exposed to users who
17 srcs_provider: The provider containing the generated source files. This will be used to make
18 the DefaultInfo return the source files.
21 Providers for this rule.
23 if len(ctx.attr.deps) != 1:
24 fail("only one deps dependency allowed.")
25 dep = ctx.attr.deps[0]
26 srcs = dep[srcs_provider].srcs
27 cc_info = dep[cc_info_provider].cc_info
29 lib = cc_info.linking_context.linker_inputs.to_list()[0].libraries[0]
30 files = _filter_none([
32 lib.pic_static_library,
36 DefaultInfo(files = depset(files + srcs.hdrs + srcs.srcs)),