native icon indicating copy to clipboard operation
native copied to clipboard

[hooks_runner] Build cache invalidation too passive for other toolchains.

Open MichealReed opened this issue 6 months ago • 1 comments

When building native assets using the native_toolchain_cmake package, I find myself having to delete the .dart_tool directory often as the builder does not pick up on file changes in the nested build process. Maybe a way to subscribe specific directories for monitoring for the cache invalidation would be beneficial, or a dart flag to force a native asset rebuild.

MichealReed avatar May 19 '25 12:05 MichealReed

When building native assets using the native_toolchain_cmake package, I find myself having to delete the .dart_tool directory often as the builder does not pick up on file changes in the nested build process.

The best way would be to automatically report the dependencies correctly. Make, Ninja, and Clang can all do this. CMake unfortunately has no such command/flag.

The second best way is to correctly report the dependencies in the build hook manually (repeating some of the logic of your CMake build). BuildOutput.addDependencies takes directories (non-recursive) and files. You can use a Glob to get all directories and files in a directory to report.

Maybe a way to subscribe specific directories for monitoring for the cache invalidation would be beneficial,

Yes, that is what output.addDependencies is for.

or a dart flag to force a native asset rebuild.

I believe this should be integrated into flutter clean (and the not yet existing dart clean)

  • https://github.com/flutter/flutter/issues/151890
  • https://github.com/dart-lang/sdk/issues/60754

(Contributions welcome!)

dcharkes avatar May 19 '25 14:05 dcharkes