forked from google/cel-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcel_proto_transitive_descriptor_set.bzl
More file actions
54 lines (49 loc) · 1.84 KB
/
cel_proto_transitive_descriptor_set.bzl
File metadata and controls
54 lines (49 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Provides the `cel_proto_transitive_descriptor_set` build rule.
"""
load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo")
def _cel_proto_transitive_descriptor_set(ctx):
output = ctx.actions.declare_file(ctx.attr.name + ".binarypb")
transitive_descriptor_sets = depset(transitive = [dep[ProtoInfo].transitive_descriptor_sets for dep in ctx.attr.deps])
args = ctx.actions.args()
args.use_param_file(param_file_arg = "%s", use_always = True)
args.add_all(transitive_descriptor_sets)
ctx.actions.run(
outputs = [output],
inputs = transitive_descriptor_sets,
progress_message = "Joining descriptors.",
executable = ctx.executable.cat_tool,
arguments = [args] + [output.path],
)
return DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles(files = [output]),
)
cel_proto_transitive_descriptor_set = rule(
attrs = {
"deps": attr.label_list(providers = [[ProtoInfo]]),
"cat_tool": attr.label(
executable = True,
cfg = "exec",
allow_files = True,
default = Label("//bazel:cat_param_file"),
)
},
outputs = {
"out": "%{name}.binarypb",
},
implementation = _cel_proto_transitive_descriptor_set,
)