Skip to content

Commit

Permalink
Add an option to link platform.dill into app kernel file (flutter#4204)
Browse files Browse the repository at this point in the history
  • Loading branch information
aam authored Oct 12, 2017
1 parent f737d49 commit 11cac67
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 15 additions & 6 deletions frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
..addOption('byte-store',
help: 'Path to file byte store used to keep incremental compiler state.'
' If omitted, then memory byte store is used.',
defaultsTo: null);
defaultsTo: null)
..addFlag('link-platform',
help: 'When in batch mode, link platform kernel file into result kernel file.'
' Intended use is to satisfy different loading strategies implemented'
' by gen_snapshot(which needs platform embedded) vs'
' Flutter engine(which does not)',
defaultsTo: true);


String _usage = '''
Usage: server [options] [input.dart]
Expand Down Expand Up @@ -156,11 +163,13 @@ class _FrontendCompiler implements CompilerInterface {
final DeltaProgram deltaProgram = await _generator.computeDelta();
program = deltaProgram.newProgram;
} else {
// TODO(aam): Remove linkedDependencies once platform is directly embedded
// into VM snapshot and http://dartbug.com/30111 is fixed.
compilerOptions.linkedDependencies = <Uri>[
sdkRoot.resolve('platform.dill')
];
if (options['link-platform']) {
// TODO(aam): Remove linkedDependencies once platform is directly embedded
// into VM snapshot and http://dartbug.com/30111 is fixed.
compilerOptions.linkedDependencies = <Uri>[
sdkRoot.resolve('platform.dill')
];
}
program = await kernelForProgram(Uri.base.resolve(_filename), compilerOptions);
}
if (program != null) {
Expand Down
21 changes: 21 additions & 0 deletions frontend_server/test/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ Future<int> main() async {
expect(capturedArgs.single['sdk-root'], equals('sdkroot'));
expect(capturedArgs.single['byte-store'], equals('path/to/bytestore'));
});

test('compile from command line with link platform', () async {
final List<String> args = <String>[
'server.dart',
'--sdk-root',
'sdkroot',
'--link-platform',
];
final int exitcode = await starter(args, compiler: compiler);
expect(exitcode, equals(0));
final List<ArgResults> capturedArgs =
verify(
compiler.compile(
argThat(equals('server.dart')),
captureAny,
generator: any,
)
).captured;
expect(capturedArgs.single['sdk-root'], equals('sdkroot'));
expect(capturedArgs.single['link-platform'], equals(true));
});
});

group('interactive file store compile with mocked compiler', () {
Expand Down

0 comments on commit 11cac67

Please sign in to comment.