Skip to content

Commit b775d95

Browse files
committed
build(bazel): establish RFC 0012 Rust reference graph
Establish the Phase 1 reference implementation proposed by RFC 0012 while retaining the existing Cargo and Mise workflows during evaluation. - pin Bazel 9.1.1 and configure Bzlmod, rules_rs, LLVM, protobuf, and Rust 1.95 toolchains - import third-party crates from Cargo metadata and propagate the workspace version into Bazel targets - add library, binary, proc-macro, unit-test, and integration-test targets across the supported Rust workspace crates and drivers - generate protobuf Rust sources and descriptor sets under Bazel while preserving Cargo-compatible generated-code imports - annotate aws-lc-sys and zstd-sys native dependencies, build Z3 4.15.2 from source, and generate z3-sys bindings - make CLI and procfs test fixtures available as explicit Bazel inputs without relying on fixed host binary paths - define optimized release targets for Linux x86_64 and aarch64 CLI, sandbox, and gateway binaries, plus macOS aarch64 artifacts - add Bazel, buildifier, and lcov to the Nix development environment RFC: 0012 (rfc12 branch) Refs: #2491 Signed-off-by: Simon Scatton <[email protected]>
1 parent 5541398 commit b775d95

50 files changed

Lines changed: 2879 additions & 141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.bazelrc‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build --@rules_rs//rs/private/prost:compile_well_known_types=false
2+
test --test_env=PATH
3+
4+
build:release --compilation_mode=opt
5+
build:release --@rules_rust//rust/settings:codegen_units=1
6+
build:release --@rules_rust//rust/settings:extra_rustc_flag=-Cstrip=symbols

‎.bazelversion‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9.1.1

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,6 @@ scripts/lint-mermaid/node_modules/
230230
# Nix
231231
/result
232232
/result-*
233+
234+
# Bazel
235+
bazel-*

‎BUILD.bazel‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(["deploy/rpm/gateway.toml.default"])

‎MODULE.bazel‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
bazel_dep(name = "rules_rs", version = "0.0.96")
2+
bazel_dep(name = "bazel_lib", version = "3.2.2")
3+
bazel_dep(name = "llvm", version = "0.8.11")
4+
bazel_dep(name = "platforms", version = "1.1.0")
5+
bazel_dep(name = "rules_cc", version = "0.2.20")
6+
bazel_dep(name = "rules_proto", version = "7.1.0")
7+
bazel_dep(name = "protobuf", version = "34.0.bcr.1")
8+
9+
include("//bazel/annotations:aws-lc-sys.MODULE.bazel")
10+
include("//bazel/annotations:z3-sys.MODULE.bazel")
11+
include("//bazel/annotations:zstd-sys.MODULE.bazel")
12+
13+
z3_repository = use_repo_rule("//third_party/z3:repositories.bzl", "z3_repository")
14+
15+
z3_repository(
16+
name = "z3",
17+
build_file = "//third_party/z3:BUILD.z3.bazel",
18+
integrity = "sha256-YGAaZ0II/2EDgM8NVhIayGeMRcXE6sOtFNv+kZmOzIo=",
19+
strip_prefix = "z3-z3-4.15.2",
20+
urls = ["https://github.com/Z3Prover/z3/archive/refs/tags/z3-4.15.2.zip"],
21+
)
22+
23+
osx = use_extension("@llvm//extensions:osx.bzl", "osx")
24+
osx.frameworks(
25+
names = [
26+
"CFNetwork",
27+
"CoreFoundation",
28+
"CoreServices",
29+
"DiskArbitration",
30+
"Foundation",
31+
"IOKit",
32+
"Kernel",
33+
"OSLog",
34+
"Security",
35+
"SystemConfiguration",
36+
],
37+
)
38+
39+
workspace_version_repository = use_repo_rule("//bazel:cargo_version.bzl", "workspace_version_repository")
40+
41+
workspace_version_repository(
42+
name = "workspace_version",
43+
manifest = "//:Cargo.toml",
44+
)
45+
46+
toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains")
47+
toolchains.toolchain(
48+
edition = "2024",
49+
version = "1.95.0",
50+
)
51+
use_repo(toolchains, "default_rust_toolchains")
52+
53+
rules_rust = use_extension("@rules_rs//rs:rules_rust.bzl", "rules_rust")
54+
use_repo(rules_rust, "rules_rust")
55+
56+
register_toolchains(
57+
"@default_rust_toolchains//:all",
58+
"@llvm//toolchain:all",
59+
"@rules_rust//extensions/prost:default_prost_toolchain",
60+
)
61+
62+
crate = use_extension("@rules_rs//rs:extensions.bzl", "crate")
63+
crate.from_cargo(
64+
name = "crates",
65+
cargo_lock = "//:Cargo.lock",
66+
cargo_toml = "//:Cargo.toml",
67+
platform_triples = [
68+
"aarch64-apple-darwin",
69+
"aarch64-unknown-linux-gnu",
70+
"aarch64-unknown-linux-musl",
71+
"x86_64-unknown-linux-gnu",
72+
"x86_64-unknown-linux-musl",
73+
],
74+
)
75+
use_repo(crate, "crates")

‎MODULE.bazel.lock‎

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

‎bazel/BUILD.bazel‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(["cargo_version.bzl"])

‎bazel/annotations/BUILD.bazel‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exports_files([
2+
"aws-lc-sys.MODULE.bazel",
3+
"z3-sys.MODULE.bazel",
4+
"zstd-sys.MODULE.bazel",
5+
])
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
bazel_dep(name = "aws-lc", version = "5.1.0")
2+
3+
rules_rust_bindgen = use_extension("@rules_rs//rs:rules_rust_bindgen.bzl", "rules_rust_bindgen")
4+
use_repo(rules_rust_bindgen, "rules_rust_bindgen")
5+
6+
register_toolchains("@rules_rust_bindgen//:all")
7+
8+
crate = use_extension("@rules_rs//rs:extensions.bzl", "crate")
9+
crate.annotation(
10+
crate = "aws-lc-rs",
11+
gen_build_script = "off",
12+
)
13+
crate.annotation(
14+
additive_build_file = "@rules_rs//3rd_party/aws-lc-sys:additive.BUILD.bazel",
15+
crate = "aws-lc-sys",
16+
extra_aliased_targets = {"aws_lc_sys_build_info": "aws_lc_sys_build_info"},
17+
gen_build_script = "off",
18+
rustc_flags = ["--cfg=use_bindgen_pregenerated"],
19+
deps = ["@crates//:aws_lc_sys_build_info"],
20+
)
21+
22+
inject_repo(crate, "aws-lc")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
crate = use_extension("@rules_rs//rs:extensions.bzl", "crate")
2+
crate.annotation(
3+
additive_build_file = "//bazel/annotations/z3-sys:additive.BUILD.bazel",
4+
crate = "z3-sys",
5+
extra_aliased_targets = {"z3_sys_build_info": "z3_sys_build_info"},
6+
gen_build_script = "off",
7+
deps = ["@crates//:z3_sys_build_info"],
8+
)
9+
10+
inject_repo(crate, "z3")

0 commit comments

Comments
 (0)