Skip to content

Commit e4f0ff7

Browse files
author
Aalyria Technologies, Inc
committed
Import changes.
- e3247e3598500e2bb570f83e4cc0d36271a159d2 GitOrigin-RevId: e3247e3598500e2bb570f83e4cc0d36271a159d2
1 parent 521680d commit e4f0ff7

10 files changed

Lines changed: 979 additions & 64 deletions

File tree

‎Cargo.lock‎

Lines changed: 889 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This is a dummy package that declares the external Rust dependencies for
2+
# rules_rs crate_universe (from_cargo). It is not built directly; the actual
3+
# Rust targets are Bazel rules. Consumed as @st_crates.
4+
[package]
5+
name = "aalyria-api-bazel-deps"
6+
version = "0.0.1"
7+
edition = "2024"
8+
9+
# Stub target: rules_rs from_cargo runs `cargo` against this manifest, which
10+
# requires a target. lib.rs is an empty placeholder; nothing is built from it.
11+
[lib]
12+
path = "lib.rs"
13+
14+
[dependencies]
15+
prost = { version = "0.14.3" }
16+
prost-types = { version = "0.14.3", default-features = false }
17+
protoc-gen-prost = { version = "0.5.0" }
18+
protoc-gen-tonic = { version = "0.5.0" }
19+
tonic = { version = "0.14.4", features = ["transport"] }
20+
tonic-build = { version = "0.14.4" }
21+
tonic-prost = { version = "0.14.4" }

‎MODULE.bazel‎

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ bazel_dep(name = "rules_proto_grpc_doc", version = "5.6.0")
3333
bazel_dep(name = "rules_proto_grpc_java", version = "5.6.0")
3434
bazel_dep(name = "rules_proto_grpc_python", version = "5.6.0")
3535
bazel_dep(name = "rules_python", version = "1.6.3")
36-
bazel_dep(name = "rules_rust", version = "0.69.0")
37-
bazel_dep(name = "rules_rust_prost", version = "0.69.0")
36+
bazel_dep(name = "rules_rs", version = "0.0.94")
3837
bazel_dep(name = "rules_shell", version = "0.6.1")
3938
bazel_dep(name = "aspect_rules_py", version = "1.8.4")
4039
bazel_dep(name = "toolchains_protoc", version = "0.4.3")
@@ -63,10 +62,12 @@ single_version_override(
6362
version = "1.19.1",
6463
)
6564

66-
# Patch gRPC v1.74.1 to fix RBE build with strict header checking.
67-
# The issue: xds_route_config target is missing upb library dependencies,
68-
# which causes undeclared inclusion errors for envoy upb-generated headers
69-
# when building with RBE's strict header checking.
65+
# grpc is pulled in transitively by rules_proto_grpc_*. Pin and patch it to match
66+
# the monorepo. The upb-gen include-shadowing patch drops grpc's committed
67+
# upb-gen include dirs, which otherwise shadow protobuf's generated upb headers
68+
# and cause "undeclared inclusion" failures under strict header checking (e.g.
69+
# when compiling cygrpc). The rbe_xds patch supplies header deps needed for
70+
# RBE + xDS builds.
7071
single_version_override(
7172
module_name = "grpc",
7273
patch_strip = 0,
@@ -214,57 +215,40 @@ RUST_EDITION = "2024"
214215

215216
RUST_VERSION = "1.94.1"
216217

217-
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
218-
rust.toolchain(
218+
# rules_rs provides hermetic Rust toolchains and the patched rules_rust facade.
219+
rs_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains")
220+
rs_toolchains.toolchain(
219221
edition = RUST_EDITION,
220-
extra_exec_rustc_flags = ["-Clink-self-contained=no"],
221-
extra_rustc_flags = ["-Clink-self-contained=no"],
222-
versions = [RUST_VERSION],
222+
# -Clink-self-contained=no: link with the registered cc toolchain's linker.
223+
# rules_rs's rustc does not ship the self-contained linker (rust-lld) in its
224+
# sysroot, so self-contained linking (the default) fails for tool/bin targets.
225+
extra_exec_rustc_flags = {
226+
"x86_64-unknown-linux-gnu": ["-Clink-self-contained=no"],
227+
},
228+
extra_rustc_flags = {
229+
"x86_64-unknown-linux-gnu": ["-Clink-self-contained=no"],
230+
},
231+
version = RUST_VERSION,
223232
)
224-
use_repo(rust, "rust_toolchains")
233+
use_repo(rs_toolchains, "default_rust_toolchains")
225234

226-
register_toolchains("@rust_toolchains//:all")
235+
# Re-export the pinned, patched @rules_rust so existing @rules_rust// loads keep
236+
# working. rules_rs bundles the prost extension under @rules_rust//extensions/prost.
237+
rules_rust = use_extension("@rules_rs//rs:rules_rust.bzl", "rules_rust")
238+
use_repo(rules_rust, "rules_rust")
239+
240+
register_toolchains("@default_rust_toolchains//:all")
227241

228242
register_toolchains(
229243
"//api/build_tools/prost_toolchain",
230244
)
231245

232-
# All of these crates come from crates.io, hence the "crates_io" name.
233-
# The "st_" (spacetime) prefix is required to avoid a collision with the
234-
# nmts submodule, which defines its own "crates_io" (and "crates") repo:
235-
# rules_rust's crate extension is shared across the whole module graph,
236-
# so two modules generating a repo of the same name would error.
237-
crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
238-
crate.spec(
239-
package = "prost",
240-
version = "0.14.3",
241-
)
242-
crate.spec(
243-
default_features = False,
244-
package = "prost-types",
245-
version = "0.14.3",
246-
)
247-
crate.spec(
248-
package = "protoc-gen-prost",
249-
version = "0.5.0",
250-
)
251-
crate.spec(
252-
package = "protoc-gen-tonic",
253-
version = "0.5.0",
254-
)
255-
crate.spec(
256-
features = ["transport"],
257-
package = "tonic",
258-
version = "0.14.4",
259-
)
260-
crate.spec(
261-
package = "tonic-build",
262-
version = "0.14.4",
263-
)
264-
crate.spec(
265-
package = "tonic-prost",
266-
version = "0.14.4",
267-
)
246+
# Rust crate dependencies via rules_rs crate_universe (from_cargo). The
247+
# dependency set lives in Cargo.toml / Cargo.lock (rules_rs supports only
248+
# from_cargo). The "st_" (spacetime) prefix keeps this hub distinct from the
249+
# nmts submodule's crate hub: the crate extension is shared across the module
250+
# graph, so two hubs of the same name would collide.
251+
crate = use_extension("@rules_rs//rs:extensions.bzl", "crate")
268252
crate.annotation(
269253
crate = "protoc-gen-prost",
270254
gen_binaries = ["protoc-gen-prost"],
@@ -273,10 +257,13 @@ crate.annotation(
273257
crate = "protoc-gen-tonic",
274258
gen_binaries = ["protoc-gen-tonic"],
275259
)
276-
crate.from_specs(
277-
name = "st_crates_io",
260+
crate.from_cargo(
261+
name = "st_crates",
262+
cargo_lock = "//:Cargo.lock",
263+
cargo_toml = "//:Cargo.toml",
264+
platform_triples = ["x86_64-unknown-linux-gnu"],
278265
)
279-
use_repo(crate, "st_crates_io")
266+
use_repo(crate, "st_crates")
280267

281268
bazel_dep(name = "org_outernetcouncil_nmts")
282269
archive_override(

‎api/build_tools/prost_toolchain/BUILD‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@rules_rust//extensions/prost:defs.bzl", "rust_prost_toolchain")
1516
load("@rules_rust//rust:defs.bzl", "rust_library_group")
16-
load("@rules_rust_prost//:defs.bzl", "rust_prost_toolchain")
1717

1818
rust_library_group(
1919
name = "prost_runtime",
2020
deps = [
21-
"@st_crates_io//:prost",
21+
"@st_crates//:prost",
2222
],
2323
)
2424

2525
rust_library_group(
2626
name = "tonic_runtime",
2727
deps = [
2828
":prost_runtime",
29-
"@st_crates_io//:tonic",
30-
"@st_crates_io//:tonic-prost",
29+
"@st_crates//:tonic",
30+
"@st_crates//:tonic-prost",
3131
],
3232
)
3333

3434
rust_prost_toolchain(
3535
name = "prost_toolchain_impl",
3636
compile_well_known_types = False,
37-
prost_plugin = "@st_crates_io//:protoc-gen-prost__protoc-gen-prost",
37+
prost_plugin = "@st_crates//:protoc-gen-prost__protoc-gen-prost",
3838
prost_runtime = ":prost_runtime",
39-
prost_types = "@st_crates_io//:prost-types",
40-
tonic_plugin = "@st_crates_io//:protoc-gen-tonic__protoc-gen-tonic",
39+
prost_types = "@st_crates//:prost-types",
40+
tonic_plugin = "@st_crates//:protoc-gen-tonic__protoc-gen-tonic",
4141
tonic_runtime = ":tonic_runtime",
4242
)
4343

4444
toolchain(
4545
name = "prost_toolchain",
4646
toolchain = "prost_toolchain_impl",
47-
toolchain_type = "@rules_rust_prost//:toolchain_type",
47+
toolchain_type = "@rules_rust//extensions/prost:toolchain_type",
4848
)

‎api/common/BUILD‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load("@rules_go//proto:def.bzl", "go_proto_library")
1717
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_proto_library")
1818
load("@rules_proto_grpc_java//:defs.bzl", "java_proto_library")
1919
load("@rules_proto_grpc_python//:defs.bzl", "python_proto_library")
20-
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
20+
load("@rules_rust//extensions/prost:defs.bzl", "rust_prost_library")
2121

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

‎api/nbi/v1alpha/resources/BUILD‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load("@rules_go//proto:def.bzl", "go_proto_library")
1717
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_grpc_library")
1818
load("@rules_proto_grpc_java//:defs.bzl", "java_grpc_library")
1919
load("@rules_proto_grpc_python//:defs.bzl", "python_grpc_library")
20-
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
20+
load("@rules_rust//extensions/prost:defs.bzl", "rust_prost_library")
2121

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

‎api/provisioning/v1alpha/BUILD‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load("@rules_go//proto:def.bzl", "go_proto_library")
1717
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_grpc_library")
1818
load("@rules_proto_grpc_java//:defs.bzl", "java_grpc_library")
1919
load("@rules_proto_grpc_python//:defs.bzl", "python_grpc_library")
20-
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
20+
load("@rules_rust//extensions/prost:defs.bzl", "rust_prost_library")
2121

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

‎api/solution/v1alpha/BUILD‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load("@rules_go//proto:def.bzl", "go_proto_library")
1717
load("@rules_proto_grpc_cpp//:defs.bzl", "cpp_grpc_library")
1818
load("@rules_proto_grpc_java//:defs.bzl", "java_grpc_library")
1919
load("@rules_proto_grpc_python//:defs.bzl", "python_grpc_library")
20-
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
20+
load("@rules_rust//extensions/prost:defs.bzl", "rust_prost_library")
2121

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

‎common.bazelrc‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ build --host_cxxopt=-Wno-deprecated-declarations
5252
##
5353
build --features=external_include_paths
5454

55+
# The hermetic clang toolchain enforces module-map strictness that the previous
56+
# toolchain did not. grpc includes zlib's module-private zconf.h/zlib.h, which
57+
# clang flags under -Wprivate-header.
58+
build --per_file_copt=external/grpc[~+]/.*@-Wno-private-header
59+
60+
# opencensus-cpp (a grpc dependency) has an unused local variable
61+
# (cloud_trace_context.cc) that clang flags under -Wunused-variable. It is
62+
# third-party code.
63+
build --per_file_copt=external/opencensus-cpp[~+]/.*@-Wno-unused-variable
64+
65+
# The hermetic clang toolchain enables Bazel's layering_check feature (module
66+
# strict-decluse), which neither this tree nor external deps like grpc declare
67+
# the layering dependencies for, so compiles fail with "module ... does not
68+
# depend on a module exporting ...". Disable it repo-wide. This is a feature,
69+
# not a -W flag, so it cannot be scoped per external repo via per_file_copt.
70+
build --features=-layering_check
71+
5572
##
5673
# Enable hermetic testing and compilation of Java using a JVM downloaded from a
5774
# remote repository.

‎lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty stub for the rules_rs from_cargo dummy package (see Cargo.toml).

0 commit comments

Comments
 (0)