-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9442aed
commit 6cb92b2
Showing
157 changed files
with
17,080 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Rust proto rules.""" | ||
|
||
load( | ||
"//proto/prost:defs.bzl", | ||
_rust_prost_library = "rust_prost_library", | ||
_rust_tonic_library = "rust_tonic_library", | ||
) | ||
load( | ||
":proto.bzl", | ||
_rust_grpc_library = "rust_grpc_library", | ||
_rust_proto_library = "rust_proto_library", | ||
) | ||
|
||
rust_proto_library = _rust_proto_library | ||
rust_grpc_library = _rust_grpc_library | ||
|
||
rust_prost_library = _rust_prost_library | ||
rust_tonic_library = _rust_tonic_library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("//rust:defs.bzl", "rust_library_group") | ||
load(":defs.bzl", "rust_prost_toolchain") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
toolchain_type( | ||
name = "toolchain_type", | ||
) | ||
|
||
rust_library_group( | ||
name = "prost_runtime", | ||
deps = [ | ||
"//proto/prost/private/3rdparty/crates:prost", | ||
], | ||
) | ||
|
||
rust_library_group( | ||
name = "tonic_runtime", | ||
deps = [ | ||
":prost_runtime", | ||
"//proto/prost/private/3rdparty/crates:tonic", | ||
], | ||
) | ||
|
||
rust_prost_toolchain( | ||
name = "default_prost_toolchain_impl", | ||
prost_plugin = "//proto/prost/private/3rdparty/crates:protoc-gen-prost__protoc-gen-prost", | ||
prost_plugin_flag = "--plugin=protoc-gen-prost=%s", | ||
prost_runtime = ":prost_runtime", | ||
proto_compiler = "@com_google_protobuf//:protoc", | ||
tonic_plugin = "//proto/prost/private/3rdparty/crates:protoc-gen-tonic__protoc-gen-tonic", | ||
tonic_plugin_flag = "--plugin=protoc-gen-tonic=%s", | ||
tonic_runtime = ":tonic_runtime", | ||
) | ||
|
||
toolchain( | ||
name = "default_prost_toolchain", | ||
toolchain = "default_prost_toolchain_impl", | ||
toolchain_type = "//proto/prost:toolchain_type", | ||
) | ||
|
||
bzl_library( | ||
name = "bzl_lib", | ||
srcs = glob(["**/*.bzl"]), | ||
deps = [ | ||
"//proto/prost/private:bzl_lib", | ||
"//rust:bzl_lib", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Rules for building proto libraries in Rust.""" | ||
|
||
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): | ||
"""A rule for generating a Rust library using Prost. | ||
Args: | ||
name (str): The name of the target. | ||
**kwargs (dict): Additional keyword arguments for the underlying | ||
`rust_prost_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_prost_library( | ||
name = name, | ||
tags = tags, | ||
**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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("//crate_universe:defs.bzl", "crate", "crates_vendor") | ||
|
||
crates_vendor( | ||
name = "crates_vendor", | ||
annotations = { | ||
"protoc-gen-prost": [crate.annotation( | ||
gen_binaries = ["protoc-gen-prost"], | ||
)], | ||
"protoc-gen-tonic": [crate.annotation( | ||
gen_binaries = ["protoc-gen-tonic"], | ||
)], | ||
}, | ||
cargo_lockfile = "Cargo.Bazel.lock", | ||
mode = "remote", | ||
packages = { | ||
"h2": crate.spec( | ||
version = "0.3.19", | ||
), | ||
"prost": crate.spec( | ||
version = "0.11.9", | ||
), | ||
"prost-types": crate.spec( | ||
version = "0.11.9", | ||
), | ||
"protoc-gen-prost": crate.spec( | ||
version = "0.2.2", | ||
), | ||
"protoc-gen-tonic": crate.spec( | ||
version = "0.2.2", | ||
), | ||
"tokio": crate.spec( | ||
features = ["full"], | ||
version = "1.28.2", | ||
), | ||
"tokio-stream": crate.spec( | ||
version = "0.1.14", | ||
), | ||
"tonic": crate.spec( | ||
version = "0.9.2", | ||
), | ||
}, | ||
repository_name = "rules_rust_prost", | ||
tags = ["manual"], | ||
) | ||
|
||
bzl_library( | ||
name = "bzl_lib", | ||
srcs = [ | ||
"//proto/prost/private/3rdparty/crates:crates.bzl", | ||
"//proto/prost/private/3rdparty/crates:defs.bzl", | ||
], | ||
visibility = ["//proto/prost/private:__pkg__"], | ||
) |
Oops, something went wrong.