-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Ensure snapshot rebuild logic takes main path into account #11924
Ensure snapshot rebuild logic takes main path into account #11924
Conversation
Do you include the identity of the engine as part of this? One thing I've noticed in the past is that if I switch between using --local-engine and not using it, we don't rebuild. Or if I use --local-engine then rebuild the engine, we don't rebuild. |
Intercepted by #11913. I'll stop this race. |
Sorry about that! Only spotted #11730 on Friday when Hixie CC'ed me on it, but by that time the merge conflicts were pretty nasty-looking. Should have CC'ed you on #11913 when I sent it out on Friday, but it slipped my mind -- sorry about that! I really like the idea of renaming Checksum -> Fingerprint and using a map for the additional properties. Probably worth sending that bit out if nothing else. I'm also happy to pick up that bit of cleanup if you've got other things on your plate. |
@cbracken No worries, I just didn't want to keep racing :-). If you are done working on this, I can do the refactoring and address Ian's comment about the engine too. Just let me know. |
I'm done for the time being. Refactor + local engine handling would be fantastic. I'm going to be working on disentangling all the AOT variants from build_aot.dart and slowly swinging them over out of the one big build method + adding tests. Thanks again! |
c7238e2
to
1a1974a
Compare
|
||
String toJson() => JSON.encode(<String, dynamic>{ | ||
String toJson() => JSON.encode(<String, dynamic>{ |
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: looks like an extra space slipped in after the return type.
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.
Done.
@@ -21,7 +21,9 @@ GenSnapshot get genSnapshot => context.putIfAbsent(GenSnapshot, () => const GenS | |||
|
|||
/// A snapshot build configuration. | |||
class SnapshotType { | |||
const SnapshotType(this.platform, this.mode); | |||
SnapshotType(this.platform, this.mode) { |
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.
Any reason to not keep the const? (and if not, s/new/const/
in buildScriptSnapshot
)
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.
Apparently, we cannot have both const
and asserts just yet. IntelliJ accepts the code below, but pub run test
chokes on it.
const SnapshotType(this.platform, this.mode): assert(mode != null);
dart -v
says
assert_initializer: false (Allow asserts in initializer lists.)
I believe this flag will be true
by default in the not too distant future.
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.
Ah yep - not sure how many times that's bit me now! The engine is compiled with that flag set, but we don't run the tool that way. Thanks.
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.
Not sure about const
, but simple fix for asserts support in pub run test
is to set DART_VM_OPTIONS=--assert-initializer
for pub run test
invocation.
'targetPlatform': 'TargetPlatform.android_x64', | ||
'entryPoint': 'a.dart', | ||
}, <String>['a.dart', 'b.dart'])); | ||
}, overrides: <Type, Generator>{ FileSystem: () => 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.
nit: s/fs}/fs }/
at the end
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.
Done.
@@ -434,10 +423,13 @@ void main() { | |||
await fs.file('other.dart').writeAsString('import "main.dart";\nvoid main() {}'); | |||
await fs.file('output.snapshot').create(); | |||
await fs.file('output.snapshot.d').writeAsString('output.snapshot : main.dart'); | |||
await fs.file('output.snapshot.d.checksums').writeAsString(JSON.encode(<String, dynamic>{ | |||
'version': '$kVersion', |
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.
Oops! Thanks for fixing!
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.
Thanks for the review!
@@ -21,7 +21,9 @@ GenSnapshot get genSnapshot => context.putIfAbsent(GenSnapshot, () => const GenS | |||
|
|||
/// A snapshot build configuration. | |||
class SnapshotType { | |||
const SnapshotType(this.platform, this.mode); | |||
SnapshotType(this.platform, this.mode) { |
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.
Apparently, we cannot have both const
and asserts just yet. IntelliJ accepts the code below, but pub run test
chokes on it.
const SnapshotType(this.platform, this.mode): assert(mode != null);
dart -v
says
assert_initializer: false (Allow asserts in initializer lists.)
I believe this flag will be true
by default in the not too distant future.
|
||
String toJson() => JSON.encode(<String, dynamic>{ | ||
String toJson() => JSON.encode(<String, dynamic>{ |
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.
Done.
'targetPlatform': 'TargetPlatform.android_x64', | ||
'entryPoint': 'a.dart', | ||
}, <String>['a.dart', 'b.dart'])); | ||
}, overrides: <Type, Generator>{ FileSystem: () => 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.
Done.
51bc0b7
to
8eb0a49
Compare
Thanks again! |
We control the VM entrypoint (it's in the bash script) so it should be a trivial thing to just pass the flag to enable const asserts and anything else we want. |
Fixes #11400
This is a retake of #11730 which was intercepted by #11820. The latter partially fixes #11400.
flutter run lib/foo.dart
always runs the first thing built #11400. Switch of main entry point would still be ignored, with no new snapshot built, if we happen to switch between two main entry points that are both snapshot dependencies independently of whether they are selected as main entry point. This happens e.g. if the two main entry points import each other. This is fixed by including the main entry point path along with build mode and target platform in the checksum file.Checksum
intoFingerprint
to reflect that the class no longer just handles file checksums, but also build properties.Fingerprint
from theSnapshotter
's knowledge of actual build properties to save.SnapshotType
withnull
build mode, to avoid having to check for this situation down-stream.