Skip to content

fix: warn that layout is ignored in lib mode, add flatten opt-out - #36

Merged
Kinflou merged 1 commit into
mainfrom
fix/lib-mode-layout-warning-and-flatten
Oct 4, 2026
Merged

Kinflou merged 1 commit into
mainfrom
fix/lib-mode-layout-warning-and-flatten

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 4, 2026

Copy link
Copy Markdown
Member

Summary

  • lib mode never consulted layout at all — only out mattered, with <language>/ always appended (src/commands/generate.rs). A target setting layout got no error and no effect, just a silently-nested directory nobody warned about. Reported against a real repro: out = "../test-cl-rs/", layout = "{{namespace}}.{{ext}}", mode = "lib" landed at ../test-cl-rs/rust/..., not ../test-cl-rs/....
  • comline generate now warns when a lib-mode target sets a non-default layout, naming where the crate actually lands.
  • Adds a per-target flatten = true (lib/dylib only) that writes the crate straight into out, skipping the <out>/<language>/ nesting — for exactly the case above, where the target already has out to itself and the nesting serves no purpose.
  • flatten is target-only, no [generate]-level default, no CLI flag/env — flattening a shared out across several lib targets would reintroduce the collision the nesting exists to avoid.
  • Docs: docs/cli.md gets the same stale "rust is the only generator" fix already applied across the docs site this week.

Test plan

  • cargo test — 49 passed, including 2 new (lib_mode_flatten_skips_the_language_directory, lib_mode_warns_that_layout_has_no_effect) plus a gen_config unit test for flatten resolution
  • Verified against the real reporter repro: unpatched config now shows the warning; adding flatten = true lands the crate directly in the target's out, no rust/ nesting

…/<lang>/

A lib-mode target silently dropped its `layout` entirely — only `out`
mattered, with `<language>/` unconditionally appended — so setting
`layout` to anything gave no error and no effect, just a confusingly
nested directory. Now warns when that happens, and adds a `flatten`
per-target bool so a target with `out` already to itself can skip the
`<out>/<language>/` nesting and land the crate straight into `out`.
@Kinflou
Kinflou merged commit 7f99195 into main Oct 4, 2026
2 checks passed
@Kinflou
Kinflou deleted the fix/lib-mode-layout-warning-and-flatten branch October 10, 2026 21:05
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