English
Code generation
A large amount of code comes out of generators, and the generated files are committed. Whenever you change an input, regenerate and commit the output along with it, or CI will fail.
Dart code generation (build_runner)
Covers injectable, freezed, json_serializable and others:
bash
dart tool/task.dart build-runner- It has to run from the repository root: running it only in
mobile/misses the annotations inside the packages. - It runs
dart format .for you as part of the job. - Run it when you change a DI binding annotation, a Freezed model or a JSON serialization annotation.
Rust FFI bindings (flutter_rust_bridge)
bash
dart tool/task.dart gen-rustRun it when you change
rust/src/apiin any native package.It first checks that the
flutter_rust_bridge_codegenCLI matches the version pinned in the pubspec (a mismatch is rejected outright, so that the pinned version can't be rewritten by accident). Install the right one if needed:bashcargo install flutter_rust_bridge_codegen --version 2.13.0 --lockedOnce generation finishes it runs
cargo fmtand analyze.
Internationalization (slang)
bash
dart tool/task.dart i18n- Run it when you change a
*.i18n.jsoninmoodiary_i18normui. - No CI check catches a forgotten regeneration, so make a point of running this yourself and committing the output.
Doing both at once
bash
dart tool/task.dart genConsistency checks
tool/check_generated.dart runs as part of analyze and in CI, and is responsible for keeping things aligned across packages:
- the
Cargo.tomlfiles, toolchains and FRB / ffigen versions of the six native packages have to match exactly; - an error here usually means one package was upgraded on its own, so either bring the others along or revert it.
More about build hooks
- The native libraries are compiled by Native Assets build hooks, and the cache lives in
.dart_tool/hooks_runner/at the repository root. flutter cleandoes not clear that cache. If the APK size doesn't change after you modify a Rust dependency, suspect the cache first.dart tool/task.dart cleanremoves both the editor output and that cache.- Build hooks return early when the target platform equals the host platform, which is why
flutter testnever builds or loads any Rust library, editor asset or license manifest (the C hook inmoodiary_sqlite_vecbeing the exception).