-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support incompatible enable proto toolchain resolution (#2741)
This allows using a shared (generally pre-built) protoc definition, rather than needing to supply one via a label. We allow (but deprecate) users to still bring along their own protoc as a label, but if they want to do so, they will need to ensure they have the correct repositories registered in order to build/bring their protoc, rather than us setting them up by default.
- Loading branch information
1 parent
ca7a3df
commit ffe8eff
Showing
49 changed files
with
1,091 additions
and
49 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
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 |
---|---|---|
|
@@ -8,5 +8,5 @@ bazel_dep( | |
) | ||
bazel_dep( | ||
name = "bazel_features", | ||
version = "1.11.0", | ||
version = "1.14.0", | ||
) |
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
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
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,9 @@ | ||
# Required on windows | ||
common --enable_platform_specific_config | ||
startup --windows_enable_symlinks | ||
build:windows --enable_runfiles | ||
|
||
# Required for cargo_build_script support before Bazel 7 | ||
build --incompatible_merge_fixed_and_default_shell_env | ||
|
||
common --incompatible_enable_proto_toolchain_resolution |
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 @@ | ||
../.bazelversion |
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,5 @@ | ||
/bazel-* | ||
.DS_Store | ||
/proto/.DS_Store | ||
/proto/grpc_server/.DS_Store | ||
/proto/proto_bindings/.DS_Store |
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,6 @@ | ||
config_setting( | ||
name = "release", | ||
values = { | ||
"compilation_mode": "opt", | ||
}, | ||
) |
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,42 @@ | ||
[workspace] | ||
resolver = "2" | ||
|
||
members = [ | ||
"proto_bindings", | ||
"grpc_server", | ||
"grpc_client", | ||
] | ||
|
||
|
||
[workspace.package] | ||
edition = "2021" | ||
rust-version = "1.78.0" | ||
readme = "README.md" | ||
|
||
|
||
[workspace.dependencies] | ||
# Internal crates | ||
proto_bindings = { path = "proto_bindings" } | ||
# External crates | ||
prost = { version = "0.12.6" } | ||
prost-types = { version = "0.12.6", default-features = false } | ||
tonic = { version = "0.11.0", features = ["transport"] } | ||
tonic-build = "0.11.0" | ||
tokio = { version = "1.38", default-features = false, features = ["macros", "net", "rt-multi-thread", "signal"] } | ||
|
||
|
||
# Optimize all crates | ||
[profile.release] | ||
opt-level = 3 | ||
strip = true # Automatically strip debug symbols from the binary | ||
lto = true # Enable Link Time Optimization (LTO) | ||
codegen-units = 1 # Reduce Parallel Code Generation Units to Increase Optimization | ||
|
||
|
||
# There's a Cargo feature named profile-overrides | ||
# that lets you override the optimization level of dependencies. | ||
# https://docs.rust-embedded.org/book/unsorted/speed-vs-size.html | ||
[profile.release.package."*"] | ||
opt-level = 3 | ||
strip = 'debuginfo' # Automatically strip debug infos from the binary to reduce size | ||
codegen-units = 1 # Reduce Parallel Code Generation Units to Increase Optimization |
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,133 @@ | ||
module( | ||
name = "grpc-client-server", | ||
version = "0.0.0", | ||
) | ||
|
||
############################################################################### | ||
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/ | ||
############################################################################### | ||
# https://github.com/bazelbuild/rules_rust/releases | ||
bazel_dep(name = "rules_rust", version = "0.46.0") | ||
local_path_override( | ||
module_name = "rules_rust", | ||
path = "../../..", | ||
) | ||
|
||
# | ||
# Rules for protobuf / gRPC | ||
# https://github.com/bazelbuild/rules_proto/releases | ||
bazel_dep(name = "rules_proto", version = "6.0.2") | ||
|
||
# https://github.com/aspect-build/toolchains_protoc/releases | ||
bazel_dep(name = "toolchains_protoc", version = "0.3.1") | ||
|
||
# https://registry.bazel.build/modules/protobuf | ||
bazel_dep(name = "protobuf", version = "27.1") | ||
|
||
# https://github.com/bazel-contrib/toolchains_llvm | ||
bazel_dep(name = "toolchains_llvm", version = "1.0.0") | ||
|
||
############################################################################### | ||
# L L V M | ||
# https://github.com/bazel-contrib/toolchains_llvm/blob/master/tests/MODULE.bazel | ||
############################################################################### | ||
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") | ||
|
||
# LLVM Versions and platforms | ||
# https://github.com/bazel-contrib/toolchains_llvm/blob/master/toolchain/internal/llvm_distributions.bzl | ||
LLVM_VERSIONS = { | ||
"": "16.0.0", | ||
"darwin-aarch64": "16.0.3", | ||
"darwin-x86_64": "15.0.7", | ||
} | ||
|
||
# Host LLVM toolchain. | ||
llvm.toolchain( | ||
name = "llvm_toolchain", | ||
llvm_versions = LLVM_VERSIONS, | ||
) | ||
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm") | ||
|
||
register_toolchains("@llvm_toolchain//:all") | ||
|
||
############################################################################### | ||
# T O O L C H A I N S | ||
############################################################################### | ||
|
||
# Rust toolchain | ||
RUST_EDITION = "2021" | ||
|
||
RUST_VERSION = "1.79.0" | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain( | ||
edition = RUST_EDITION, | ||
versions = [RUST_VERSION], | ||
) | ||
use_repo(rust, "rust_toolchains") | ||
|
||
register_toolchains("@rust_toolchains//:all") | ||
|
||
# Proto toolchain | ||
register_toolchains("@rules_rust//proto/protobuf:default-proto-toolchain") | ||
|
||
# Custom Prost toolchain | ||
register_toolchains("@//build/prost_toolchain") | ||
|
||
############################################################################### | ||
# R U S T C R A T E S | ||
############################################################################### | ||
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") | ||
|
||
# | ||
# protobuf / gRPC dependencies | ||
crate.spec( | ||
package = "prost", | ||
version = "0.12", | ||
) | ||
crate.spec( | ||
default_features = False, | ||
package = "prost-types", | ||
version = "0.12", | ||
) | ||
crate.spec( | ||
features = ["transport"], | ||
package = "tonic", | ||
version = "0.11", | ||
) | ||
crate.spec( | ||
package = "tonic-build", | ||
version = "0.11", | ||
) | ||
crate.spec( | ||
package = "protoc-gen-prost", | ||
version = "0.3.1", | ||
) | ||
crate.annotation( | ||
crate = "protoc-gen-prost", | ||
gen_binaries = ["protoc-gen-prost"], | ||
) | ||
crate.spec( | ||
package = "protoc-gen-tonic", | ||
version = "0.4.0", | ||
) | ||
crate.annotation( | ||
crate = "protoc-gen-tonic", | ||
gen_binaries = ["protoc-gen-tonic"], | ||
) | ||
|
||
# | ||
# External crates | ||
crate.spec( | ||
default_features = False, | ||
features = [ | ||
"macros", | ||
"net", | ||
"rt-multi-thread", | ||
"signal", | ||
], | ||
package = "tokio", | ||
version = "1.38", | ||
) | ||
crate.from_specs() | ||
use_repo(crate, "crates") |
Oops, something went wrong.