feat: add support for dispatch table supplement files (#3081)
This commit is contained in:
@@ -1 +1 @@
|
||||
0ac69de92c7201830d6a687a44fa0d34f6003f90
|
||||
7c1c25e48e6dd849c3264588346aa63652d5e426
|
||||
|
||||
@@ -135,7 +135,7 @@ class Apple {
|
||||
/// patch builds. Both times it produces supplement files in a directory.
|
||||
/// In the release case, these files are zipped up and stored as an artifact
|
||||
/// on our servers for later use. In the patch case, they were created on
|
||||
/// disk just before this call.
|
||||
/// disk just before this call by XCode calling flutter calling gen_snapshot.
|
||||
/// In both cases we need to copy the supplement files from these directories
|
||||
/// to right next to where the snapshot files are before calling into
|
||||
/// `aot_tools` to link the two snapshots together.
|
||||
@@ -153,13 +153,19 @@ class Apple {
|
||||
'App.class_table.json',
|
||||
'App.ft.link',
|
||||
'App.field_table.json',
|
||||
'App.dt.link',
|
||||
'App.dispatch_table.json',
|
||||
];
|
||||
|
||||
// This uses maybeCopy because not all versions of gen_snapshot/aot_tools
|
||||
// use the same supplement files. At the `shorebird` level we don't know
|
||||
// which files should be present, so we just try to copy all.
|
||||
void maybeCopy(File file, Directory destDir, {String? newBaseName}) {
|
||||
if (!file.existsSync()) return;
|
||||
logger.detail('Copying supplement file ${file.path} to ${destDir.path}');
|
||||
if (!file.existsSync()) {
|
||||
logger.detail('Unable to find supplement file at ${file.path}');
|
||||
return;
|
||||
}
|
||||
final baseName = p.basename(file.path);
|
||||
final destName =
|
||||
newBaseName != null
|
||||
|
||||
@@ -103,8 +103,10 @@ To add macOS, run "flutter create . --platforms macos"''');
|
||||
test('copies all files next to snapshots', () {
|
||||
final names = [
|
||||
'App.class_table.json',
|
||||
'App.dispatch_table.json',
|
||||
'App.field_table.json',
|
||||
'App.ct.link',
|
||||
'App.dt.link',
|
||||
'App.ft.link',
|
||||
];
|
||||
|
||||
@@ -121,14 +123,16 @@ To add macOS, run "flutter create . --platforms macos"''');
|
||||
|
||||
final releaseSnapshotDir = Directory.systemTemp.createTempSync();
|
||||
final patchSnapshotDir = Directory.systemTemp.createTempSync();
|
||||
apple.copySupplementFilesToSnapshotDirs(
|
||||
releaseSupplementDir: releaseSupplementDir,
|
||||
releaseSnapshotDir: releaseSnapshotDir,
|
||||
patchSupplementDir: patchSupplementDir,
|
||||
patchSnapshotDir: patchSnapshotDir,
|
||||
runWithOverrides(
|
||||
() => apple.copySupplementFilesToSnapshotDirs(
|
||||
releaseSupplementDir: releaseSupplementDir,
|
||||
releaseSnapshotDir: releaseSnapshotDir,
|
||||
patchSupplementDir: patchSupplementDir,
|
||||
patchSnapshotDir: patchSnapshotDir,
|
||||
),
|
||||
);
|
||||
expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(4));
|
||||
expect(Directory(patchSnapshotDir.path).listSync(), hasLength(4));
|
||||
expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(6));
|
||||
expect(Directory(patchSnapshotDir.path).listSync(), hasLength(6));
|
||||
});
|
||||
|
||||
test('copies only some files next to snapshots', () {
|
||||
@@ -147,14 +151,37 @@ To add macOS, run "flutter create . --platforms macos"''');
|
||||
|
||||
final releaseSnapshotDir = Directory.systemTemp.createTempSync();
|
||||
final patchSnapshotDir = Directory.systemTemp.createTempSync();
|
||||
apple.copySupplementFilesToSnapshotDirs(
|
||||
releaseSupplementDir: releaseSupplementDir,
|
||||
releaseSnapshotDir: releaseSnapshotDir,
|
||||
patchSupplementDir: patchSupplementDir,
|
||||
patchSnapshotDir: patchSnapshotDir,
|
||||
runWithOverrides(
|
||||
() => apple.copySupplementFilesToSnapshotDirs(
|
||||
releaseSupplementDir: releaseSupplementDir,
|
||||
releaseSnapshotDir: releaseSnapshotDir,
|
||||
patchSupplementDir: patchSupplementDir,
|
||||
patchSnapshotDir: patchSnapshotDir,
|
||||
),
|
||||
);
|
||||
expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(2));
|
||||
expect(Directory(patchSnapshotDir.path).listSync(), hasLength(2));
|
||||
|
||||
// Logs when copying files.
|
||||
final classTableFilePath = p.join(
|
||||
releaseSupplementDir.path,
|
||||
'App.class_table.json',
|
||||
);
|
||||
verify(
|
||||
() => logger.detail(
|
||||
'Copying supplement file $classTableFilePath to ${releaseSnapshotDir.path}',
|
||||
),
|
||||
).called(1);
|
||||
// Logs about missing files
|
||||
final dispatchTableFilePath = p.join(
|
||||
releaseSupplementDir.path,
|
||||
'App.dispatch_table.json',
|
||||
);
|
||||
verify(
|
||||
() => logger.detail(
|
||||
'Unable to find supplement file at $dispatchTableFilePath',
|
||||
),
|
||||
).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user