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