Unverified Commit 39ddeb52 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Fix snapshot fingerprint check for --preview-dart-2. (#14775)

* Fix snapshot fingerprint check for --preview-dart-2.

* Remove printTraces
parent 494270fe
......@@ -335,6 +335,30 @@ Future<String> _buildAotSnapshot(
]);
}
final String genSnapshotInputFile = previewDart2 ? kApplicationKernelPath : mainPath;
final SnapshotType snapshotType = new SnapshotType(platform, buildMode);
final File fingerprintFile = fs.file('$dependencies.fingerprint');
final List<File> fingerprintFiles = <File>[fingerprintFile, fs.file(dependencies)]
..addAll(inputPaths.map(fs.file))
..addAll(outputPaths.map(fs.file));
if (fingerprintFiles.every((File file) => file.existsSync())) {
try {
final String json = await fingerprintFile.readAsString();
final Fingerprint oldFingerprint = new Fingerprint.fromJson(json);
final Set<String> snapshotInputPaths = await readDepfile(dependencies)
..add(genSnapshotInputFile)
..addAll(outputPaths);
final Fingerprint newFingerprint = Snapshotter.createFingerprint(snapshotType, genSnapshotInputFile, snapshotInputPaths);
if (oldFingerprint == newFingerprint) {
printStatus('Skipping AOT snapshot build. Fingerprint match.');
return outputPath;
}
} catch (e) {
// Log exception and continue, this step is a performance improvement only.
printTrace('Rebuilding snapshot due to fingerprint check error: $e');
}
}
if (previewDart2) {
mainPath = await compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
......@@ -358,29 +382,6 @@ Future<String> _buildAotSnapshot(
genSnapshotCmd.add(mainPath);
final SnapshotType snapshotType = new SnapshotType(platform, buildMode);
final File fingerprintFile = fs.file('$dependencies.fingerprint');
final List<File> fingerprintFiles = <File>[fingerprintFile, fs.file(dependencies)]
..addAll(inputPaths.map(fs.file))
..addAll(outputPaths.map(fs.file));
if (fingerprintFiles.every((File file) => file.existsSync())) {
try {
final String json = await fingerprintFile.readAsString();
final Fingerprint oldFingerprint = new Fingerprint.fromJson(json);
final Set<String> snapshotInputPaths = await readDepfile(dependencies)
..add(mainPath)
..addAll(outputPaths);
final Fingerprint newFingerprint = Snapshotter.createFingerprint(snapshotType, mainPath, snapshotInputPaths);
if (oldFingerprint == newFingerprint) {
printStatus('Skipping AOT snapshot build. Fingerprint match.');
return outputPath;
}
} catch (e) {
// Log exception and continue, this step is a performance improvement only.
printTrace('Rebuilding snapshot due to fingerprint check error: $e');
}
}
final RunResult results = await runAsync(genSnapshotCmd);
if (results.exitCode != 0) {
printError('Dart snapshot generator failed with exit code ${results.exitCode}');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment