Skip to content

feat: mode = "lib" end to end (G2a, cli half) - #17

Merged
Kinflou merged 2 commits into
mainfrom
feat/lib-mode-cli
Aug 31, 2026
Merged

Kinflou merged 2 commits into
mainfrom
feat/lib-mode-cli

Conversation

@Kinflou

@Kinflou Kinflou commented Aug 31, 2026

Copy link
Copy Markdown
Member

De-rot G2a, CLI half. Pairs with generation #5 (GeneratedFile contract + rust lib mode) and #6 (autobins fix), both merged.

generate.rs

Speaks the new generator contract:

  • t.mode string → Mode — code / lib; dylib is rejected with a clear message.
  • Per package version: build a GenRequest { mode, schemas: <all of them>, package: PackageMeta { name, version } }, call the generator once, write the files it returns.
    • name = the congregation name (:: → -); version = the package version, or 0.0.0 for an unbuilt working tree.
  • code — one file per schema, still placed by the layout template (unchanged behaviour).
  • lib — the returned crate is written under <out>/<language>/ verbatim (Cargo.toml + src/lib.rs + src/<namespace>.rs); layout is not consulted inside a crate.
  • lib + multiple package versions → error for now.

Wiring

comline-codelib-gen git rev bumped to db4f166 (lib mode + autobins fix + the TypeScript generator from generation#4). comline-core stays at the rev comline-codelib-gen pins, so the tree still has one comline-core.

Tests

lib_mode_emits_a_crate (asserts Cargo.toml name/edition/serde, src/lib.rs mod list, src/*.rs), dylib_mode_is_rejected. 38 pass. Manually verified: the fixture generates a crate that cargo checks clean.

Follow-ups (noted, not blocking)

  • A namespace literally named main or lib still trips Rust's special_module_name warning (it compiles) — fix by nesting schema modules under src/schemas/.
  • clean.rs unchanged: its "dedicated out dir → remove wholesale" branch already covers lib mode for the common config; it could instead ask the generator for its paths.
  • layout-driven lib root, multi-version lib, nested namespaces in lib.

Design: design/generation.md → G2a.

Kinflou added 2 commits August 31, 2026 18:00
generate.rs now speaks the GeneratedFile contract (generation#5):

- t.mode string -> Mode (code / lib; dylib rejected).
- Per version, build a GenRequest with every schema, the mode, and
  PackageMeta { name = congregation name, version = package version or
  0.0.0 for an unbuilt tree }, call the generator once, write the files
  it returns.
- code mode: one file per schema, still placed by the layout template.
- lib mode: the returned crate goes under <out>/<language>/ verbatim
  (Cargo.toml + src/lib.rs + src/<namespace>.rs). The layout template is
  not consulted inside the crate.
- lib + multiple package versions -> error for now.

Cargo.toml: bump comline-codelib-gen to db4f166 (lib mode + autobins fix
+ the TypeScript generator from #4).

Tests: lib_mode_emits_a_crate, dylib_mode_is_rejected. 38 pass.

Follow-ups: a namespace literally named main or lib still triggers Rust's
special_module_name warning (nest schema modules under src/schemas/);
clean.rs could ask the generator for its paths rather than lean on the
"dedicated out dir" branch.
@Kinflou
Kinflou merged commit d80886d into main Aug 31, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/lib-mode-cli branch September 2, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant