-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUILD.bazel
More file actions
110 lines (99 loc) · 3.51 KB
/
Copy pathBUILD.bazel
File metadata and controls
110 lines (99 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
load("@crates//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_clippy", "rust_library", "rust_test", "rustfmt_test")
load("//tools/bazel:cargo_deny.bzl", "cargo_deny_test")
load("//tools/bazel:llvm_cov.bzl", "llvm_cov_test")
package(default_visibility = ["//visibility:public"])
exports_files([
"Cargo.toml",
"Cargo.lock",
])
# TODO(Phase 6): TypeShare code generation: Rust → TypeScript types.
# Requires typeshare-cli binary — not yet available via crate_universe.
# For now, run `cargo install typeshare-cli && typeshare . --lang=typescript`
# manually or via Dagger. See build.rs for the Cargo-based approach.
# Library crate — contains all modules (agents, api, auth, backends, etc.)
# main.rs imports from this via `use clauderon::*`.
rust_library(
name = "clauderon_lib",
srcs = glob(
["src/**/*.rs"],
exclude = ["src/main.rs"],
),
# include_dir! and include_str! need these files/dirs at compile time.
# The .gitkeep files ensure dist/ directories exist in the source tree
# (force-added to git despite .gitignore). For production, these dirs
# contain actual build outputs; for compilation they just need to exist.
compile_data = [
"//packages/clauderon/docs:dist_gitkeep",
"//packages/clauderon/docs:docker-config.toml.example",
"//packages/clauderon/web/frontend:dist_gitkeep",
],
crate_name = "clauderon",
proc_macro_deps = all_crate_deps(proc_macro = True),
# CARGO_MANIFEST_DIR points to the source tree location.
# include_dir! resolves $CARGO_MANIFEST_DIR/web/frontend/dist etc.
rustc_env = {
"CARGO_MANIFEST_DIR": "packages/clauderon",
},
deps = all_crate_deps(normal = True),
)
# Binary crate — just the CLI entry point.
rust_binary(
name = "clauderon",
srcs = ["src/main.rs"],
proc_macro_deps = all_crate_deps(proc_macro = True),
deps = [
":clauderon_lib",
] + all_crate_deps(normal = True),
)
# 1 of 352 tests (test_image_path_translation) fails in sandbox because
# HOME=/tmp causes host path to equal container path, breaking assertion.
rust_test(
name = "clauderon_test",
crate = ":clauderon_lib",
env = {"HOME": "/Users/testuser"},
proc_macro_deps = all_crate_deps(proc_macro_dev = True),
tags = ["test"],
deps = all_crate_deps(normal_dev = True),
)
rust_clippy(
name = "clippy",
tags = ["lint"],
deps = [":clauderon_lib"],
)
rustfmt_test(
name = "rustfmt",
tags = ["lint"],
targets = [":clauderon_lib"],
)
# Hermetic cargo-deny via @multitool + @rules_rust cargo.
cargo_deny_test(
name = "cargo_deny",
srcs = [
"Cargo.lock",
"Cargo.toml",
"deny.toml",
],
local = True,
tags = [
"lint",
"requires-network",
],
)
# Code coverage via cargo-llvm-cov. Manual: requires Rust toolchain.
# Run explicitly: bazel test //packages/clauderon:llvm_cov
llvm_cov_test(
name = "llvm_cov",
srcs = glob(["src/**/*.rs"]) + [
"Cargo.lock",
"Cargo.toml",
],
)
# TODO: OCI image for clauderon.
# Requires: Rust binary (:clauderon) + web/frontend dist + docs dist.
# The Dagger pipeline builds frontend/docs first, embeds them via include_dir!,
# then compiles the Rust binary. Replicating this in Bazel needs:
# 1. Build web/frontend with Vite (not yet in Bazel)
# 2. Build docs with Astro (not yet in Bazel)
# 3. Package the compiled Rust binary into a distroless/static image
# For now, the Dagger-based image build remains the primary path.