Skip to content
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

Merged
merged 5 commits into from
Sep 7, 2017

Conversation

mravn-google
Copy link
Contributor

@mravn-google mravn-google commented Sep 4, 2017

Fixes #11400

This is a retake of #11730 which was intercepted by #11820. The latter partially fixes #11400.

  • Fixes the remaining part of 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.
  • Refactors Checksum into Fingerprint to reflect that the class no longer just handles file checksums, but also build properties.
  • Separates the general notion of a build Fingerprint from the Snapshotter's knowledge of actual build properties to save.
  • Prevents the creation of a SnapshotType with null build mode, to avoid having to check for this situation down-stream.

@Hixie
Copy link
Contributor

Hixie commented Sep 5, 2017

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.

@mravn-google
Copy link
Contributor Author

Intercepted by #11913. I'll stop this race.

@cbracken
Copy link
Member

cbracken commented Sep 5, 2017

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.

@mravn-google
Copy link
Contributor Author

@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.

@cbracken
Copy link
Member

cbracken commented Sep 5, 2017

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!


String toJson() => JSON.encode(<String, dynamic>{
String toJson() => JSON.encode(<String, dynamic>{
Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

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)

Copy link
Contributor Author

@mravn-google mravn-google Sep 7, 2017

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.

Copy link
Member

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.

Copy link
Member

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});
Copy link
Member

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

Copy link
Contributor Author

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks for fixing!

@cbracken
Copy link
Member

cbracken commented Sep 7, 2017

lgtm

Thanks!

Copy link
Contributor Author

@mravn-google mravn-google left a 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) {
Copy link
Contributor Author

@mravn-google mravn-google Sep 7, 2017

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>{
Copy link
Contributor Author

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});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@cbracken
Copy link
Member

cbracken commented Sep 7, 2017

Thanks again!

@Hixie
Copy link
Contributor

Hixie commented Sep 7, 2017

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.

@mravn-google mravn-google deleted the launch_wrong_target2 branch December 18, 2017 21:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flutter run lib/foo.dart always runs the first thing built
5 participants