@@ -24,40 +24,40 @@ load("@rules_proto//proto:defs.bzl", "ProtoInfo")
2424
2525def java_lite_proto_cel_library_impl (
2626 name ,
27- proto_src ,
27+ deps ,
2828 java_proto_library_dep ,
29- java_descriptor_class_name = None ,
29+ java_descriptor_class_suffix = None ,
3030 debug = False ):
3131 """Generates a CelLiteDescriptor
3232
3333 Args:
34- name: name of this target.
35- proto_src: Name of the proto_library target.
36- java_descriptor_class_name (optional): Java class name for the generated CEL lite descriptor.
37- By default, CEL will use the first encountered message name in proto_src with "CelLiteDescriptor"
38- suffixed as the class name. Use this field to override this name.
34+ name: Name of this target.
35+ deps: The list of proto_library rules to generate Java code for.
36+ java_descriptor_class_suffix (optional): Suffix for the Java class name of the generated CEL lite descriptor.
37+ Default is "CelLiteDescriptor".
3938 java_proto_library_dep: (optional) Uses the provided java_lite_proto_library or java_proto_library to generate the lite descriptors.
4039 If none is provided, java_lite_proto_library is used by default behind the scenes. Most use cases should not need to provide this.
4140 debug: (optional) If true, prints additional information during codegen for debugging purposes.
4241 """
4342 if not name :
4443 fail ("You must provide a name." )
4544
46- if not proto_src :
47- fail ("You must provide a proto_library dependency." )
45+ if not deps or len ( deps ) < 1 :
46+ fail ("You must provide at least one proto_library dependency." )
4847
4948 generated = name + "_cel_lite_descriptor"
5049 java_lite_proto_cel_library_rule (
5150 name = generated ,
52- descriptor = proto_src ,
53- java_descriptor_class_name = java_descriptor_class_name ,
51+ debug = debug ,
52+ descriptors = deps ,
53+ java_descriptor_class_suffix = java_descriptor_class_suffix ,
5454 )
5555
5656 if not java_proto_library_dep :
5757 java_proto_library_dep = name + "_java_lite_proto_dep"
5858 java_lite_proto_library (
5959 name = java_proto_library_dep ,
60- deps = [ proto_src ] ,
60+ deps = deps ,
6161 )
6262
6363 descriptor_codegen_deps = [
@@ -75,24 +75,35 @@ def _generate_cel_lite_descriptor_class(ctx):
7575 srcjar_output = ctx .actions .declare_file (ctx .attr .name + ".srcjar" )
7676 java_file_path = srcjar_output .path
7777
78- proto_info = ctx .attr .descriptor [ProtoInfo ]
79- transitive_descriptors = proto_info .transitive_descriptor_sets
78+ direct_descriptor_set = depset (
79+ direct = [
80+ descriptor [ProtoInfo ].direct_descriptor_set
81+ for descriptor in ctx .attr .descriptors
82+ ],
83+ )
84+ transitive_descriptor_set = depset (
85+ transitive = [
86+ descriptor [ProtoInfo ].transitive_descriptor_sets
87+ for descriptor in ctx .attr .descriptors
88+ ],
89+ )
8090
8191 args = ctx .actions .args ()
8292 args .add ("--version" , CEL_VERSION )
83- args .add ("--descriptor " , proto_info . direct_descriptor_set )
84- args .add_joined ("--transitive_descriptor_set" , transitive_descriptors , join_with = "," )
93+ args .add_joined ("--descriptor_set " , direct_descriptor_set , join_with = "," )
94+ args .add_joined ("--transitive_descriptor_set" , transitive_descriptor_set , join_with = "," )
8595 args .add ("--out" , java_file_path )
8696
87- if ctx .attr .java_descriptor_class_name :
88- args .add ("--overridden_descriptor_class_name" , ctx .attr .java_descriptor_class_name )
97+ if ctx .attr .java_descriptor_class_suffix :
98+ args .add ("--overridden_descriptor_class_suffix" , ctx .attr .java_descriptor_class_suffix )
99+
89100 if ctx .attr .debug :
90101 args .add ("--debug" )
91102
92103 ctx .actions .run (
93104 mnemonic = "CelLiteDescriptorGenerator" ,
94105 arguments = [args ],
95- inputs = transitive_descriptors ,
106+ inputs = transitive_descriptor_set ,
96107 outputs = [srcjar_output ],
97108 progress_message = "Generating CelLiteDescriptor for: " + ctx .attr .name ,
98109 executable = ctx .executable ._tool ,
@@ -103,8 +114,8 @@ def _generate_cel_lite_descriptor_class(ctx):
103114java_lite_proto_cel_library_rule = rule (
104115 implementation = _generate_cel_lite_descriptor_class ,
105116 attrs = {
106- "java_descriptor_class_name " : attr .string (),
107- "descriptor " : attr .label (
117+ "java_descriptor_class_suffix " : attr .string (),
118+ "descriptors " : attr .label_list (
108119 providers = [ProtoInfo ],
109120 ),
110121 "debug" : attr .bool (),
0 commit comments