Bazel: Simplify the implementation of proto_gen. (#8120)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Samir Talwar 2020-12-01 11:36:10 +01:00 committed by GitHub
parent 7d25cbba8b
commit 4d1cf41adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 50 deletions

View File

@ -44,19 +44,12 @@ def get_plugin_runfiles(tool, plugin_runfiles):
return files
def _proto_gen_impl(ctx):
src_descs = [src[ProtoInfo].direct_descriptor_set for src in ctx.attr.srcs]
dep_descs = [depset for dep in ctx.attr.deps for depset in dep[ProtoInfo].transitive_descriptor_sets.to_list()]
descriptors = src_descs + dep_descs
sources_out = ctx.actions.declare_directory(ctx.attr.name + "-sources")
descriptor_set_delim = "\\;" if _is_windows(ctx) else ":"
args = []
args += [
"--descriptor_set_in=" + descriptor_set_delim.join([d.path for d in descriptors]),
]
args += [
descriptors = [depset for src in ctx.attr.srcs for depset in src[ProtoInfo].transitive_descriptor_sets.to_list()]
args = [
"--descriptor_set_in=" + descriptor_set_delim.join([depset.path for depset in descriptors]),
"--{}_out={}:{}".format(ctx.attr.plugin_name, ",".join(ctx.attr.plugin_options), sources_out.path),
]
plugins = []
@ -133,8 +126,7 @@ def _proto_gen_impl(ctx):
proto_gen = rule(
implementation = _proto_gen_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = [ProtoInfo]),
"srcs": attr.label_list(providers = [ProtoInfo]),
"plugin_name": attr.string(),
"plugin_exec": attr.label(
cfg = "host",
@ -287,7 +279,6 @@ def proto_jars(
plugin_name = "scalapb",
plugin_options = ["grpc"] if grpc else [],
visibility = ["//visibility:public"],
deps = deps + proto_deps,
)
all_scala_deps = _proto_scala_deps(grpc, proto_deps)

View File

@ -16,15 +16,6 @@ proto_gen(
visibility = [
"//visibility:public",
],
deps = [
"@com_github_googleapis_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
)
# this is only needed for the uber-javadoc in //language-support/java:javadoc
@ -57,15 +48,6 @@ proto_gen(
visibility = [
"//visibility:public",
],
deps = [
"@com_github_googleapis_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
)
da_java_library(

View File

@ -251,16 +251,6 @@ proto_gen(
visibility = [
"//visibility:public",
],
deps = [
"@com_github_googleapis_googleapis//google/rpc:code_proto",
"@com_github_googleapis_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
)
genrule(

View File

@ -12,15 +12,6 @@ proto_gen(
],
plugin_exec = "//scala-protoc-plugins/scala-akka:protoc-gen-scala-akka",
plugin_name = "scala-akka",
deps = [
"@com_github_googleapis_googleapis//google/rpc:status_proto",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
],
)
da_scala_library(