Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use new linker pipeline on iOS #1810

Merged
merged 8 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,20 @@ ${summary.join('\n')}
return ExitCode.software.code;
}

final genSnapshot = shorebirdArtifacts.getArtifactPath(
artifact: ShorebirdArtifact.genSnapshot,
);

final linkProgress = logger.progress('Linking AOT files');
try {
await aotTools.link(
base: releaseArtifact.path,
patch: patch.path,
analyzeSnapshot: analyzeSnapshot.path,
genSnapshot: genSnapshot,
outputPath: _vmcodeOutputPath,
workingDirectory: _buildDirectory,
kernel: newestAppDill().path,
);
} catch (error) {
linkProgress.fail('Failed to link AOT files: $error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,18 @@ ${summary.join('\n')}
return ExitCode.software.code;
}

final genSnapshot = shorebirdArtifacts.getArtifactPath(
artifact: ShorebirdArtifact.genSnapshot,
);

final linkProgress = logger.progress('Linking AOT files');
try {
await aotTools.link(
base: releaseArtifact.path,
patch: aotSnapshot.path,
analyzeSnapshot: analyzeSnapshot.path,
genSnapshot: genSnapshot,
kernel: newestAppDill().path,
outputPath: _vmcodeOutputPath,
workingDirectory: _buildDirectory,
);
Expand Down
21 changes: 21 additions & 0 deletions packages/shorebird_cli/lib/src/executables/aot_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import 'package:mason_logger/mason_logger.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:scoped/scoped.dart';
import 'package:shorebird_cli/src/cache.dart';
import 'package:shorebird_cli/src/extensions/version.dart';
import 'package:shorebird_cli/src/engine_config.dart';
import 'package:shorebird_cli/src/shorebird_artifacts.dart';
import 'package:shorebird_cli/src/shorebird_env.dart';
Expand Down Expand Up @@ -109,20 +111,39 @@
);
}

Future<bool> _linkerUsesGenSnapshot() async {
final version = await _getVersion();
return version != null && version >= Version(0, 0, 1);

Check warning on line 116 in packages/shorebird_cli/lib/src/executables/aot_tools.dart

View check run for this annotation

Codecov / codecov/patch

packages/shorebird_cli/lib/src/executables/aot_tools.dart#L116

Added line #L116 was not covered by tests
}

Future<Version?> _getVersion() async {
final result = await _exec(['--version']);
if (result.exitCode != ExitCode.success.code) {
return null;
}
final version = result.stdout.toString().trim();
return tryParseVersion(version);
}

/// Generate a link vmcode file from two AOT snapshots.
Future<void> link({
required String base,
required String patch,
required String analyzeSnapshot,
required String genSnapshot,
required String kernel,
required String outputPath,
String? workingDirectory,
}) async {
final linkerUsesGenSnapshot = await _linkerUsesGenSnapshot();
final result = await _exec(
[
'link',
'--base=$base',
'--patch=$patch',
'--analyze-snapshot=$analyzeSnapshot',
if (linkerUsesGenSnapshot) '--gen-snapshot=$genSnapshot',
if (linkerUsesGenSnapshot) '--kernel=$kernel',

Check warning on line 146 in packages/shorebird_cli/lib/src/executables/aot_tools.dart

View check run for this annotation

Codecov / codecov/patch

packages/shorebird_cli/lib/src/executables/aot_tools.dart#L145-L146

Added lines #L145 - L146 were not covered by tests
'--output=$outputPath',
],
workingDirectory: workingDirectory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ flutter:
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -819,6 +821,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -1142,6 +1146,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -1175,6 +1181,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand All @@ -1189,6 +1197,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -1235,6 +1245,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ flutter:
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -589,6 +591,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -1011,6 +1015,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand All @@ -1025,6 +1031,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down Expand Up @@ -1071,6 +1079,8 @@ Please re-run the release command for this version or create a new release.'''),
base: any(named: 'base'),
patch: any(named: 'patch'),
analyzeSnapshot: any(named: 'analyzeSnapshot'),
genSnapshot: any(named: 'genSnapshot'),
kernel: any(named: 'kernel'),
workingDirectory: any(named: 'workingDirectory'),
outputPath: any(named: 'outputPath'),
),
Expand Down
12 changes: 11 additions & 1 deletion packages/shorebird_cli/test/src/executables/aot_tools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ void main() {
group('link', () {
const base = './path/to/base.aot';
const patch = './path/to/patch.aot';
const analyzeSnapshot = './path/to/analyze_snapshot.aot';
const analyzeSnapshot = './path/to/analyze_snapshot';
const genSnapshot = './path/to/gen_snapshot';
const kernel = './path/to/kernel.dill';
const outputPath = './path/to/out.vmcode';

test('throws Exception when process exits with non-zero code', () async {
Expand Down Expand Up @@ -83,6 +85,8 @@ void main() {
base: base,
patch: patch,
analyzeSnapshot: analyzeSnapshot,
genSnapshot: genSnapshot,
kernel: kernel,
outputPath: outputPath,
),
),
Expand Down Expand Up @@ -127,6 +131,8 @@ void main() {
base: base,
patch: patch,
analyzeSnapshot: analyzeSnapshot,
genSnapshot: genSnapshot,
kernel: kernel,
workingDirectory: workingDirectory.path,
outputPath: outputPath,
),
Expand Down Expand Up @@ -180,6 +186,8 @@ void main() {
base: base,
patch: patch,
analyzeSnapshot: analyzeSnapshot,
genSnapshot: genSnapshot,
kernel: kernel,
workingDirectory: workingDirectory.path,
outputPath: outputPath,
),
Expand Down Expand Up @@ -235,6 +243,8 @@ void main() {
base: base,
patch: patch,
analyzeSnapshot: analyzeSnapshot,
genSnapshot: genSnapshot,
kernel: kernel,
workingDirectory: workingDirectory.path,
outputPath: outputPath,
),
Expand Down
Loading