OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Outputs source code for `part` used by `shard2group.dart`. Usage: | 5 // Outputs source code for `part` used by `shard2group.dart`. Usage: |
6 // `dart bin/create_shard_groups.dart source.html >lib/src/shard_data.dart`. | 6 // `dart bin/create_shard_groups.dart source.html >lib/src/shard_data.dart`. |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } else if (trimmed.contains(shardsGroupStartMark)) { | 59 } else if (trimmed.contains(shardsGroupStartMark)) { |
60 // This is a group separator, switch to next sublist. | 60 // This is a group separator, switch to next sublist. |
61 if (shardResult != null) result.add(shardResult); | 61 if (shardResult != null) result.add(shardResult); |
62 shardResult = <String>[]; | 62 shardResult = <String>[]; |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 return result; | 66 return result; |
67 } | 67 } |
68 | 68 |
| 69 void help() { |
| 70 print("Generates the 'shard_data.dart' file that is used by our gardening"); |
| 71 print("tools. This tool needs to be run when the buildbot configuration"); |
| 72 print("(shard) changes\n"); |
| 73 print('Usage: dart create_shard_groups.dart <darto-source-file>'); |
| 74 } |
| 75 |
69 main(List<String> args) { | 76 main(List<String> args) { |
70 if (args.length != 1) { | 77 if (args.length != 1 || args[0] == "--help") { |
71 print('Usage: dart create_shard_groups.dart <darto-source-file>'); | 78 help(); |
| 79 if (args.length == 1) return; |
72 exit(1); | 80 exit(1); |
73 } | 81 } |
74 | 82 |
75 File dartoSourceFile = new File(args[0]); | 83 File dartoSourceFile = new File(args[0]); |
76 List<String> dartoSource = dartoSourceFile.readAsLinesSync(); | 84 List<String> dartoSource = dartoSourceFile.readAsLinesSync(); |
77 | 85 |
78 List<String> groups = findGroups(dartoSource); | 86 List<String> groups = findGroups(dartoSource); |
79 List<List<String>> shards = findShards(dartoSource); | 87 List<List<String>> shards = findShards(dartoSource); |
80 int groupCount = math.min(groups.length, shards.length); | 88 int groupCount = math.min(groups.length, shards.length); |
81 | 89 |
(...skipping 10 matching lines...) Expand all Loading... |
92 const Map<String, List<String>> shardGroups = const {"""); | 100 const Map<String, List<String>> shardGroups = const {"""); |
93 for (int i = 0; i < groupCount; i++) { | 101 for (int i = 0; i < groupCount; i++) { |
94 print(" '${groups[i]}': const <String>["); | 102 print(" '${groups[i]}': const <String>["); |
95 for (String shard in shards[i]) { | 103 for (String shard in shards[i]) { |
96 print(" '$shard',"); | 104 print(" '$shard',"); |
97 } | 105 } |
98 print(" ],"); | 106 print(" ],"); |
99 } | 107 } |
100 print('};'); | 108 print('};'); |
101 } | 109 } |
OLD | NEW |