Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: pkg/front_end/lib/src/fasta/run.dart

Issue 2722223006: Move all main methods to tool/. (Closed)
Patch Set: Update tools/patch_sdk.dart. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/parser_main.dart ('k') | pkg/front_end/lib/src/fasta/scanner/bin/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698