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
|
# The C ABI Jolt loads for the UI: libvidya.so.
rust_library(
name = "vidya-ffi",
srcs = glob(["src/**/*.rs"]),
crate = "vidya",
crate_root = "src/lib.rs",
edition = "2021",
preferred_linkage = "shared",
# Without this buck names the library after the target — lib_vidya-ffi.so —
# and that name, not the filename, is what the linker writes into a
# dependent's DT_NEEDED. Every consumer looks for `libvidya`.
soname = "libvidya.so",
# Cross-crate inlining across the whole graph, and one codegen unit so the
# dedup is not fighting parallelism inside the crate. Measured on the
# desktop object: 12.06M to 10.57M, of which 628K is .text and the rest is
# the unwind tables halving — LTO alone folds most of the duplicate landing
# pads away. Only the cdylib asks for it; the rlibs above stay as they are.
#
# opt-level stays at 2. 3 was measured too and came out 134K *larger*, so
# the level in the toolchain is the one to keep.
rustc_flags = [
"-Clto=fat",
"-Ccodegen-units=1",
],
visibility = ["PUBLIC"],
# Cargo renames the dependency so the cdylib itself can keep the `vidya`
# crate name; mirror that here.
named_deps = select({
"DEFAULT": {"vidya_core": "//crates/vidya-core:vidya"},
# jni is renamed in third-party/rust/Cargo.toml, for the reason given
# there; the crate is `jni` to the source either way.
"prelude//os:android": {
"jni": "//third-party/rust:jni-0-22",
"vidya_core": "//crates/vidya-core:vidya",
},
}),
deps = [
"//third-party/rust:egui",
"//third-party/rust:egui-winit",
"//third-party/rust:egui_glow",
"//third-party/rust:glow",
"//third-party/rust:glutin",
"//third-party/rust:glutin-winit",
"//third-party/rust:png",
"//third-party/rust:winit",
] + select({
# Reading a pasted picture off the clipboard, which arboard has no
# Android backend for; `vidya_open_url` is an ACTION_VIEW intent there
# and a JNI call. Mirrors the target-gated deps in Cargo.toml.
"DEFAULT": ["//third-party/rust:arboard"],
"prelude//os:android": [],
}),
)
|