Skip to content

[ffigen] Remove the dependency on package:cli_util - #3674

Closed
spydon wants to merge 1 commit into
dart-lang:mainfrom
spydon:ffigen-remove-cli-util
Closed

spydon wants to merge 1 commit into
dart-lang:mainfrom
spydon:ffigen-remove-cli-util

Conversation

@spydon

@spydon spydon commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Note

This is an alternative to #3673. Only one of the two should be merged: #3673 widens the cli_util constraint, while this PR removes the dependency altogether.

Description

ffigen currently depends on cli_util: ^0.4.2, while newer tooling has moved on to cli_util 0.5 and 0.6. For example, every melos 8 release requires cli_util >=0.5.0, so a package can't have both ffigen and melos in its dev_dependencies. Since Melos 7, melos has to be a dev dependency in the workspace root, so any Flutter FFI plugin that uses Melos currently can't keep ffigen as a dev dependency.

The only thing ffigen uses from cli_util is the Ansi class, and only for three escape codes: green for the success messages, red for severe log lines in the executable, and the reset code. Rather than widening the constraint, this PR removes the dependency, so ffigen can't clash with other tools over cli_util again:

  • lib/src/logger.dart gets ansiGreen and ansiRed helpers, which use the same terminal check as Ansi.terminalSupportsAnsi (stdout.supportsAnsiEscapes and stdout being a terminal) and the same escape codes as before.
  • lib/src/ffigen.dart and lib/src/executables/ffigen.dart use those helpers instead of Ansi.
  • test/header_parser_tests/dart_handle_test.dart used sdkPath from cli_util to find the SDK include directory. It now derives it from ffigen's own dartExecutable helper.
  • example/shared_bindings declared cli_util without using it, so it is removed there too.

I ran dart analyze on the package and on example/shared_bindings, and ran test/header_parser_tests/dart_handle_test.dart, test/config_tests and test/unit_tests. Everything passes except the two sdk_variables_test.dart tests, which fail on my machine because xcrun can't find the iOS SDK. I also ran the ffigen executable in a pseudo terminal to confirm that the success message is still printed in green.

Related Issues

Alternative to #3673.

PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • I've run dart tool/ci.dart --all locally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevel pubspec.yaml workspace. (ffigen is not part of the top level workspace yet. I ran dart format and dart analyze on the package directly.)
  • All existing and new tests are passing. I added new tests to check the change I am making. (No new tests; the existing tests cover the affected code paths.)
  • The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR.
  • I have updated CHANGELOG.md for the relevant packages. (Not needed for small changes such as doc typos).
  • I have updated the pubspec package version if necessary. (The package is already on 22.0.1-wip.)

@spydon

spydon commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #3673

@spydon spydon closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants