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