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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 import 'severity.dart' show Severity; | 24 import 'severity.dart' show Severity; |
25 | 25 |
26 import 'ticker.dart' show Ticker; | 26 import 'ticker.dart' show Ticker; |
27 | 27 |
28 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | 28 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
29 | 29 |
30 mainEntryPoint(List<String> arguments) async { | 30 mainEntryPoint(List<String> arguments) async { |
31 Uri uri; | 31 Uri uri; |
32 for (int i = 0; i < iterations; i++) { | 32 for (int i = 0; i < iterations; i++) { |
33 await CompilerCommandLine.withGlobalOptions("run", arguments, | 33 await CompilerCommandLine.withGlobalOptions("run", arguments, false, |
34 (CompilerContext c) async { | 34 (CompilerContext c, List<String> restArguments) async { |
| 35 var input = Uri.base.resolve(restArguments[0]); |
| 36 c.options.inputs.add(input); |
35 if (i > 0) { | 37 if (i > 0) { |
36 print("\n"); | 38 print("\n"); |
37 } | 39 } |
38 try { | 40 try { |
39 CompileTask task = | 41 CompileTask task = |
40 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); | 42 new CompileTask(c, new Ticker(isVerbose: c.options.verbose)); |
41 uri = await task.compile(); | 43 uri = await task.compile(); |
42 } on deprecated_InputError catch (e) { | 44 } on deprecated_InputError catch (e) { |
43 CompilerContext.current | 45 CompilerContext.current |
44 .report(deprecated_InputError.toMessage(e), Severity.error); | 46 .report(deprecated_InputError.toMessage(e), Severity.error); |
45 exit(1); | 47 exit(1); |
46 } | 48 } |
47 if (exitCode != 0) exit(exitCode); | 49 if (exitCode != 0) exit(exitCode); |
48 if (i + 1 == iterations) { | 50 if (i + 1 == iterations) { |
49 exit(await run(uri, c)); | 51 exit(await run(uri, c, restArguments)); |
50 } | 52 } |
51 }); | 53 }); |
52 } | 54 } |
53 } | 55 } |
54 | 56 |
55 Future<int> run(Uri uri, CompilerContext c) async { | 57 Future<int> run(Uri uri, CompilerContext c, List<String> allArguments) async { |
56 Uri sdk = await computePatchedSdk(); | 58 Uri sdk = await computePatchedSdk(); |
57 Uri dartVm = computeDartVm(sdk); | 59 Uri dartVm = computeDartVm(sdk); |
58 List<String> arguments = <String>["${uri.toFilePath()}"] | 60 List<String> arguments = <String>["${uri.toFilePath()}"] |
59 ..addAll(c.options.arguments.skip(1)); | 61 ..addAll(allArguments.skip(1)); |
60 if (c.options.verbose) { | 62 if (c.options.verbose) { |
61 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); | 63 print("Running ${dartVm.toFilePath()} ${arguments.join(' ')}"); |
62 } | 64 } |
63 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); | 65 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), arguments); |
64 stdout.write(result.output); | 66 stdout.write(result.output); |
65 return result.exitCode; | 67 return result.exitCode; |
66 } | 68 } |
OLD | NEW |