| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /// Command line entry point for Dart Development Compiler (dartdevc). | 6 /// Command line entry point for Dart Development Compiler (dartdevc). |
| 7 /// | 7 /// |
| 8 /// Supported commands are | 8 /// Supported commands are |
| 9 /// * compile: builds a collection of dart libraries into a single JS module | 9 /// * compile: builds a collection of dart libraries into a single JS module |
| 10 /// | 10 /// |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 import 'package:bazel_worker/bazel_worker.dart'; | 43 import 'package:bazel_worker/bazel_worker.dart'; |
| 44 import 'package:dev_compiler/src/compiler/command.dart'; | 44 import 'package:dev_compiler/src/compiler/command.dart'; |
| 45 | 45 |
| 46 Future main(List<String> args) async { | 46 Future main(List<String> args) async { |
| 47 // Always returns a new modifiable list. | 47 // Always returns a new modifiable list. |
| 48 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args); | 48 args = preprocessArgs(PhysicalResourceProvider.INSTANCE, args); |
| 49 | 49 |
| 50 if (args.contains('--persistent_worker')) { | 50 if (args.contains('--persistent_worker')) { |
| 51 new _CompilerWorker(args..remove('--persistent_worker')).run(); | 51 new _CompilerWorker(args..remove('--persistent_worker')).run(); |
| 52 } else { | 52 } else { |
| 53 exitCode = compile(args); | 53 exitCode = await compile(args); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 /// Runs the compiler worker loop. | 57 /// Runs the compiler worker loop. |
| 58 class _CompilerWorker extends AsyncWorkerLoop { | 58 class _CompilerWorker extends AsyncWorkerLoop { |
| 59 /// The original args supplied to the executable. | 59 /// The original args supplied to the executable. |
| 60 final List<String> _startupArgs; | 60 final List<String> _startupArgs; |
| 61 | 61 |
| 62 _CompilerWorker(this._startupArgs) : super(); | 62 _CompilerWorker(this._startupArgs) : super(); |
| 63 | 63 |
| 64 /// Performs each individual work request. | 64 /// Performs each individual work request. |
| 65 Future<WorkResponse> performRequest(WorkRequest request) async { | 65 Future<WorkResponse> performRequest(WorkRequest request) async { |
| 66 var args = _startupArgs.toList()..addAll(request.arguments); | 66 var args = _startupArgs.toList()..addAll(request.arguments); |
| 67 | 67 |
| 68 var output = new StringBuffer(); | 68 var output = new StringBuffer(); |
| 69 var exitCode = compile(args, printFn: output.writeln); | 69 var exitCode = await compile(args, printFn: output.writeln); |
| 70 AnalysisEngine.instance.clearCaches(); | 70 AnalysisEngine.instance.clearCaches(); |
| 71 return new WorkResponse() | 71 return new WorkResponse() |
| 72 ..exitCode = exitCode | 72 ..exitCode = exitCode |
| 73 ..output = output.toString(); | 73 ..output = output.toString(); |
| 74 } | 74 } |
| 75 } | 75 } |
| OLD | NEW |