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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library fasta.compile_platform; | 5 library fasta.compile_platform; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'ticker.dart' show Ticker; | 9 import 'ticker.dart' show Ticker; |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 import 'translate_uri.dart' show TranslateUri; | 23 import 'translate_uri.dart' show TranslateUri; |
24 | 24 |
25 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | 25 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
26 | 26 |
27 Future mainEntryPoint(List<String> arguments) async { | 27 Future mainEntryPoint(List<String> arguments) async { |
28 for (int i = 0; i < iterations; i++) { | 28 for (int i = 0; i < iterations; i++) { |
29 if (i > 0) { | 29 if (i > 0) { |
30 print("\n"); | 30 print("\n"); |
31 } | 31 } |
32 Ticker ticker = new Ticker(); | |
33 try { | 32 try { |
34 await CompilerCommandLine.withGlobalOptions("compile_platform", arguments, | 33 await compilePlatform(arguments); |
35 (CompilerContext c) => compilePlatform(c, ticker)); | |
36 } on InputError catch (e) { | 34 } on InputError catch (e) { |
37 exitCode = 1; | 35 exitCode = 1; |
38 print(e.format()); | 36 print(e.format()); |
39 return null; | 37 return null; |
40 } | 38 } |
41 } | 39 } |
42 } | 40 } |
43 | 41 |
44 Future compilePlatform(CompilerContext c, Ticker ticker) async { | 42 Future compilePlatform(List<String> arguments) async { |
| 43 Ticker ticker = new Ticker(); |
| 44 await CompilerCommandLine.withGlobalOptions("compile_platform", arguments, |
| 45 (CompilerContext c) { |
| 46 Uri patchedSdk = Uri.base.resolveUri(new Uri.file(c.options.arguments[0])); |
| 47 Uri output = Uri.base.resolveUri(new Uri.file(c.options.arguments[1])); |
| 48 return compilePlatformInternal(c, ticker, patchedSdk, output); |
| 49 }); |
| 50 } |
| 51 |
| 52 Future compilePlatformInternal( |
| 53 CompilerContext c, Ticker ticker, Uri patchedSdk, Uri output) async { |
45 ticker.isVerbose = c.options.verbose; | 54 ticker.isVerbose = c.options.verbose; |
46 Uri output = Uri.base.resolveUri(new Uri.file(c.options.arguments[1])); | 55 Uri deps = Uri.base.resolveUri(new Uri.file("${output.toFilePath()}.d")); |
47 Uri deps = Uri.base.resolveUri(new Uri.file("${c.options.arguments[1]}.d")); | |
48 Uri patchedSdk = Uri.base.resolveUri(new Uri.file(c.options.arguments[0])); | |
49 ticker.logMs("Parsed arguments"); | 56 ticker.logMs("Parsed arguments"); |
50 if (ticker.isVerbose) { | 57 if (ticker.isVerbose) { |
51 print("Compiling $patchedSdk to $output"); | 58 print("Compiling $patchedSdk to $output"); |
52 } | 59 } |
53 | 60 |
54 TranslateUri uriTranslator = | 61 TranslateUri uriTranslator = |
55 await TranslateUri.parse(patchedSdk, c.options.packages); | 62 await TranslateUri.parse(patchedSdk, c.options.packages); |
56 ticker.logMs("Read packages file"); | 63 ticker.logMs("Read packages file"); |
57 | 64 |
58 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); | 65 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); |
59 KernelTarget kernelTarget = | 66 KernelTarget kernelTarget = |
60 new KernelTarget(dillTarget, uriTranslator, c.uriToSource); | 67 new KernelTarget(dillTarget, uriTranslator, c.uriToSource); |
61 | 68 |
62 kernelTarget.read(Uri.parse("dart:core")); | 69 kernelTarget.read(Uri.parse("dart:core")); |
63 await dillTarget.writeOutline(null); | 70 await dillTarget.writeOutline(null); |
64 await kernelTarget.writeOutline(output); | 71 await kernelTarget.writeOutline(output); |
65 | 72 |
66 if (exitCode != 0) return null; | 73 if (exitCode != 0) return null; |
67 await kernelTarget.writeProgram(output, | 74 await kernelTarget.writeProgram(output, |
68 dumpIr: c.options.dumpIr, verify: c.options.verify); | 75 dumpIr: c.options.dumpIr, verify: c.options.verify); |
69 await kernelTarget.writeDepsFile(output, deps); | 76 await kernelTarget.writeDepsFile(output, deps); |
70 } | 77 } |
OLD | NEW |