OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.profile_many; | 5 library dart2js.profile_many; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:compiler/src/dart2js.dart' as cmdline; | 9 import 'package:compiler/src/dart2js.dart' as cmdline; |
10 | 10 |
11 const String USAGE = """ | 11 const String USAGE = """ |
12 Usage: dart2js_profile_many.dart [OPTIONS] [FILES] | 12 Usage: dart2js_profile_many.dart [OPTIONS] [FILES] |
13 | 13 |
14 Invokes dart2js separately for each file using the given options. | 14 Invokes dart2js separately for each file using the given options. |
15 This is for profiling multiple compilations in the Dart Observatory. | 15 This is for profiling multiple compilations in the Dart Observatory. |
16 """; | 16 """; |
17 | 17 |
18 printUsage() { | 18 printUsage() { |
19 print(USAGE); | 19 print(USAGE); |
20 } | 20 } |
21 | 21 |
22 void main(List<String> args) { | 22 void main(List<String> args) { |
23 List options = []; | 23 var options = <String>[]; |
24 List files = []; | 24 var files = <String>[]; |
25 | 25 |
26 for (String arg in args) { | 26 for (String arg in args) { |
27 if (arg.startsWith('-')) { | 27 if (arg.startsWith('-')) { |
28 options.add(arg); | 28 options.add(arg); |
29 } else { | 29 } else { |
30 files.add(arg); | 30 files.add(arg); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 if (files.length == 0) { | 34 if (files.length == 0) { |
35 printUsage(); | 35 printUsage(); |
36 return; | 36 return; |
37 } | 37 } |
38 | 38 |
39 cmdline.exitFunc = (code) { | 39 cmdline.exitFunc = (code) { |
40 throw "Exit with code $code"; | 40 throw "Exit with code $code"; |
41 }; | 41 }; |
42 | 42 |
43 Future.forEach(files, (String file) { | 43 Future.forEach(files, (String file) { |
44 List subargs = []; | 44 List subargs = []; |
45 subargs.addAll(options); | 45 subargs.addAll(options); |
46 subargs.add(file); | 46 subargs.add(file); |
47 return cmdline.compilerMain(subargs).catchError((e) {}); | 47 return cmdline.compilerMain(subargs).catchError((e) {}); |
48 }).then((_) { | 48 }).then((_) { |
49 print("Done"); | 49 print("Done"); |
50 }); | 50 }); |
51 } | 51 } |
OLD | NEW |