Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto: documentation to change dependencies #173

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,37 @@ rust_proto_toolchain(
)
```

Finally, now that you have your own toolchain, you need to register it by
Now that you have your own toolchain, you need to register it by
inserting the following statement in your `WORKSPACE` file:

```python
register_toolchains(["//package:toolchain"])
```

Finally, you might want to set the `rust_deps` attribute in
`rust_proto_library` and `rust_grpc_library` to change the compile-time
dependencies:

```python
rust_proto_library(
...
rust_deps = ["//cargo_raze/remote:protobuf"],
...
)

rust_grpc_library(
...
rust_deps = [
"//cargo_raze/remote:protobuf",
"//cargo_raze/remote:grpc",
"//cargo_raze/remote:tls_api",
"//cargo_raze/remote:tls_api_stub",
],
...
)
```

__Note__: Ideally, we would inject those dependencies from the toolchain,
but due to [bazelbuild/bazel#6889](https://github.com/bazelbuild/bazel/issues/6889)
all dependencies added via the toolchain ends-up being in the wrong
configuration.
19 changes: 4 additions & 15 deletions proto/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ def _rust_proto_toolchain_impl(ctx):
return platform_common.ToolchainInfo(
protoc = ctx.executable.protoc,
proto_plugin = ctx.file.proto_plugin,
proto_compile_deps = ctx.attr.proto_compile_deps,
grpc_plugin = ctx.file.grpc_plugin,
grpc_compile_deps = ctx.attr.grpc_compile_deps,
edition = ctx.attr.edition,
)
)

PROTO_COMPILE_DEPS = [
"@io_bazel_rules_rust//proto/raze:protobuf",
Expand All @@ -121,6 +119,9 @@ GRPC_COMPILE_DEPS = PROTO_COMPILE_DEPS + [
]
"""Default dependencies needed to compile gRPC stubs."""

# TODO(damienmg): Once bazelbuild/bazel#6889 is fixed, reintroduce
# proto_compile_deps and grpc_compile_deps and remove them from the
# rust_proto_library and grpc_proto_library.
rust_proto_toolchain = rule(
_rust_proto_toolchain_impl,
attrs = {
Expand Down Expand Up @@ -150,16 +151,6 @@ rust_proto_toolchain = rule(
doc = "The edition used by the generated rust source.",
default = "2015",
),
"proto_compile_deps": attr.label_list(
allow_files = True,
cfg = "target",
default = [Label(l) for l in PROTO_COMPILE_DEPS],
),
"grpc_compile_deps": attr.label_list(
allow_files = True,
cfg = "target",
default = [Label(l) for l in GRPC_COMPILE_DEPS],
),
},
)

Expand All @@ -176,8 +167,6 @@ Args:
optional_output_wrapper: An executable
grpc_plugin: The location of the Rust protobuf compiler pugin to generate
gRPC stubs.
proto_compile_deps: dependencies for rust compilation of protobuf stubs.
grpc_compile_deps: dependencies for rust compilation of gRPC stubs.

Example:
Suppose a new nicer gRPC plugin has came out. Using this new plugin can be
Expand Down