Add output path option (flutter/engine#4663)

This commit is contained in:
Alexander Aprelev
2018-02-13 14:00:34 -08:00
committed by GitHub
parent a98c9a16a6
commit c69188ad9f
2 changed files with 42 additions and 2 deletions

View File

@@ -50,6 +50,12 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
' by gen_snapshot(which needs platform embedded) vs'
' Flutter engine(which does not)',
defaultsTo: true)
..addOption('output-dill',
help: 'Output path for the generated dill',
defaultsTo: null)
..addOption('output-incremental-dill',
help: 'Output path for the generated incremental dill',
defaultsTo: null)
..addOption('packages',
help: '.packages file to use for compilation',
defaultsTo: null)
@@ -152,8 +158,12 @@ class _FrontendCompiler implements CompilerInterface {
IncrementalCompiler generator,
}) async {
final Uri filenameUri = Uri.base.resolveUri(new Uri.file(filename));
_kernelBinaryFilenameFull = '$filename.dill';
_kernelBinaryFilenameIncremental = '$filename.incremental.dill';
_kernelBinaryFilenameFull = options['output-dill'] ?? '$filename.dill';
_kernelBinaryFilenameIncremental =
options['output-incremental-dill'] ??
options['output-dill'] != null
? '${options["output-dill"]}.incremental.dill'
: '$filename.incremental.dill';
_kernelBinaryFilename = _kernelBinaryFilenameFull;
final String boundaryKey = new Uuid().generateV4();
_outputStream.writeln('result $boundaryKey');

View File

@@ -368,6 +368,36 @@ Future<int> main() async {
streamController.close();
});
group('compile with output path', ()
{
final CompilerInterface compiler = new _MockedCompiler();
test('compile from command line', () async {
final List<String> args = <String>[
'server.dart',
'--sdk-root',
'sdkroot',
'--output-dill',
'/foo/bar/server.dart.dill',
'--output-incremental-dill',
'/foo/bar/server.incremental.dart.dill',
];
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['strong'], equals(false));
});
});
});
return 0;
}