From c69188ad9fd79515a688525a675b87ddcd03ca00 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 13 Feb 2018 14:00:34 -0800 Subject: [PATCH] Add output path option (flutter/engine#4663) --- .../flutter/frontend_server/lib/server.dart | 14 +++++++-- .../frontend_server/test/server_test.dart | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/frontend_server/lib/server.dart b/engine/src/flutter/frontend_server/lib/server.dart index f3896f58fc..bf67921731 100644 --- a/engine/src/flutter/frontend_server/lib/server.dart +++ b/engine/src/flutter/frontend_server/lib/server.dart @@ -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'); diff --git a/engine/src/flutter/frontend_server/test/server_test.dart b/engine/src/flutter/frontend_server/test/server_test.dart index b845d24468..55ee1771b9 100644 --- a/engine/src/flutter/frontend_server/test/server_test.dart +++ b/engine/src/flutter/frontend_server/test/server_test.dart @@ -368,6 +368,36 @@ Future main() async { streamController.close(); }); + group('compile with output path', () + { + final CompilerInterface compiler = new _MockedCompiler(); + + test('compile from command line', () async { + final List args = [ + '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 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; }