Support for building dynamic patches in AOT mode. (#27672)
This commit is contained in:
committed by
GitHub
parent
7cdb30fba2
commit
63e6a7ad30
@@ -503,13 +503,21 @@ Future<void> _buildGradleProjectV2(
|
||||
|
||||
final Archive update = Archive();
|
||||
for (ArchiveFile newFile in newApk) {
|
||||
if (!newFile.isFile || !newFile.name.startsWith('assets/flutter_assets/'))
|
||||
if (!newFile.isFile)
|
||||
continue;
|
||||
|
||||
// Ignore changes to signature manifests.
|
||||
if (newFile.name.startsWith('META-INF/'))
|
||||
continue;
|
||||
|
||||
final ArchiveFile oldFile = oldApk.findFile(newFile.name);
|
||||
if (oldFile != null && oldFile.crc32 == newFile.crc32)
|
||||
continue;
|
||||
|
||||
// Only allow changes under assets/.
|
||||
if (!newFile.name.startsWith('assets/'))
|
||||
throwToolExit("Error: Dynamic patching doesn't support changes to ${newFile.name}.");
|
||||
|
||||
final String name = fs.path.relative(newFile.name, from: 'assets/');
|
||||
update.addFile(ArchiveFile(name, newFile.content.length, newFile.content));
|
||||
}
|
||||
@@ -527,11 +535,21 @@ Future<void> _buildGradleProjectV2(
|
||||
printStatus('No changes detected, creating rollback patch.');
|
||||
}
|
||||
|
||||
final ArchiveFile oldFile = oldApk.findFile('assets/flutter_assets/isolate_snapshot_data');
|
||||
if (oldFile == null)
|
||||
throwToolExit('Error: Could not find baseline assets/flutter_assets/isolate_snapshot_data.');
|
||||
final List<String> checksumFiles = <String>[
|
||||
'assets/isolate_snapshot_data',
|
||||
'assets/isolate_snapshot_instr',
|
||||
'assets/flutter_assets/isolate_snapshot_data',
|
||||
];
|
||||
|
||||
int baselineChecksum = 0;
|
||||
for (String fn in checksumFiles) {
|
||||
final ArchiveFile oldFile = oldApk.findFile(fn);
|
||||
if (oldFile != null)
|
||||
baselineChecksum = getCrc32(oldFile.content, baselineChecksum);
|
||||
}
|
||||
if (baselineChecksum == 0)
|
||||
throwToolExit('Error: Could not find baseline VM snapshot.');
|
||||
|
||||
final int baselineChecksum = getCrc32(oldFile.content);
|
||||
final Map<String, dynamic> manifest = <String, dynamic>{
|
||||
'baselineChecksum': baselineChecksum,
|
||||
'buildNumber': package.versionCode,
|
||||
|
||||
@@ -440,6 +440,15 @@ class JITSnapshotter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
final ArchiveFile af = baselinePkg.findFile(
|
||||
fs.path.join('assets/flutter_assets/vm_snapshot_instr'));
|
||||
if (af != null) {
|
||||
printError('Error: Invalid baseline package ${baselineApk.path}.');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d');
|
||||
|
||||
@@ -229,9 +229,7 @@ class UserMessages {
|
||||
'https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/pubspec.yaml\n';
|
||||
String flutterTargetFileMissing(String path) => 'Target file "$path" not found.';
|
||||
String get flutterBasePatchFlagsExclusive => 'Error: Only one of --baseline, --patch is allowed.';
|
||||
String get flutterBaselineRequiresDynamic => 'Error: --baseline is allowed only when --dynamic is specified.';
|
||||
String get flutterBaselineRequiresTraceFile => 'Error: --baseline requires --compilation-trace-file to be specified.';
|
||||
String get flutterPatchRequiresDynamic => 'Error: --patch is allowed only when --dynamic is specified.';
|
||||
String get flutterPatchRequiresTraceFile => 'Error: --patch requires --compilation-trace-file to be specified.';
|
||||
|
||||
// Messages used in FlutterCommandRunner
|
||||
|
||||
@@ -647,8 +647,6 @@ abstract class FlutterCommand extends Command<void> {
|
||||
throw ToolExit(userMessages.flutterTargetFileMissing(targetPath));
|
||||
}
|
||||
|
||||
final bool dynamicFlag = argParser.options.containsKey('dynamic')
|
||||
? argResults['dynamic'] : false;
|
||||
final String compilationTraceFilePath = argParser.options.containsKey('compilation-trace-file')
|
||||
? argResults['compilation-trace-file'] : null;
|
||||
final bool createBaseline = argParser.options.containsKey('baseline')
|
||||
@@ -658,12 +656,8 @@ abstract class FlutterCommand extends Command<void> {
|
||||
|
||||
if (createBaseline && createPatch)
|
||||
throw ToolExit(userMessages.flutterBasePatchFlagsExclusive);
|
||||
if (createBaseline && !dynamicFlag)
|
||||
throw ToolExit(userMessages.flutterBaselineRequiresDynamic);
|
||||
if (createBaseline && compilationTraceFilePath == null)
|
||||
throw ToolExit(userMessages.flutterBaselineRequiresTraceFile);
|
||||
if (createPatch && !dynamicFlag)
|
||||
throw ToolExit(userMessages.flutterPatchRequiresDynamic);
|
||||
if (createPatch && compilationTraceFilePath == null)
|
||||
throw ToolExit(userMessages.flutterPatchRequiresTraceFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user