-
Notifications
You must be signed in to change notification settings - Fork 29.7k
regenerate generated_main if deps changed in hot reload/restart
#77959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prefer relative imports for flutter_tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: doc comment describing what this is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should only skip if generateDartPluginRegistry is false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, smart :D
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would now be handled by the target DartPluginRegistrantTarget. no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should run before the first compile, but that should be easy to checl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed in 829756e
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this adds the possibility to over write fileSystem which makes test easier.
|
|
||
| final CompositeTarget compositeTarget = CompositeTarget(<Target>[ | ||
| const GenerateLocalizationsTarget(), | ||
| const DartPluginRegistrantTarget(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
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.