OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /** | 6 /** |
7 * Script to compile each dart web component examples and copy the | 7 * Script to compile each dart web component examples and copy the |
8 * generated code to an output directory. | 8 * generated code to an output directory. |
9 */ | 9 */ |
10 library build_examples; | 10 library build_examples; |
11 | 11 |
12 import 'dart:async'; | 12 import 'dart:async'; |
13 import 'dart:io'; | 13 import 'dart:io'; |
14 import 'package:args/args.dart'; | 14 import 'package:args/args.dart'; |
15 import 'package:web_ui/dwc.dart' as dwc; | 15 import 'package:web_ui/dwc.dart' as dwc; |
16 | 16 |
17 main() { | 17 main(arguments) { |
18 var argParser = new ArgParser(); | 18 var argParser = new ArgParser(); |
19 argParser.addFlag('help', abbr: 'h', help: 'Displayes this help message', | 19 argParser.addFlag('help', abbr: 'h', help: 'Displayes this help message', |
20 defaultsTo: false, negatable: false); | 20 defaultsTo: false, negatable: false); |
21 argParser.addOption('out', abbr: 'o', | 21 argParser.addOption('out', abbr: 'o', |
22 help: 'output directory for the generated code', | 22 help: 'output directory for the generated code', |
23 defaultsTo: 'generated'); | 23 defaultsTo: 'generated'); |
24 var args = argParser.parse(new Options().arguments); | 24 var args = argParser.parse(arguments); |
25 | 25 |
26 if (args['help']) { | 26 if (args['help']) { |
27 print('Usage: build_examples.dart [-o outdir] [file1, file2, ...]'); | 27 print('Usage: build_examples.dart [-o outdir] [file1, file2, ...]'); |
28 print(argParser.getUsage()); | 28 print(argParser.getUsage()); |
29 exit(0); | 29 exit(0); |
30 } | 30 } |
31 | 31 |
32 var output = args['out']; | 32 var output = args['out']; |
33 if (args.rest.isEmpty) { | 33 if (args.rest.isEmpty) { |
34 var dir = new Directory.current(); | 34 var dir = Directory.current; |
35 listFiles(dir, | 35 listFiles(dir, |
36 (filename) => filename.endsWith('.html') && !filename.startsWith('_')) | 36 (filename) => filename.endsWith('.html') && !filename.startsWith('_')) |
37 .then((inputs) { | 37 .then((inputs) { |
38 buildAll(inputs.map((file) => new Path(file).filename), output); | 38 buildAll(inputs.map((file) => new Path(file).filename), output); |
39 }); | 39 }); |
40 } else { | 40 } else { |
41 buildAll(args.rest, output); | 41 buildAll(args.rest, output); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 final String NO_COLOR = '\u001b[0m'; | 89 final String NO_COLOR = '\u001b[0m'; |
90 | 90 |
91 Stopwatch startTime() => new Stopwatch()..start(); | 91 Stopwatch startTime() => new Stopwatch()..start(); |
92 | 92 |
93 void stopTime(Stopwatch watch, String message) { | 93 void stopTime(Stopwatch watch, String message) { |
94 watch.stop(); | 94 watch.stop(); |
95 var duration = watch.elapsedMilliseconds; | 95 var duration = watch.elapsedMilliseconds; |
96 print('$message: $GREEN_COLOR$duration ms$NO_COLOR'); | 96 print('$message: $GREEN_COLOR$duration ms$NO_COLOR'); |
97 totalTime.add('$message: $GREEN_COLOR$duration ms$NO_COLOR'); | 97 totalTime.add('$message: $GREEN_COLOR$duration ms$NO_COLOR'); |
98 } | 98 } |
OLD | NEW |