Skip to content

Commit

Permalink
Bazel rules: Adjust accessing ProtoInfo of dependencies
Browse files Browse the repository at this point in the history
To be compatible with Bazel 0.29+. See also:
bazelbuild/bazel#7152

Change-Id: Idd53f148aadc44c727966e8910f2776704a018a6
GitOrigin-RevId: 6922a516dd7c4a9c2cc8a981f2e4b9f74488ed78
  • Loading branch information
gertvdijk committed Sep 11, 2019
1 parent 936c3ff commit 0543d08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions bazel/rules_proto_py/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def _protoc_output_path(proto_src, suffix):
return _proto_path(proto_src).replace("-", "_").replace(".proto", suffix)

def _py_proto_library_gen_impl(ctx):
srcs = [f for dep in ctx.attr.deps for f in dep.proto.transitive_sources.to_list()]
includes = [f for dep in ctx.attr.deps for f in dep.proto.transitive_imports.to_list()]
srcs = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].transitive_sources.to_list()]
includes = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].transitive_imports.to_list()]

proto_include_args = ["--proto_path={0}={1}".format(_proto_path(include), include.path) for include in includes]
options = ",".join([]) # Empty, for now.
Expand All @@ -49,6 +49,7 @@ _py_proto_library_gen = rule(
attrs = {
"deps": attr.label_list(
mandatory = True,
providers = [ProtoInfo],
),
"_protoc": attr.label(
default = Label("@com_google_protobuf//:protoc"),
Expand Down Expand Up @@ -79,8 +80,8 @@ def py_proto_library(name, deps, **kwargs):
)

def _py_grpc_library_gen_impl(ctx):
srcs = [f for dep in ctx.attr.deps for f in dep.proto.transitive_sources.to_list()]
includes = [f for dep in ctx.attr.deps for f in dep.proto.transitive_imports.to_list()]
srcs = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].transitive_sources.to_list()]
includes = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].transitive_imports.to_list()]

proto_include_args = ["--proto_path={0}={1}".format(_proto_path(include), include.path) for include in includes]
options = ",".join([]) # Empty, for now.
Expand Down Expand Up @@ -134,6 +135,7 @@ _py_grpc_library_gen = rule(
attrs = {
"deps": attr.label_list(
mandatory = True,
providers = [ProtoInfo],
),
"includes": attr.label_list(),
"_protoc": attr.label(
Expand Down
5 changes: 3 additions & 2 deletions bazel/rules_protodoc/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def _protoc_output_path(proto_src):
return _proto_path(proto_src).replace("-", "_").replace(".proto", "")

def _rst_proto_gen_impl(ctx):
srcs = [f for dep in ctx.attr.deps for f in dep.proto.direct_sources]
includes = [f for dep in ctx.attr.deps for f in dep.proto.transitive_imports.to_list()]
srcs = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].direct_sources]
includes = [f for dep in ctx.attr.deps for f in dep[ProtoInfo].transitive_imports.to_list()]

proto_include_args = ["--proto_path={0}={1}".format(_proto_path(include), include.path) for include in includes]
options = ",".join([]) # Empty, for now.
Expand Down Expand Up @@ -49,6 +49,7 @@ _rst_proto_gen = rule(
attrs = {
"deps": attr.label_list(
mandatory = True,
providers = [ProtoInfo],
),
"_protoc": attr.label(
default = Label("@com_google_protobuf//:protoc"),
Expand Down

0 comments on commit 0543d08

Please sign in to comment.