Skip to content

refactor: migrate ffigen configs to Dart and upgrade to ^20.0.0#324

Open
mosuem wants to merge 5 commits into
google:masterfrom
mosuem:migrate-ffigen-to-dart-config
Open

refactor: migrate ffigen configs to Dart and upgrade to ^20.0.0#324
mosuem wants to merge 5 commits into
google:masterfrom
mosuem:migrate-ffigen-to-dart-config

Conversation

@mosuem

@mosuem mosuem commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Migrated YAML ffigen configurations to Dart configurations in tool/ffigen.dart, updated ffigen to ^20.0.0, updated tool/update-bindings.sh, and re-generated native bindings.

mosuem added 2 commits July 15, 2026 12:50
- Upgrade ffigen dependency to ^20.0.0 in pubspec.yaml
- Consolidate YAML ffigen configs into tool/ffigen.dart
- Update tool/update-bindings.sh to run dart run tool/ffigen.dart
- Re-generate native bindings
@jonasfj

jonasfj commented Jul 15, 2026

Copy link
Copy Markdown
Member

Why not use YAML files?

@mosuem

mosuem commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Why not use YAML files?

https://pub.dev/packages/ffigen#yaml-configuration-reference It's being deprecated :)

@mosuem
mosuem requested a review from jonasfj July 16, 2026 09:25

@HamdaanAliQuatil HamdaanAliQuatil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the ffigen configuration to Dart makes sense since YAML configuration is being phased out.

I left comments on three things that currently make this harder to audit: typedefs: includeAll is greatly expanding the generated surface, the Flutter demo cleanup is unrelated, and the hooks major upgrade should be separated unless ffigen 20 requires it.

Could we keep this PR focused on the Dart configuration migration, the ffigen upgrade, the update script, and the necessary regenerated bindings? Changes to generated native bindings are much easier to review when the surrounding diff has one clear purpose.

Comment thread tool/ffigen.dart
include: Declarations.includeSet({'webcrypto_get_CBB_size'}),
),
structs: const Structs(dependencies: CompoundDependencies.opaque),
typedefs: const Typedefs(include: Declarations.includeAll),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pulling in far more than the YAML config did. The regenerated wrapper binding gains 141 typedefs, while the BoringSSL binding gains hundreds of typedefs and more than 100 unrelated opaque declarations. The set of bound functions itself has not changed.

Can we remove includeAll here and in the second config below, and let ffigen generate only the typedefs required by the selected declarations?


@override
_MyAppState createState() => _MyAppState();
MyAppState createState() => MyAppState();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we leave the demo changes out of this PR? They aren’t needed for the ffigen migration.

If the private return type was causing a lint, the narrower fix is:

State<MyApp> createState() => _MyAppState();

That keeps the state class private. The scrolling, spacing and deprecated-API cleanup would be easier to review separately.

Comment thread pubspec.yaml
dependencies:
ffi: ^2.0.0
hooks: ^1.0.0
hooks: ^2.0.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the hooks 2.x upgrade required by ffigen 20? This changes a runtime dependency, while the rest of the PR is a code-generation tooling migration.

If it is independent, can we update it separately?

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.

3 participants