Skip to content

Commit d959896

Browse files
committed
build(bazel): add openshell-sandbox supervisor binary
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>
1 parent 5c3d54e commit d959896

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
load("@crates//:defs.bzl", "all_crate_deps")
5+
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
6+
7+
WORKSPACE_DEPS = [
8+
"//crates/openshell-core:openshell_core",
9+
"//crates/openshell-ocsf:openshell_ocsf",
10+
"//crates/openshell-policy:openshell_policy",
11+
"//crates/openshell-supervisor-network:openshell_supervisor_network",
12+
"//crates/openshell-supervisor-process:openshell_supervisor_process",
13+
]
14+
15+
rust_library(
16+
name = "openshell_sandbox",
17+
srcs = glob(
18+
["src/**/*.rs"],
19+
exclude = ["src/main.rs"],
20+
),
21+
edition = "2024",
22+
visibility = ["//visibility:public"],
23+
deps = all_crate_deps(normal = True) + WORKSPACE_DEPS,
24+
proc_macro_deps = all_crate_deps(proc_macro = True),
25+
)
26+
27+
# The container supervisor binary, sideloaded into sandbox images.
28+
rust_binary(
29+
name = "openshell-sandbox",
30+
srcs = ["src/main.rs"],
31+
edition = "2024",
32+
visibility = ["//visibility:public"],
33+
deps = all_crate_deps(normal = True) + WORKSPACE_DEPS + [
34+
":openshell_sandbox",
35+
],
36+
proc_macro_deps = all_crate_deps(proc_macro = True),
37+
)
38+
39+
rust_test(
40+
name = "openshell_sandbox_test",
41+
crate = ":openshell_sandbox",
42+
deps = all_crate_deps(normal_dev = True),
43+
)
44+
45+
# Cargo-style integration test; CARGO_BIN_EXE_* is baked at compile time as a
46+
# runfiles-relative rootpath and resolved from the test's working directory.
47+
rust_test(
48+
name = "stdout_logging_test",
49+
srcs = ["tests/stdout_logging.rs"],
50+
data = [":openshell-sandbox"],
51+
edition = "2024",
52+
rustc_env = {
53+
"CARGO_BIN_EXE_openshell-sandbox": "$(rootpath :openshell-sandbox)",
54+
},
55+
deps = all_crate_deps(
56+
normal = True,
57+
normal_dev = True,
58+
) + WORKSPACE_DEPS + [
59+
":openshell_sandbox",
60+
],
61+
)

0 commit comments

Comments
 (0)