From 391d63e1c195d0d83b46e0e2d0a142cc943ef11a Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Tue, 16 Jan 2018 19:41:57 -0800 Subject: [PATCH 1/4] Support .packages option in frontend_server, bundle_path in main_mac. This is needed to be able to run in mode. --- frontend_server/lib/server.dart | 14 +++++--------- shell/platform/darwin/desktop/main_mac.mm | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/frontend_server/lib/server.dart b/frontend_server/lib/server.dart index 3fce388e3d059..458fb88d845c7 100644 --- a/frontend_server/lib/server.dart +++ b/frontend_server/lib/server.dart @@ -32,10 +32,6 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true) ..addOption('sdk-root', help: 'Path to sdk root', defaultsTo: '../../out/android_debug/flutter_patched_sdk') - ..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) ..addFlag('aot', help: 'Run compiler in AOT mode (enables whole-program transformations)', defaultsTo: false) @@ -48,7 +44,10 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true) ' Intended use is to satisfy different loading strategies implemented' ' by gen_snapshot(which needs platform embedded) vs' ' Flutter engine(which does not)', - defaultsTo: true); + defaultsTo: true) + ..addOption('packages', + help: '.packages file to use for compilation', + defaultsTo: '.packages'); String _usage = ''' Usage: server [options] [input.dart] @@ -144,12 +143,9 @@ class _FrontendCompiler implements CompilerInterface { final String boundaryKey = new Uuid().generateV4(); _outputStream.writeln("result $boundaryKey"); final Uri sdkRoot = _ensureFolderPath(options['sdk-root']); - final String byteStorePath = options['byte-store']; final CompilerOptions compilerOptions = new CompilerOptions() - ..byteStore = byteStorePath != null - ? new FileByteStore(byteStorePath) - : new MemoryByteStore() ..sdkRoot = sdkRoot + ..packagesFileUri = options['packages'] != null ? Uri.base.resolveUri(new Uri.file(options['packages'])) : null ..strongMode = options['strong'] ..target = new FlutterTarget(new TargetFlags(strongMode: options['strong'])) ..reportMessages = true; diff --git a/shell/platform/darwin/desktop/main_mac.mm b/shell/platform/darwin/desktop/main_mac.mm index c8fd14326a40b..bfe016e30e688 100644 --- a/shell/platform/darwin/desktop/main_mac.mm +++ b/shell/platform/darwin/desktop/main_mac.mm @@ -12,13 +12,31 @@ #include "flutter/shell/platform/darwin/common/platform_mac.h" #include "flutter/shell/platform/darwin/desktop/flutter_application.h" #include "flutter/shell/testing/testing.h" +#include "lib/fxl/logging.h" +#include "lib/fxl/command_line.h" + + +static fxl::CommandLine InitializedCommandLine() { + std::vector args_vector; + + for (NSString* arg in [NSProcessInfo processInfo].arguments) { + args_vector.emplace_back(arg.UTF8String); + } + + return fxl::CommandLineFromIterators(args_vector.begin(), args_vector.end()); +} int main(int argc, const char* argv[]) { [FlutterApplication sharedApplication]; - shell::PlatformMacMain("", "", ""); + // Can't use shell::Shell::Shared().GetCommandLine() because it is initialized only + // in shell::PlatformMacMain call below. + auto command_line = InitializedCommandLine(); + + std::string bundle_path = ""; + command_line.GetOptionValue(FlagForSwitch(shell::Switch::FlutterAssetsDir), &bundle_path); - const auto& command_line = shell::Shell::Shared().GetCommandLine(); + shell::PlatformMacMain("", "", bundle_path); // Print help. if (command_line.HasOption(shell::FlagForSwitch(shell::Switch::Help))) { From ecaf29337d02bf4839030f8b44b82d5b8155db04 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 17 Jan 2018 09:07:13 -0800 Subject: [PATCH 2/4] Remove byte store tests --- frontend_server/test/server_test.dart | 29 +-------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/frontend_server/test/server_test.dart b/frontend_server/test/server_test.dart index 1d2d215905b44..cb18a302309fc 100644 --- a/frontend_server/test/server_test.dart +++ b/frontend_server/test/server_test.dart @@ -75,29 +75,6 @@ Future main() async { expect(capturedArgs.single['strong'], equals(true)); }); - test('compile from command line with file byte store', () async { - final List args = [ - 'server.dart', - '--sdk-root', - 'sdkroot', - '--byte-store', - 'path/to/bytestore' - ]; - 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['byte-store'], equals('path/to/bytestore')); - expect(capturedArgs.single['strong'], equals(false)); - }); - test('compile from command line with link platform', () async { final List args = [ 'server.dart', @@ -121,14 +98,12 @@ Future main() async { }); }); - group('interactive file store compile with mocked compiler', () { + group('interactive compile with mocked compiler', () { final CompilerInterface compiler = new _MockedCompiler(); final List args = [ '--sdk-root', 'sdkroot', - '--byte-store', - 'path/to/bytestore', ]; test('compile one file', () async { @@ -140,8 +115,6 @@ Future main() async { expect(invocation.positionalArguments[0], equals('server.dart')); expect(invocation.positionalArguments[1]['sdk-root'], equals('sdkroot')); - expect(invocation.positionalArguments[1]['byte-store'], - equals('path/to/bytestore')); expect(invocation.positionalArguments[1]['strong'], equals(false)); compileCalled.sendPort.send(true); } From 943acbefb1ffa3d4cbda1ddab2ba94ed4b19a7bf Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 17 Jan 2018 09:18:39 -0800 Subject: [PATCH 3/4] Remove unused import --- frontend_server/lib/server.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend_server/lib/server.dart b/frontend_server/lib/server.dart index 458fb88d845c7..2a168ac212510 100644 --- a/frontend_server/lib/server.dart +++ b/frontend_server/lib/server.dart @@ -11,7 +11,6 @@ import 'package:args/args.dart'; // that would replace api used below. This api was made private in // an effort to discourage further use. // ignore_for_file: implementation_imports -import 'package:front_end/src/api_prototype/byte_store.dart'; import 'package:front_end/src/api_prototype/compiler_options.dart'; import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'; From 0f67840521f9ee2a157e606e842d29ba6130195e Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 17 Jan 2018 09:33:15 -0800 Subject: [PATCH 4/4] Fix formatting --- shell/platform/darwin/desktop/main_mac.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/platform/darwin/desktop/main_mac.mm b/shell/platform/darwin/desktop/main_mac.mm index bfe016e30e688..8087d0e92cd6d 100644 --- a/shell/platform/darwin/desktop/main_mac.mm +++ b/shell/platform/darwin/desktop/main_mac.mm @@ -12,18 +12,17 @@ #include "flutter/shell/platform/darwin/common/platform_mac.h" #include "flutter/shell/platform/darwin/desktop/flutter_application.h" #include "flutter/shell/testing/testing.h" -#include "lib/fxl/logging.h" #include "lib/fxl/command_line.h" - +#include "lib/fxl/logging.h" static fxl::CommandLine InitializedCommandLine() { - std::vector args_vector; + std::vector args_vector; - for (NSString* arg in [NSProcessInfo processInfo].arguments) { - args_vector.emplace_back(arg.UTF8String); - } + for (NSString* arg in [NSProcessInfo processInfo].arguments) { + args_vector.emplace_back(arg.UTF8String); + } - return fxl::CommandLineFromIterators(args_vector.begin(), args_vector.end()); + return fxl::CommandLineFromIterators(args_vector.begin(), args_vector.end()); } int main(int argc, const char* argv[]) {