codegen: drop generate_wasm + emit single wasm-compat types.rs #114
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_rpc!114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "drop-wasm-emission"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Per the maintainer: there should be no separate WASM types file. The generated
types.rsis wasm-compatible by construction; OSIS storage impls live in a sibling cfg-gated file. Nogenerate_wasmflag, no opt-in dance, no dead-weight second file ever.Architecture
Before:
After:
herolib_sidandherolib_otomlare themselves wasm-compatible (no tokio / I/O / native-only deps), so the type definitions compile cleanly to wasm32. The OSIS storage trait machinery only lives in the cfg-gated sibling, so it disappears on wasm32 builds.Changes
OschemaBuildConfig::generate_wasmfield +with_wasm()setter.Generator::generate_wasmfield +wasm()setter.if config.generate_wasm).crate::generate::wasm_build_script(long unused per its own module docstring).generate/rust_types.rs: write onlytypes.rs(now wasm-compat), plus the newosis_impl.rs.pub mod types_wasm;+pub use generated::types_wasm::*;cfg branches from both the generated barrel and the scaffolded parentmod.rs.crate::rust::generate_osis_impl_block(&Schema)— emits the manualimpl OsisObjectblock (same shape#[derive(OsisObject)]would expand to). Honours@indexmarkers. ReturnsNonewhen the schema has no root objects.rust_struct.rs::generate_rust_structsto: import OTOML built-ins fromherolib_otoml(nothero_rpc_osis::otoml::*); drop#[derive(OsisObject)]from the struct definition.build/layout.rs::generate_domain_mod_flatto emit a singlemod types; pub use types::*;block (no cfg-gates).herolib_otomlto the core crate's dependencies.src/recipes/mod.rs+crates/hero_recipes/Cargo.toml+build.rsupdated in-tree to match.crates/osis/examples/basic/code/src/core/app/mod.rscfg-routing cleaned up..with_wasm()comment removed.Test plan
cargo test --workspace --libpasses (302 lib tests across the workspace).cargo build --manifest-path examples/recipe_server/Cargo.tomlcompletes clean — every workspace member compiles.cargo run --example 01_walkthroughcompletes all six steps; demo dir has onetypes.rsplus cfg-gatedosis_impl.rs, notypes_wasm.rsanywhere.Per the maintainer: there should be no separate WASM types file. The generated `types.rs` is wasm-compatible *by construction*; OSIS storage impls live in a sibling cfg-gated file. No `generate_wasm` flag, no opt-in dance, no dead-weight second file ever. ## Architecture Before: generated/types.rs # uses hero_rpc_osis::* + #[derive(OsisObject)] generated/types_wasm.rs # parallel self-contained version, opt-in After: generated/types.rs # ONLY uses serde + herolib_sid + herolib_otoml # (wasm-compatible — no hero_rpc_osis imports) generated/osis_impl.rs # `#![cfg(not(target_arch = "wasm32"))]` # manual `impl OsisObject for X` per root object `herolib_sid` and `herolib_otoml` are themselves wasm-compatible (no tokio / I/O / native-only deps), so the type definitions compile cleanly to wasm32. The OSIS storage trait machinery only lives in the cfg-gated sibling, so it disappears on wasm32 builds. ## Changes - Remove `OschemaBuildConfig::generate_wasm` field + `with_wasm()` setter. - Remove `Generator::generate_wasm` field + `wasm()` setter. - Remove the builder wiring (`if config.generate_wasm`). - Remove `crate::generate::wasm_build_script` (long unused per its own module docstring). - Drop the dual-emission path in `generate/rust_types.rs`: write only `types.rs` (now wasm-compat), plus the new `osis_impl.rs`. - Drop the `pub mod types_wasm;` + `pub use generated::types_wasm::*;` cfg branches from both the generated barrel and the scaffolded parent `mod.rs`. - Add `crate::rust::generate_osis_impl_block(&Schema)` — emits the manual `impl OsisObject` block (same shape `#[derive(OsisObject)]` expanded to). Honours `@index` markers via `indexed_fields()` and `indexed_field_names()`. Returns `None` when the schema has no root objects (no file to write). - Update `rust_struct.rs::generate_rust_structs` to: - Import OTOML built-ins from `herolib_otoml` (not `hero_rpc_osis::otoml::*`). - Drop `#[derive(OsisObject)]` from the struct definition. - Update `build/layout.rs::generate_domain_mod_flat` to emit a single `mod types; pub use types::*;` block (no cfg-gates). - Scaffolder Cargo.toml template adds `herolib_otoml` to the core crate's dependencies (it's referenced directly in the emitted `types.rs`). - Recipe server's `src/recipes/mod.rs` + `crates/hero_recipes/Cargo.toml` + `build.rs` updated in-tree to match the new layout. - Stale `crates/osis/examples/basic/code/src/core/app/mod.rs` cfg-routing cleaned up. - Walkthrough demo's leftover `.with_wasm()` comment removed. ## Tests - One generator unit test (`test_otoml_types`) had an `assert!(contains "hero_rpc_osis::otoml::"`)` — updated to `herolib_otoml::`. - 138/138 generator lib tests pass. - Full `cargo test --workspace --lib` passes (302 lib tests across the workspace). - `cargo build --manifest-path examples/recipe_server/Cargo.toml` completes clean — every workspace member compiles. - `cargo run --example 01_walkthrough` still completes all six steps; the demo dir contains a single `types.rs` plus the cfg-gated `osis_impl.rs`, no `types_wasm.rs` anywhere.