Skip to content

Experiment with Bazel as a build system.#2240

Draft
SDAChess wants to merge 18 commits into
mainfrom
sscatton/test-bazel-as-build
Draft

Experiment with Bazel as a build system.#2240
SDAChess wants to merge 18 commits into
mainfrom
sscatton/test-bazel-as-build

Conversation

@SDAChess

Copy link
Copy Markdown
Collaborator

Summary

Related Issue

Changes

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@SDAChess SDAChess self-assigned this Jul 13, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@SDAChess

Copy link
Copy Markdown
Collaborator Author

/ok-to-test f3ac6c8

@SDAChess

Copy link
Copy Markdown
Collaborator Author

/ok-to-test 466d5ae

1 similar comment
@SDAChess

Copy link
Copy Markdown
Collaborator Author

/ok-to-test 466d5ae

@SDAChess SDAChess force-pushed the sscatton/test-bazel-as-build branch from 466d5ae to d9dbef3 Compare July 13, 2026 09:50
@SDAChess

Copy link
Copy Markdown
Collaborator Author

/ok-to-test d9dbef3

@SDAChess

SDAChess commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

/ok-to-test 59b2d9c

@SDAChess SDAChess force-pushed the sscatton/test-bazel-as-build branch 2 times, most recently from b24dfb6 to d358a8c Compare July 13, 2026 13:36
@SDAChess

Copy link
Copy Markdown
Collaborator Author

/ok-to-test d358a8c

SDAChess added 18 commits July 14, 2026 10:39
Nix supplies bazel itself (nix-built, so it runs on NixOS without a
loader shim); Bazel supplies all build toolchains. Replaces the old
mise toolchain layer and the previous rust/z3 dev shell.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
load_class_schema/load_object_schema read schema files at runtime from
a path baked in via env!("CARGO_MANIFEST_DIR"), which only resolves
inside a source checkout. Under Bazel the baked path points into the
deleted compile sandbox, and cargo-installed binaries have no checkout
at all. Embedding with include_str! makes the crate self-contained and
turns a missing or renamed schema file into a compile error.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
First real crate on the Bazel build. rust_test(crate = ...) compiles
the inline unit tests; schemas ride along as compile_data for
include_str!.

Also set -Clink-self-contained=no on the musl toolchains: rustc
otherwise injects its own bundled crt objects alongside the ones zig cc
provides, and the first musl binary link fails with duplicate
_start/_init/_fini. With the flag, zig owns the entire C runtime.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
openshell-vfio follows the ocsf template: rust_library plus a rust_test
for the inline unit tests.

openshell-server-macros is the first rust_proc_macro. Consumers build
it for the exec platform via proc_macro_deps, but wildcard builds under
a musl --platforms flag would also try a standalone musl variant, which
cannot link: a proc-macro is always a dylib and the zig musl toolchain
ships no shared unwinder (libgcc_s). Mark the target incompatible with
musl platforms so //... sweeps skip it.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
One job, three invocations sharing the bazel server and caches: host
tests, then both musl release platforms. setup-bazel is pinned by
commit sha (tags are mutable); .bazelversion pins the same bazel the
nix devshell provides.

Remove the legacy build, packaging, release, and license-header
workflows on this branch for now, so bazel checks are the only CI
exercising the code. Triage, docs, DCO, and vouch workflows stay.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
build.rs hardcoded ../../proto relative to the manifest and always
compiled protoc from source through protobuf-src. Both now come from
the environment: OPENSHELL_PROTO_DIR locates the proto tree (cargo
sets it in .cargo/config.toml), PROTOC/PROTOC_INCLUDE override the
compiler and its well-known-types include root. protobuf-src moves
behind the default-on vendored-protoc feature, so plain cargo builds
behave as before while other build systems can inject a prebuilt or
hermetically built protoc.

Also drop the git-describe version stamping: openshell_core::VERSION
now always reports CARGO_PKG_VERSION, and release stamping can be
reintroduced by the packaging pipeline where needed.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
First crate with a build script. cargo_build_script runs the tonic
codegen with protoc built from the protobuf module in the exec
configuration; PROTOC_INCLUDE points protoc at the protobuf source
tree for the google/protobuf well-known types, staged via the
well_known_type_protos filegroup.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
First crate depending on another workspace member: internal deps are
explicit labels, only external crates come from all_crate_deps. Core's
telemetry feature set matches what cargo's workspace-wide feature
unification produces, so the single core target serves all consumers.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
The provider YAML profiles are include_str!-embedded, so they ride
along as compile_data via a //providers filegroup.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Router brings the first cargo-style integration test: tests/ files
become their own rust_test crate linked against the library, unlike
the inline-test targets which recompile the crate with --test.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
/bin/sleep does not exist on every distro (NixOS ships only /bin/sh in
/bin), so the deleted-suffix tests failed on such hosts. Copy /bin/sh
instead and keep it alive with the read builtin blocking on a piped
stdin, which needs no external binaries at all.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Skills markdown and rego policies are include_str!-embedded and ride
along as compile_data; supervisor-network's inline tests additionally
embed testdata fixtures. Core grows the test-helpers feature to match
what cargo's workspace feature unification produces for dev builds.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
First rust_binary on the Bazel build, and the payoff target: under
--platforms=//:linux_amd64_musl it produces the fully static (no
INTERP, no NEEDED) supervisor that gets sideloaded into sandbox
images. The integration test receives CARGO_BIN_EXE_openshell-sandbox
as a runfiles-relative rootpath baked via rustc_env, with the binary
attached as data.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Registers the zig darwin cc toolchain, an aarch64-apple-darwin rust
toolchain, and a //:darwin_arm64 platform. Toolchain resolution works
and pure-Rust rlibs cross-compile from Linux; crates whose C
dependencies do not build for mach-o (aws-lc-sys) and anything linking
Apple frameworks still fail — real macOS artifacts stay on Apple
hardware for now.

Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Signed-off-by: Simon Scatton <sscatton@nvidia.com>
Signed-off-by: Simon Scatton <sscatton@nvidia.com>
@SDAChess SDAChess force-pushed the sscatton/test-bazel-as-build branch from d358a8c to 6a39474 Compare July 14, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant