BUCKannotatedBUCKsource84 lines · 3.1 KB · raw
1_DEPS = [
2    "//packages/alttp:alttp",
3    "//packages/console:console",
4    "//packages/mcp:mcp",
5    "//third-party/rust:jev-http",
6    "//packages/zbanks:zbanks",
7    "//packages/decisions:decisions",
8    "//packages/panels:panels",
9    "//packages/replay:replay",
10    "//third-party/rust:cpal",
11    "//third-party/rust:eframe",
12    "//third-party/rust:file-rotate",
13    "//third-party/rust:libc",
14    "//third-party/rust:ringbuf",
15    "//third-party/rust:serde_json",
16    "//third-party/rust:subsecond",
17    "//third-party/rust:subsecond-types",
18    "//third-party/rust:tokio",
19]
20
21rust_library(
22    name = "app",
23    srcs = ["src/app.rs", "src/activity.rs"],
24    crate_root = "src/app.rs",
25    edition = "2024",
26    # Hot-patch flags (research/subsecond-patch-build.md §1/§5/§7/§8):
27    # save-temps keeps the per-codegen-unit .rcgu.o objects a patch build
28    # relinks from; link-dead-code stops the linker from dropping symbols a
29    # future patch might jump to; debug-assertions=yes is what makes the
30    # `debug_assert_eq!` patch-point guards (and `subsecond::call` in ITS OWN
31    # compilation, third-party/rust/fixups/subsecond/fixups.toml carries the
32    # same flag for subsecond's - §8.1, both are needed) non-inert.
33    rustc_flags = [
34        "-Csave-temps=true",
35        "-Clink-dead-code",
36        "-Cdebug-assertions=yes",
37    ],
38    deps = _DEPS,
39    visibility = ["PUBLIC"],
40)
41
42# The stall detector's and the recovery mechanism's own `#[cfg(test)]`
43# modules moved with them to //packages/zbanks:test (src/stall.rs,
44# src/recovery.rs are shared with apps/zbanks now - see that crate's own
45# BUCK and CLAUDE.md). `bot_log_rotation_tests` (app.rs) is what this
46# target's own tests are, as of the pipe-and-rotate bot.log fix.
47rust_test(
48    name = "test",
49    srcs = ["src/app.rs", "src/activity.rs"],
50    crate_root = "src/app.rs",
51    edition = "2024",
52    deps = _DEPS,
53)
54
55rust_binary(
56    name = "native",
57    srcs = ["src/main.rs"],
58    crate_root = "src/main.rs",
59    edition = "2024",
60    # `-Clink-dead-code` stays on the EXECUTABLE's own rustc invocation
61    # because that is the one that actually calls the system linker
62    # (research/subsecond-patch-build.md §7.2's measurement was against a
63    # rust_binary for exactly this reason) - it is what stops the final
64    # link from stripping `app`/`panels` symbols a future patch needs to
65    # jump back into. `-Csave-temps=true` stays too, NOT for main.rs's own
66    # patch points (it has none) but because `main`'s compiled object is the
67    # only place the "main" sentinel symbol subsecond's `apply_patch` looks
68    # up by name can come from - tools/hotpatch/patch.sh folds this
69    # target's OWN last-built object in from disk (never rebuilding the
70    # executable itself) alongside `app`'s fresh ones. `main.rs` has no
71    # patch points, so no `-Cdebug-assertions=yes`.
72    rustc_flags = [
73        "-Csave-temps=true",
74        "-Clink-dead-code",
75    ],
76    # Exports `main` as the ASLR reference point, same as apps/hotdemo/BUCK.
77    linker_flags = [
78        "-Wl,--export-dynamic-symbol,main",
79    ],
80    deps = [
81        ":app",
82        "//packages/mcp:mcp",
83    ],
84)