Skip to content

Commit

Permalink
Use tonic for rust proto and grpc. Updates to handle dependency chains.
Browse files Browse the repository at this point in the history
  • Loading branch information
echochamber committed Jun 6, 2023
1 parent 519cef1 commit b02cfc3
Show file tree
Hide file tree
Showing 275 changed files with 11,552 additions and 16,129 deletions.
4 changes: 0 additions & 4 deletions .bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion .bazelversion

This file was deleted.

2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencie

crate_universe_dependencies(bootstrap = True)

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

crate_repositories()

Expand Down
11 changes: 0 additions & 11 deletions example/rust/rust_grpc_compile/BUILD.bazel

This file was deleted.

30 changes: 0 additions & 30 deletions example/rust/rust_grpc_compile/WORKSPACE

This file was deleted.

9 changes: 0 additions & 9 deletions example/rust/rust_grpc_library/BUILD.bazel

This file was deleted.

30 changes: 0 additions & 30 deletions example/rust/rust_grpc_library/WORKSPACE

This file was deleted.

17 changes: 16 additions & 1 deletion example/rust/rust_prost_proto_compile/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ load("@rules_proto_grpc//rust:defs.bzl", "rust_prost_proto_compile")

rust_prost_proto_compile(
name = "person_rust_proto",
declared_proto_packages = ["example.proto"],
options = {
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Person=#[derive(Eq\\,Hash)]"],
},
protos = ["@rules_proto_grpc//example/proto:person_proto"],
)

rust_prost_proto_compile(
name = "place_rust_proto",
declared_proto_packages = ["example.proto"],
options = {
"//rust:rust_prost_plugin": ["type_attribute=.other.space.Place=#[derive(Eq\\,Hash)]"],
},
protos = ["@rules_proto_grpc//example/proto:place_proto"],

prost_proto_deps = []
)

rust_prost_proto_compile(
name = "thing_rust_proto",
declared_proto_packages = ["example.proto"],
options = {
# Known limitation, can't derive if the type contains a pbjson type.
# "//rust:rust_prost_plugin": ["type_attribute=.other.space.Thing=#[derive(Eq\\,Hash)]"],
},
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
)
4 changes: 2 additions & 2 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ VERSIONS = {
# Rust
"rules_rust": {
"type": "http",
"urls": ["https://github.com/bazelbuild/rules_rust/releases/download/0.16.1/rules_rust-v0.16.1.tar.gz"],
"sha256": "aaaa4b9591a5dad8d8907ae2dbe6e0eb49e6314946ce4c7149241648e56a1277",
"urls": ["https://github.com/bazelbuild/rules_rust/releases/download/0.22.0/rules_rust-v0.22.0.tar.gz"],
"sha256": "50272c39f20a3a3507cb56dcb5c3b348bda697a7d868708449e2fa6fb893444c",
},

# Scala
Expand Down
110 changes: 110 additions & 0 deletions rust/3rdparty/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Third party crates/deps for rules_proto_grpc_rust.

load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor")
crates_vendor(
name = "crates_vendor",
annotations = {
"prost-build": [crate.annotation(
build_script_env = {
"PROTOC_NO_VENDOR": "true",
"PROTOC": "$(execpath @com_google_protobuf//:protoc)",
"PROTOC_INCLUDE": ".",
},
build_script_tools = ["@com_google_protobuf//:protoc"],
)],
},
generate_binaries = True,
mode = "remote",
packages = {
"protoc-gen-prost": crate.spec(
version = "0.2.1",
),
# See https://github.com/neoeinstein/protoc-gen-prost/issues/62
"protoc-gen-prost-crate": crate.spec(
git = "https://github.com/neoeinstein/protoc-gen-prost",
rev = "038cd342677dfa869f8c3a2a2787a139fc561df8"
),
"protoc-gen-tonic": crate.spec(
version = "0.2.1",
),
"protoc-gen-prost-serde": crate.spec(
version = "0.2.1",
),
"prost": crate.spec(
version = "0.11.6",
),
"prost-derive": crate.spec(
version = "0.11.6",
),
"prost-types": crate.spec(
version = "0.11.6",
),
"tonic": crate.spec(
version = "0.8.2",
),
"tonic-build": crate.spec(
version = "0.8.2",
),

# routeguide example deps
"serde": crate.spec(
features = ["derive"],
version = "1.0.152",
),
"serde_json": crate.spec(
version = "1.0.91",
),
"rand": crate.spec(
version = "0.8.5",
),
"tokio": crate.spec(
version = "1.24.2",
),
"tokio-stream": crate.spec(
version = "0.1.11",
),
"async-stream": crate.spec(
version = "0.3.3",
),
"futures": crate.spec(
version = "0.3.25",
),
# See: https://github.com/influxdata/pbjson/pull/90
"pbjson-types": crate.spec(
git = 'https://github.com/echochamber/pbjson',
rev = 'a4f760e5d53086d989f28dc9d1d0adcc22fe37c4'
),
"pbjson": crate.spec(
version = "0.5.1",
),
},
repository_name = "rules_proto_grpc_rust",
supported_platform_triples = [
"i686-apple-darwin",
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"aarch64-apple-darwin",
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"aarch64-linux-android",
"aarch64-unknown-linux-gnu",
"arm-unknown-linux-gnueabi",
"armv7-unknown-linux-gnueabi",
"armv7-linux-androideabi",
"i686-linux-android",
"i686-unknown-freebsd",
"powerpc-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"wasm32-unknown-unknown",
"wasm32-wasi",
"x86_64-apple-ios",
"x86_64-linux-android",
"x86_64-unknown-freebsd",
# "riscv32imc-unknown-none-elf", # disabled as @platforms doesn't have //cpu:riscv32 in the version embedded in Bazel 5.x
],
tags = ["manual"],
vendor_path = "crates",
)
41 changes: 41 additions & 0 deletions rust/3rdparty/crates/BUILD.android-tzdata-0.1.1.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
###############################################################################
# @generated
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
# regenerate this file, run the following:
#
# bazel run @//rust/3rdparty:crates_vendor
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])

# licenses([
# "TODO", # MIT OR Apache-2.0
# ])

rust_library(
name = "android_tzdata",
srcs = glob(["**/*.rs"]),
compile_data = glob(
include = ["**"],
exclude = [
"**/* *",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = ["--cap-lints=allow"],
tags = [
"cargo-bazel",
"crate-name=android-tzdata",
"manual",
"noclippy",
"norustfmt",
],
version = "0.1.1",
)
89 changes: 89 additions & 0 deletions rust/3rdparty/crates/BUILD.anyhow-1.0.71.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
###############################################################################
# @generated
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
# regenerate this file, run the following:
#
# bazel run @//rust/3rdparty:crates_vendor
###############################################################################

load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])

# licenses([
# "TODO", # MIT OR Apache-2.0
# ])

rust_library(
name = "anyhow",
srcs = glob(["**/*.rs"]),
compile_data = glob(
include = ["**"],
exclude = [
"**/* *",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
crate_features = [
"default",
"std",
],
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = ["--cap-lints=allow"],
tags = [
"cargo-bazel",
"crate-name=anyhow",
"manual",
"noclippy",
"norustfmt",
],
version = "1.0.71",
deps = [
"@rules_proto_grpc_rust__anyhow-1.0.71//:build_script_build",
],
)

cargo_build_script(
name = "anyhow_build_script",
srcs = glob(["**/*.rs"]),
crate_features = [
"default",
"std",
],
crate_name = "build_script_build",
crate_root = "build.rs",
data = glob(
include = ["**"],
exclude = [
"**/* *",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-bazel",
"crate-name=anyhow",
"manual",
"noclippy",
"norustfmt",
],
version = "1.0.71",
visibility = ["//visibility:private"],
)

alias(
name = "build_script_build",
actual = "anyhow_build_script",
tags = ["manual"],
)
Loading

0 comments on commit b02cfc3

Please sign in to comment.