Skip to content

Commit

Permalink
Replace rust rules with new prost and tonic rules
Browse files Browse the repository at this point in the history
  • Loading branch information
titanous committed Jan 26, 2023
1 parent bbb8193 commit 0b97a94
Show file tree
Hide file tree
Showing 231 changed files with 16,944 additions and 8,017 deletions.
8 changes: 4 additions & 4 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ tasks:
shell_commands:
- set -x
- export CC=clang
- make rust_rust_proto_compile_example
- make rust_rust_grpc_compile_example
- make rust_rust_proto_library_example
- make rust_rust_grpc_library_example
- make rust_rust_prost_proto_compile_example
- make rust_rust_tonic_grpc_compile_example
- make rust_rust_prost_proto_library_example
- make rust_rust_tonic_grpc_library_example

scala_ubuntu2004_examples:
name: scala examples
Expand Down
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build --compilation_mode=opt
build --strip=never

build --experimental_proto_descriptor_sets_include_source_info
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.0.0
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ buildifier:
bazel run //tools:buildifier


# Run cargo raze on the rust dependencies
.PHONY: rust_raze
rust_raze:
cd rust/raze; \
rm Cargo.raze.lock || true; \
rm -r remote; \
cargo raze;
# Run crate_universe to update the rust dependencies
.PHONY: rust_crates_vendor
rust_crates_vendor:
bazel run //rust:crates_vendor -- --repin


# Run yarn to upgrade the js dependencies
Expand Down Expand Up @@ -66,7 +63,7 @@ fsharp_regenerate_packages:

# Run all language specific updates
.PHONY: all_updates
all_updates: rust_raze yarn_upgrade ruby_bundle_upgrade pip_compile csharp_regenerate_packages fsharp_regenerate_packages
all_updates: rust_crates_vendor yarn_upgrade ruby_bundle_upgrade pip_compile csharp_regenerate_packages fsharp_regenerate_packages


# Pull in auto-generated examples makefile
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ Full documentation for the current and previous versions [can be found here](htt
| [Ruby](https://rules-proto-grpc.com/en/latest/lang/ruby.html) | [ruby_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/ruby.html#ruby-grpc-compile) | Generates Ruby protobuf and gRPC ``.rb`` files ([example](/example/ruby/ruby_grpc_compile)) |
| [Ruby](https://rules-proto-grpc.com/en/latest/lang/ruby.html) | [ruby_proto_library](https://rules-proto-grpc.com/en/latest/lang/ruby.html#ruby-proto-library) | Generates a Ruby protobuf library using ``ruby_library`` from ``rules_ruby`` ([example](/example/ruby/ruby_proto_library)) |
| [Ruby](https://rules-proto-grpc.com/en/latest/lang/ruby.html) | [ruby_grpc_library](https://rules-proto-grpc.com/en/latest/lang/ruby.html#ruby-grpc-library) | Generates a Ruby protobuf and gRPC library using ``ruby_library`` from ``rules_ruby`` ([example](/example/ruby/ruby_grpc_library)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_proto_compile](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-proto-compile) | Generates Rust protobuf ``.rs`` files ([example](/example/rust/rust_proto_compile)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-grpc-compile) | Generates Rust protobuf and gRPC ``.rs`` files ([example](/example/rust/rust_grpc_compile)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_proto_library](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-proto-library) | Generates a Rust protobuf library using ``rust_library`` from ``rules_rust`` ([example](/example/rust/rust_proto_library)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_grpc_library](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-grpc-library) | Generates a Rust protobuf and gRPC library using ``rust_library`` from ``rules_rust`` ([example](/example/rust/rust_grpc_library)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_prost_proto_compile](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-prost-proto-compile) | Generates Rust protobuf ``.rs`` files using prost ([example](/example/rust/rust_prost_proto_compile)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_tonic_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-tonic-grpc-compile) | Generates Rust protobuf and gRPC ``.rs`` files using prost and tonic ([example](/example/rust/rust_tonic_grpc_compile)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_prost_proto_library](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-prost-proto-library) | Generates a Rust prost protobuf library using ``rust_library`` from ``rules_rust`` ([example](/example/rust/rust_prost_proto_library)) |
| [Rust](https://rules-proto-grpc.com/en/latest/lang/rust.html) | [rust_tonic_grpc_library](https://rules-proto-grpc.com/en/latest/lang/rust.html#rust-tonic-grpc-library) | Generates a Rust prost protobuf and tonic gRPC library using ``rust_library`` from ``rules_rust`` ([example](/example/rust/rust_tonic_grpc_library)) |
| [Scala](https://rules-proto-grpc.com/en/latest/lang/scala.html) | [scala_proto_compile](https://rules-proto-grpc.com/en/latest/lang/scala.html#scala-proto-compile) | Generates a Scala protobuf ``.jar`` file ([example](/example/scala/scala_proto_compile)) |
| [Scala](https://rules-proto-grpc.com/en/latest/lang/scala.html) | [scala_grpc_compile](https://rules-proto-grpc.com/en/latest/lang/scala.html#scala-grpc-compile) | Generates Scala protobuf and gRPC ``.jar`` file ([example](/example/scala/scala_grpc_compile)) |
| [Scala](https://rules-proto-grpc.com/en/latest/lang/scala.html) | [scala_proto_library](https://rules-proto-grpc.com/en/latest/lang/scala.html#scala-proto-library) | Generates a Scala protobuf library using ``scala_library`` from ``rules_scala`` ([example](/example/scala/scala_proto_library)) |
Expand Down
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ rules_rust_dependencies()

rust_register_toolchains(edition = "2021")

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")

crate_universe_dependencies(bootstrap = True)

load("//rust/crates:crates.bzl", "crate_repositories")

crate_repositories()

#
# Scala
#
Expand Down
125 changes: 76 additions & 49 deletions docs/lang/rust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
Rust
====

Rules for generating Rust protobuf and gRPC ``.rs`` files and libraries using `rust-protobuf <https://github.com/stepancheg/rust-protobuf>`_ and `grpc <https://github.com/stepancheg/grpc-rust>`_. Libraries are created with ``rust_library`` from `rules_rust <https://github.com/bazelbuild/rules_rust>`_.
Rules for generating Rust protobuf and gRPC ``.rs`` files and libraries using `prost <https://github.com/tokio-rs/prost>`_ and `tonic <https://github.com/hyperium/tonic>`_. Libraries are created with ``rust_library`` from `rules_rust <https://github.com/bazelbuild/rules_rust>`_. Requires ``--experimental_proto_descriptor_sets_include_source_info`` to be set for the build.

.. list-table:: Rules
:widths: 1 2
:header-rows: 1

* - Rule
- Description
* - `rust_proto_compile`_
- Generates Rust protobuf ``.rs`` files
* - `rust_grpc_compile`_
- Generates Rust protobuf and gRPC ``.rs`` files
* - `rust_proto_library`_
- Generates a Rust protobuf library using ``rust_library`` from ``rules_rust``
* - `rust_grpc_library`_
- Generates a Rust protobuf and gRPC library using ``rust_library`` from ``rules_rust``
* - `rust_prost_proto_compile`_
- Generates Rust protobuf ``.rs`` files using prost
* - `rust_tonic_grpc_compile`_
- Generates Rust protobuf and gRPC ``.rs`` files using prost and tonic
* - `rust_prost_proto_library`_
- Generates a Rust prost protobuf library using ``rust_library`` from ``rules_rust``
* - `rust_tonic_grpc_library`_
- Generates a Rust prost protobuf and tonic gRPC library using ``rust_library`` from ``rules_rust``

.. _rust_proto_compile:
.. _rust_prost_proto_compile:

rust_proto_compile
------------------
rust_prost_proto_compile
------------------------

Generates Rust protobuf ``.rs`` files
Generates Rust protobuf ``.rs`` files using prost

Example
*******

Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_proto_compile>`__
Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_prost_proto_compile>`__

``WORKSPACE``
^^^^^^^^^^^^^
Expand All @@ -59,27 +59,27 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul

.. code-block:: python
load("@rules_proto_grpc//rust:defs.bzl", "rust_proto_compile")
load("@rules_proto_grpc//rust:defs.bzl", "rust_prost_proto_compile")
rust_proto_compile(
rust_prost_proto_compile(
name = "person_rust_proto",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
)
rust_proto_compile(
rust_prost_proto_compile(
name = "place_rust_proto",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
)
rust_proto_compile(
rust_prost_proto_compile(
name = "thing_rust_proto",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
Attributes
**********

.. list-table:: Attributes for rust_proto_compile
.. list-table:: Attributes for rust_prost_proto_compile
:widths: 1 1 1 1 4
:header-rows: 1

Expand Down Expand Up @@ -127,19 +127,20 @@ Attributes
Plugins
*******

- `@rules_proto_grpc//rust:rust_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:rust_prost_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:rust_crate_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__

.. _rust_grpc_compile:
.. _rust_tonic_grpc_compile:

rust_grpc_compile
-----------------
rust_tonic_grpc_compile
-----------------------

Generates Rust protobuf and gRPC ``.rs`` files
Generates Rust protobuf and gRPC ``.rs`` files using prost and tonic

Example
*******

Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_grpc_compile>`__
Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_tonic_grpc_compile>`__

``WORKSPACE``
^^^^^^^^^^^^^
Expand All @@ -165,22 +166,22 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul

.. code-block:: python
load("@rules_proto_grpc//rust:defs.bzl", "rust_grpc_compile")
load("@rules_proto_grpc//rust:defs.bzl", "rust_tonic_grpc_compile")
rust_grpc_compile(
rust_tonic_grpc_compile(
name = "thing_rust_grpc",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
rust_grpc_compile(
rust_tonic_grpc_compile(
name = "greeter_rust_grpc",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
)
Attributes
**********

.. list-table:: Attributes for rust_grpc_compile
.. list-table:: Attributes for rust_tonic_grpc_compile
:widths: 1 1 1 1 4
:header-rows: 1

Expand Down Expand Up @@ -228,20 +229,21 @@ Attributes
Plugins
*******

- `@rules_proto_grpc//rust:rust_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:grpc_rust_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:rust_prost_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:rust_tonic_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__
- `@rules_proto_grpc//rust:rust_crate_plugin <https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/rust/BUILD.bazel>`__

.. _rust_proto_library:
.. _rust_prost_proto_library:

rust_proto_library
------------------
rust_prost_proto_library
------------------------

Generates a Rust protobuf library using ``rust_library`` from ``rules_rust``
Generates a Rust prost protobuf library using ``rust_library`` from ``rules_rust``

Example
*******

Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_proto_library>`__
Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_prost_proto_library>`__

``WORKSPACE``
^^^^^^^^^^^^^
Expand All @@ -267,10 +269,10 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul

.. code-block:: python
load("@rules_proto_grpc//rust:defs.bzl", "rust_proto_library")
load("@rules_proto_grpc//rust:defs.bzl", "rust_prost_proto_library")
rust_proto_library(
name = "proto_rust_proto",
rust_prost_proto_library(
name = "proto_rust_prost_proto",
protos = [
"@rules_proto_grpc//example/proto:person_proto",
"@rules_proto_grpc//example/proto:place_proto",
Expand All @@ -281,7 +283,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
Attributes
**********

.. list-table:: Attributes for rust_proto_library
.. list-table:: Attributes for rust_prost_proto_library
:widths: 1 1 1 1 4
:header-rows: 1

Expand Down Expand Up @@ -330,18 +332,28 @@ Attributes
- false
- ``[]``
- List of labels to pass as deps attr to underlying lang_library rule
* - ``prost_deps``
- ``label_list``
- false
- ``["//rust/crates:prost", "//rust/crates:prost-types"]``
- The prost dependencies that the rust library should depend on.
* - ``prost_derive_dep``
- ``label``
- false
- ``//rust/crates:prost-derive``
- The prost-derive dependency that the rust library should depend on.

.. _rust_grpc_library:
.. _rust_tonic_grpc_library:

rust_grpc_library
-----------------
rust_tonic_grpc_library
-----------------------

Generates a Rust protobuf and gRPC library using ``rust_library`` from ``rules_rust``
Generates a Rust prost protobuf and tonic gRPC library using ``rust_library`` from ``rules_rust``

Example
*******

Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_grpc_library>`__
Full example project can be found `here <https://github.com/rules-proto-grpc/rules_proto_grpc/tree/master/example/rust/rust_tonic_grpc_library>`__

``WORKSPACE``
^^^^^^^^^^^^^
Expand All @@ -367,10 +379,10 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul

.. code-block:: python
load("@rules_proto_grpc//rust:defs.bzl", "rust_grpc_library")
load("@rules_proto_grpc//rust:defs.bzl", "rust_tonic_grpc_library")
rust_grpc_library(
name = "greeter_rust_grpc",
rust_tonic_grpc_library(
name = "greeter_rust_tonic_grpc",
protos = [
"@rules_proto_grpc//example/proto:greeter_grpc",
"@rules_proto_grpc//example/proto:thing_proto",
Expand All @@ -380,7 +392,7 @@ Full example project can be found `here <https://github.com/rules-proto-grpc/rul
Attributes
**********

.. list-table:: Attributes for rust_grpc_library
.. list-table:: Attributes for rust_tonic_grpc_library
:widths: 1 1 1 1 4
:header-rows: 1

Expand Down Expand Up @@ -429,3 +441,18 @@ Attributes
- false
- ``[]``
- List of labels to pass as deps attr to underlying lang_library rule
* - ``prost_deps``
- ``label_list``
- false
- ``["//rust/crates:prost", "//rust/crates:prost-types"]``
- The prost dependencies that the rust library should depend on.
* - ``prost_derive_dep``
- ``label``
- false
- ``//rust/crates:prost-derive``
- The prost-derive dependency that the rust library should depend on.
* - ``tonic_dep``
- ``label``
- false
- ``//rust/crates:tonic``
- The tonic dependency that the rust library should depend on.
Loading

0 comments on commit 0b97a94

Please sign in to comment.