OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fasta.run; | 5 library fasta.run; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'dart:io' show stdout; | 9 import 'dart:io' show stdout, exit, exitCode; |
10 | 10 |
11 import 'package:testing/testing.dart' show StdioProcess; | 11 import 'package:testing/testing.dart' show StdioProcess; |
12 | 12 |
13 import 'testing/kernel_chain.dart' show computeDartVm, computePatchedSdk; | 13 import 'testing/kernel_chain.dart' show computeDartVm, computePatchedSdk; |
14 | 14 |
15 import 'compiler_context.dart' show CompilerContext; | 15 import 'compiler_context.dart' show CompilerContext; |
16 | 16 |
| 17 import 'compiler_command_line.dart' show CompilerCommandLine; |
| 18 |
| 19 import 'outline.dart' show CompileTask; |
| 20 |
| 21 import 'errors.dart' show InputError; |
| 22 |
| 23 import 'ticker.dart' show Ticker; |
| 24 |
| 25 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
| 26 |
| 27 mainEntryPoint(List<String> arguments) async { |
| 28 Uri uri; |
| 29 for (int i = 0; i < iterations; i++) { |
| 30 await CompilerCommandLine.withGlobalOptions("run", arguments, |
| 31 (CompilerContext c) async { |
| 32 if (i > 0) { |
| 33 print("\n"); |
| 34 } |
| 35 try { |
| 36 CompileTask task = |
| 37 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); |
| 38 uri = await task.compile(); |
| 39 } on InputError catch (e) { |
| 40 print(e.format()); |
| 41 exit(1); |
| 42 } |
| 43 if (exitCode != 0) exit(exitCode); |
| 44 if (i + 1 == iterations) { |
| 45 exit(await run(uri, c)); |
| 46 } |
| 47 }); |
| 48 } |
| 49 } |
| 50 |
17 Future<int> run(Uri uri, CompilerContext c) async { | 51 Future<int> run(Uri uri, CompilerContext c) async { |
18 Uri sdk = await computePatchedSdk(); | 52 Uri sdk = await computePatchedSdk(); |
19 Uri dartVm = computeDartVm(sdk); | 53 Uri dartVm = computeDartVm(sdk); |
20 List<String> arguments = <String>["${uri.toFilePath()}"] | 54 List<String> arguments = <String>["${uri.toFilePath()}"] |
21 ..addAll(c.options.arguments.skip(1)); | 55 ..addAll(c.options.arguments.skip(1)); |
22 if (c.options.verbose) { | 56 if (c.options.verbose) { |
23 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); | 57 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); |
24 } | 58 } |
25 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); | 59 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); |
26 stdout.write(result.output); | 60 stdout.write(result.output); |
27 return result.exitCode; | 61 return result.exitCode; |
28 } | 62 } |
OLD | NEW |