regenerate generated_main if deps changed in hot reload/restart#77959
regenerate generated_main if deps changed in hot reload/restart#77959cyanglaz wants to merge 10 commits intoflutter:masterfrom
generated_main if deps changed in hot reload/restart#77959Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
nit: prefer relative imports for flutter_tools
There was a problem hiding this comment.
nit: doc comment describing what this is for.
There was a problem hiding this comment.
This should be read from the environment configuration - see the KernelSnapshot target for an example, think it is called target or something like that
There was a problem hiding this comment.
I think you should only skip if generateDartPluginRegistry is false
5c8472f to
8b62bbd
Compare
843ffba to
2c823cc
Compare
| /// Construct a [DartPluginRegistrantTarget]. | ||
| /// | ||
| /// If `project` is unset, a [FlutterProject] based on environment is used. | ||
| DartPluginRegistrantTarget({FlutterProject project}) { |
There was a problem hiding this comment.
the project param is mainly configurable for testing. In tests, i needed a FlutterProject.fromDirectoryTest
If there are better solution to this, please let me know.
There was a problem hiding this comment.
You can add a @VisibleForTesting annotation on it if it isn't meant to be normally used
|
| /// | ||
| /// If `project` is unset, a [FlutterProject] based on environment is used. | ||
| DartPluginRegistrantTarget({FlutterProject project}) { | ||
| _project = project; |
There was a problem hiding this comment.
do this in an initializer and make it final
| /// Construct a [DartPluginRegistrantTarget]. | ||
| /// | ||
| /// If `project` is unset, a [FlutterProject] based on environment is used. | ||
| DartPluginRegistrantTarget({FlutterProject project}) { |
There was a problem hiding this comment.
this constructor should be const
generated_main if deps changed in hot reload/restartgenerated_main if deps changed in hot reload/restart
cyanglaz
left a comment
There was a problem hiding this comment.
@jonahwilliams Fixed review comments. PTAL
aa6787d to
280989a
Compare
|
Holding off on landing this until we re-visting the dart plugin registrant |
| // so the resident compiler can find it. | ||
| final File newMainDart = buildDir.parent.childFile('generated_main.dart'); | ||
| if (await generateMainDartWithPluginRegistrant( | ||
| await generateMainDartWithPluginRegistrant( |
There was a problem hiding this comment.
I thought this would now be handled by the target DartPluginRegistrantTarget. no?
There was a problem hiding this comment.
I thought DartPluginRegistrantTarget only happens in hot reload not compile. At least that's the behavior in my manual testing.
@jonahwilliams Is there a way to always handle this in DartPluginRegistrantTarget, both in compile and hot reload/restart?
There was a problem hiding this comment.
I believe it should run before the first compile, but that should be easy to checl
| final String renderedTemplate = globals.templateRenderer | ||
| .renderString(template, context, htmlEscapeValues: false); | ||
| final File file = globals.fs.file(filePath); | ||
| final FileSystem fs = fileSystem ?? globals.fs; |
There was a problem hiding this comment.
what about just globals.fs? it'd be more consistent with the use of globals in line 28
There was a problem hiding this comment.
this adds the possibility to over write fileSystem which makes test easier.
|
|
||
| final CompositeTarget compositeTarget = CompositeTarget(<Target>[ | ||
| const GenerateLocalizationsTarget(), | ||
| const DartPluginRegistrantTarget(), |
When dependencies are changed in the middle of run, hot reload and hot restart should update
generated_mainaccordingly.Fixes #76219
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.