mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix snapshot fingerprint check for --preview-dart-2. (#14775)
* Fix snapshot fingerprint check for --preview-dart-2. * Remove printTraces
This commit is contained in:
parent
494270fe46
commit
39ddeb52b0
@ -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}');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user