Skip to content

fix: gate flatbuffers regeneration behind REGEN_FLATBUFFERS - #84

Open
netsirius wants to merge 1 commit into
mainfrom
fix/4747-stdlib-flatc-regen
Open

fix: gate flatbuffers regeneration behind REGEN_FLATBUFFERS#84
netsirius wants to merge 1 commit into
mainfrom
fix/4747-stdlib-flatc-regen

Conversation

@netsirius

Copy link
Copy Markdown
Contributor

Problem

rust/build.rs ran flatc --rust -o src/generated ... on every build, rewriting the checked-in generated files with whatever flatc is installed locally. A mismatched flatc turned a plain cargo check into ~4k dirty tracked lines, which twice got swept into commits (#72, reverted by #73; the initial commit of #83).

Solution

Regeneration is now opt-in (option 2 from the issue):

  • Normal builds never touch src/generated/ and don't require flatc — the checked-in files are the source of truth.
  • After editing a schema, run REGEN_FLATBUFFERS=1 cargo build and commit the .fbs and regenerated .rs together (documented in CONTRIBUTING.md). REGEN_FLATBUFFERS=0 or empty counts as unset.
  • Since regeneration is now explicit, it fails loudly: missing flatc or a nonzero flatc exit panics the build script instead of silently succeeding with stale files.

Testing

Scenario Result
cargo check (no env var) src/generated/ untouched, flatc not required
REGEN_FLATBUFFERS=0 cargo build no regeneration
REGEN_FLATBUFFERS=1 cargo build regenerates, output matches checked-in files
REGEN_FLATBUFFERS=1 without flatc build fails with a clear message

Possible follow-up: a CI job regenerating with a pinned flatc that fails on diff.

Fixes

Closes freenet/freenet-core#4747

@netsirius
netsirius requested review from iduartgomez and sanity July 19, 2026 15:08
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.

stdlib build.rs regenerates tracked flatbuffers with local flatc — repeatedly causes accidental 4k-line regen commits

1 participant