diff --git a/crates/engine/src/cmd/diagnostics.rs b/crates/engine/src/cmd/diagnostics.rs index a918dace8..6eff986a4 100644 --- a/crates/engine/src/cmd/diagnostics.rs +++ b/crates/engine/src/cmd/diagnostics.rs @@ -38,6 +38,12 @@ pub static COMMANDS: &[CommandSpec] = &[ inside it; total counts its outermost run only. Recording also starts with SOLIDCRAFT_PROFILE=1, the CLI's \ --profile and the app's preference; off, it costs nothing measurable. Read-only", ), + CommandSpec::new("diagnostics.kernel", "Geometry Kernel", kernel).icon("bug_report").noundo().params( + "choice?: routed | smlib | solidcore (sets which kernel answers: routed = each operation on the kernel the routing \ + table gives it, smlib = the C++ SMLib kernel for all, solidcore = its Rust port for all; bodies already computed \ + keep their results). SOLIDCRAFT_KERNEL, when set, wins over it. Returns {choice, environment, routes: [{op, \ + route, backend}]}: route is the table's kernel for the operation, backend the one it runs on now", + ), CommandSpec::new("diagnostics.crash_test", "Crash Test", crash_test).icon("bug_report").noundo().enabled(crash_test_enabled).params( "mode: panic | kernel | abort. Checks that crash reports work: panic = an internal error in this command (caught; \ the design is unchanged), kernel = one inside the geometry kernel (caught), abort = the app ends at once (reported \ @@ -45,6 +51,19 @@ pub static COMMANDS: &[CommandSpec] = &[ ), ]; +fn kernel(_: &mut Session, p: &Value) -> Result { + use solidcraft_kernel::kernel_route as route; + if let Some(id) = str_(p, "choice") { + let c = route::Choice::from_id(id).ok_or_else(|| bad("diagnostics.kernel", "`choice` is routed, smlib or solidcore"))?; + route::set_choice(c); + } + let routes: Vec = route::Op::ALL + .iter() + .map(|op| json!({ "op": format!("{op:?}").to_lowercase(), "route": op.route().id(), "backend": op.backend().id() })) + .collect(); + Ok(json!({ "choice": route::choice().id(), "environment": route::overridden(), "routes": routes })) +} + fn dir(cmd: &str) -> Result { crash::default_dir().ok_or_else(|| bad(cmd, "no crash folder on this system")) } diff --git a/crates/kernel/src/lib.rs b/crates/kernel/src/lib.rs index f081298d9..adc778d4c 100644 --- a/crates/kernel/src/lib.rs +++ b/crates/kernel/src/lib.rs @@ -207,6 +207,8 @@ pub use polyhedron::{HalfSpace, convex_polyhedron, draft, offset_faces, shell}; pub use prism::{PLANAR_FIT_TOL, extrude_planar_regions, planar_regions_boolean}; pub use prism_measure::certified_prism_equivalent; pub use sew::{EdgeSpec, FaceSpec, SurfSpec, sew, sew_touching}; +/// Which kernel answers each operation, SMLib or solidcore (crates/smlib/src/route.rs). +pub use solidcraft_smlib::route as kernel_route; pub use splitface::{SplitTool, split_body, split_faces, split_faces_with_map}; pub use step::step_export; pub use step_in::{