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, exit, exitCode; | 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/patched_sdk_location.dart' | 13 import 'testing/patched_sdk_location.dart' |
14 show computeDartVm, computePatchedSdk; | 14 show computeDartVm, computePatchedSdk; |
15 | 15 |
16 import 'compiler_context.dart' show CompilerContext; | 16 import 'compiler_context.dart' show CompilerContext; |
17 | 17 |
18 import 'compiler_command_line.dart' show CompilerCommandLine; | 18 import 'compiler_command_line.dart' show CompilerCommandLine; |
19 | 19 |
20 import 'fasta.dart' show CompileTask; | 20 import 'fasta.dart' show CompileTask; |
21 | 21 |
22 import 'deprecated_problems.dart' show deprecated_InputError; | 22 import 'deprecated_problems.dart' show deprecated_InputError; |
23 | 23 |
| 24 import 'severity.dart' show Severity; |
| 25 |
24 import 'ticker.dart' show Ticker; | 26 import 'ticker.dart' show Ticker; |
25 | 27 |
26 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | 28 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
27 | 29 |
28 mainEntryPoint(List<String> arguments) async { | 30 mainEntryPoint(List<String> arguments) async { |
29 Uri uri; | 31 Uri uri; |
30 for (int i = 0; i < iterations; i++) { | 32 for (int i = 0; i < iterations; i++) { |
31 await CompilerCommandLine.withGlobalOptions("run", arguments, | 33 await CompilerCommandLine.withGlobalOptions("run", arguments, |
32 (CompilerContext c) async { | 34 (CompilerContext c) async { |
33 if (i > 0) { | 35 if (i > 0) { |
34 print("\n"); | 36 print("\n"); |
35 } | 37 } |
36 try { | 38 try { |
37 CompileTask task = | 39 CompileTask task = |
38 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); | 40 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); |
39 uri = await task.compile(); | 41 uri = await task.compile(); |
40 } on deprecated_InputError catch (e) { | 42 } on deprecated_InputError catch (e) { |
41 print(e.deprecated_format()); | 43 CompilerContext.current |
| 44 .report(deprecated_InputError.toMessage(e), Severity.error); |
42 exit(1); | 45 exit(1); |
43 } | 46 } |
44 if (exitCode != 0) exit(exitCode); | 47 if (exitCode != 0) exit(exitCode); |
45 if (i + 1 == iterations) { | 48 if (i + 1 == iterations) { |
46 exit(await run(uri, c)); | 49 exit(await run(uri, c)); |
47 } | 50 } |
48 }); | 51 }); |
49 } | 52 } |
50 } | 53 } |
51 | 54 |
52 Future<int> run(Uri uri, CompilerContext c) async { | 55 Future<int> run(Uri uri, CompilerContext c) async { |
53 Uri sdk = await computePatchedSdk(); | 56 Uri sdk = await computePatchedSdk(); |
54 Uri dartVm = computeDartVm(sdk); | 57 Uri dartVm = computeDartVm(sdk); |
55 List<String> arguments = <String>["${uri.toFilePath()}"] | 58 List<String> arguments = <String>["${uri.toFilePath()}"] |
56 ..addAll(c.options.arguments.skip(1)); | 59 ..addAll(c.options.arguments.skip(1)); |
57 if (c.options.verbose) { | 60 if (c.options.verbose) { |
58 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); | 61 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); |
59 } | 62 } |
60 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); | 63 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); |
61 stdout.write(result.output); | 64 stdout.write(result.output); |
62 return result.exitCode; | 65 return result.exitCode; |
63 } | 66 } |
OLD | NEW |