From 1f6b9471a87ce90472afd8ee5fc951e5662208b5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Fri, 23 Feb 2018 21:40:19 +0100 Subject: [PATCH] Fix snapshot fingerprinting in --preview-dart-2 mode. (#14843) * Fix snapshot fingerprinting in --preview-dart-2 mode. This is a follow up to PR #14775 - instead of treating dill file as an input treat as intermediate file and don't fingerprint it. Make sure to always use original main Dart file as an entry point for fingerprint calculation. This fixes an issue that AOT snapshot would not be recompiled in the preview-dart-2 mode if entry point changes, e.g. $ flutter build aot -t t/x.dart --preview-dart-2 $ flutter build aot -t t/y.dart --preview-dart-2 The second invocation would not build AOT snapshot. (This issue is visible on the microbencmarks bot) --- .../lib/src/commands/build_aot.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index 86dcc042aa..5180509c67 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -335,8 +335,15 @@ Future _buildAotSnapshot( ]); } - final String genSnapshotInputFile = previewDart2 ? kApplicationKernelPath : mainPath; + final String entryPoint = mainPath; final SnapshotType snapshotType = new SnapshotType(platform, buildMode); + Future makeFingerprint() async { + final Set snapshotInputPaths = await readDepfile(dependencies) + ..add(entryPoint) + ..addAll(outputPaths); + return Snapshotter.createFingerprint(snapshotType, entryPoint, snapshotInputPaths); + } + final File fingerprintFile = fs.file('$dependencies.fingerprint'); final List fingerprintFiles = [fingerprintFile, fs.file(dependencies)] ..addAll(inputPaths.map(fs.file)) @@ -345,11 +352,7 @@ Future _buildAotSnapshot( try { final String json = await fingerprintFile.readAsString(); final Fingerprint oldFingerprint = new Fingerprint.fromJson(json); - final Set snapshotInputPaths = await readDepfile(dependencies) - ..add(genSnapshotInputFile) - ..addAll(outputPaths); - final Fingerprint newFingerprint = Snapshotter.createFingerprint(snapshotType, genSnapshotInputFile, snapshotInputPaths); - if (oldFingerprint == newFingerprint) { + if (oldFingerprint == await makeFingerprint()) { printStatus('Skipping AOT snapshot build. Fingerprint match.'); return outputPath; } @@ -459,10 +462,7 @@ Future _buildAotSnapshot( // Compute and record build fingerprint. try { - final Set snapshotInputPaths = await readDepfile(dependencies) - ..add(mainPath) - ..addAll(outputPaths); - final Fingerprint fingerprint = Snapshotter.createFingerprint(snapshotType, mainPath, snapshotInputPaths); + final Fingerprint fingerprint = await makeFingerprint(); await fingerprintFile.writeAsString(fingerprint.toJson()); } catch (e, s) { // Log exception and continue, this step is a performance improvement only.