1//! Crux type-generation for the shared domain (built with `--features typegen`).
3//! Demonstrates the Crux type-sharing pipeline: the core's view types are the
4//! single source of truth, and this binary emits matching JVM type definitions
5//! for the shell to consume across an FFI boundary. In this NDK-less build the
6//! Android shell hand-mirrors these types (see `app/.../core/ViewModel.kt`);
7//! wiring a real `.so` would have it consume the generated output instead.
9//! Run: `cd shared && cargo run --features typegen --bin codegen`
10//! Output: `generated/` (JVM/Java sources + the bincode serde runtime).
12use std::path::PathBuf;
15use crux_core::typegen::TypeGen;
16use shared::{MessageStatus, MessageView, Screen, SessionView, ToolView, ViewModel};
18fn main() -> Result<()> {
19 let mut gen = TypeGen::new();
21 // Register leaf types before the aggregates that reference them.
22 gen.register_type::<Screen>()?;
23 gen.register_type::<MessageStatus>()?;
24 gen.register_type::<ToolView>()?;
25 gen.register_type::<SessionView>()?;
26 gen.register_type::<MessageView>()?;
27 gen.register_type::<ViewModel>()?;
29 let out = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../generated");
30 std::fs::create_dir_all(&out)?;
31 gen.java("soy.iko.opencode.shared", &out)?;
33 println!("Generated shared JVM types into {}", out.display());
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list