Skip to content

Consolidate rust_prost_library and fix extension-only proto generation. #2047

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

Merged
merged 3 commits into from
Jul 5, 2023
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
4 changes: 4 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ load("//test:deps.bzl", "rules_rust_test_deps")

rules_rust_test_deps()

load("//test:deps_transitive.bzl", "rules_rust_test_deps_transitive")

rules_rust_test_deps_transitive()

# --- end stardoc

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand Down
1 change: 0 additions & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ PAGES = dict([
"rust_proto_transitive_repositories",
"rust_proto_toolchain",
"rust_prost_library",
"rust_tonic_library",
],
),
page(
Expand Down
20 changes: 0 additions & 20 deletions docs/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* [rust_stdlib_filegroup](#rust_stdlib_filegroup)
* [rust_test](#rust_test)
* [rust_test_suite](#rust_test_suite)
* [rust_tonic_library](#rust_tonic_library)
* [rust_toolchain](#rust_toolchain)
* [rust_toolchain_repository](#rust_toolchain_repository)
* [rust_toolchain_repository_proxy](#rust_toolchain_repository_proxy)
Expand Down Expand Up @@ -2017,25 +2016,6 @@ rust_test_suite(
| <a id="rust_test_suite-kwargs"></a>kwargs | Additional keyword arguments for the underyling [rust_test](#rust_test) targets. The <code>tags</code> argument is also passed to the generated <code>test_suite</code> target. | none |


<a id="rust_tonic_library"></a>

## rust_tonic_library

<pre>
rust_tonic_library(<a href="#rust_tonic_library-name">name</a>, <a href="#rust_tonic_library-kwargs">kwargs</a>)
</pre>

A rule for generating a Rust library using Prost and Tonic.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="rust_tonic_library-name"></a>name | The name of the target. | none |
| <a id="rust_tonic_library-kwargs"></a>kwargs | Additional keyword arguments for the underlying <code>rust_tonic_library</code> rule. | none |


<a id="rust_toolchain_repository"></a>

## rust_toolchain_repository
Expand Down
23 changes: 1 addition & 22 deletions docs/rust_proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
* [rust_proto_transitive_repositories](#rust_proto_transitive_repositories)
* [rust_proto_toolchain](#rust_proto_toolchain)
* [rust_prost_library](#rust_prost_library)
* [rust_tonic_library](#rust_tonic_library)


## Overview
These build rules are used for building [protobufs][protobuf]/[gRPC][grpc] in [Rust][rust] with Bazel.

There are two rule sets. The first ruleset defines the `rust_proto_library` and `rust_grpc_library`
rules which generate Rust code using the [`rust-protobuf`] dependencies. The second ruleset defines
the `rust_prost_library` and `rust_tonic_library` rules which generate Rust code using the [`prost`]
and [`tonic`] dependencies respectively.
the `rust_prost_library` which generates Rust code using the [`prost`] and [`tonic`] dependencies.

[rust]: http://www.rust-lang.org/
[protobuf]: https://developers.google.com/protocol-buffers/
Expand Down Expand Up @@ -427,22 +425,3 @@ This macro should be called immediately after the `rust_proto_repositories` macr



<a id="rust_tonic_library"></a>

## rust_tonic_library

<pre>
rust_tonic_library(<a href="#rust_tonic_library-name">name</a>, <a href="#rust_tonic_library-kwargs">kwargs</a>)
</pre>

A rule for generating a Rust library using Prost and Tonic.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="rust_tonic_library-name"></a>name | The name of the target. | none |
| <a id="rust_tonic_library-kwargs"></a>kwargs | Additional keyword arguments for the underlying <code>rust_tonic_library</code> rule. | none |


3 changes: 1 addition & 2 deletions docs/rust_proto.vm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ These build rules are used for building [protobufs][protobuf]/[gRPC][grpc] in [R

There are two rule sets. The first ruleset defines the `rust_proto_library` and `rust_grpc_library`
rules which generate Rust code using the [`rust-protobuf`] dependencies. The second ruleset defines
the `rust_prost_library` and `rust_tonic_library` rules which generate Rust code using the [`prost`]
and [`tonic`] dependencies respectively.
the `rust_prost_library` which generates Rust code using the [`prost`] and [`tonic`] dependencies.

[rust]: http://www.rust-lang.org/
[protobuf]: https://developers.google.com/protocol-buffers/
Expand Down
2 changes: 0 additions & 2 deletions docs/symbols.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ load(
_rust_grpc_library = "rust_grpc_library",
_rust_prost_library = "rust_prost_library",
_rust_proto_library = "rust_proto_library",
_rust_tonic_library = "rust_tonic_library",
)
load(
"@rules_rust//proto:repositories.bzl",
Expand Down Expand Up @@ -127,7 +126,6 @@ rust_doc_test = _rust_doc_test
rust_proto_library = _rust_proto_library
rust_grpc_library = _rust_grpc_library
rust_prost_library = _rust_prost_library
rust_tonic_library = _rust_tonic_library

rust_bindgen = _rust_bindgen
rust_bindgen_dependencies = _rust_bindgen_dependencies
Expand Down
2 changes: 0 additions & 2 deletions proto/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
load(
"//proto/prost:defs.bzl",
_rust_prost_library = "rust_prost_library",
_rust_tonic_library = "rust_tonic_library",
)
load(
":proto.bzl",
Expand All @@ -15,4 +14,3 @@ rust_proto_library = _rust_proto_library
rust_grpc_library = _rust_grpc_library

rust_prost_library = _rust_prost_library
rust_tonic_library = _rust_tonic_library
24 changes: 0 additions & 24 deletions proto/prost/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load(
"//proto/prost/private:prost.bzl",
_rust_prost_library = "rust_prost_library",
_rust_prost_toolchain = "rust_prost_toolchain",
_rust_tonic_library = "rust_tonic_library",
)

def rust_prost_library(name, **kwargs):
Expand All @@ -30,27 +29,4 @@ def rust_prost_library(name, **kwargs):
**kwargs
)

def rust_tonic_library(name, **kwargs):
"""A rule for generating a Rust library using Prost and Tonic.

Args:
name (str): The name of the target.
**kwargs (dict): Additional keyword arguments for the underlying
`rust_tonic_library` rule.
"""

# Clippy and Rustfmt will attempt to run on these targets.
# This is not correct and likely a bug in target detection.
tags = kwargs.pop("tags", [])
if "no-clippy" not in tags:
tags.append("no-clippy")
if "no-rustfmt" not in tags:
tags.append("no-rustfmt")

_rust_tonic_library(
name = name,
tags = tags,
**kwargs
)

rust_prost_toolchain = _rust_prost_toolchain
Loading