| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 main(List<String> args) { | 69 main(List<String> args) { |
| 70 if (args.length != 1) { | 70 if (args.length != 1) { |
| 71 print('Usage: dart create_shard_groups.dart <darto-source-file>'); | 71 print('Usage: dart create_shard_groups.dart <darto-source-file>'); |
| 72 exit(1); | 72 exit(1); |
| 73 } | 73 } |
| 74 | 74 |
| 75 File dartoSourceFile = new File(args[0]); | 75 File dartoSourceFile = new File(args[0]); |
| 76 List<String> dartoSource = dartoSourceFile.readAsLinesSync(); | 76 List<String> dartoSource = dartoSourceFile.readAsLinesSync(); |
| 77 | 77 |
| 78 List<String> groups = findGroups(dartoSource); | 78 List<String> groups = findGroups(dartoSource); |
| 79 List<String> shards = findShards(dartoSource); | 79 List<List<String>> shards = findShards(dartoSource); |
| 80 int groupCount = math.min(groups.length, shards.length); | 80 int groupCount = math.min(groups.length, shards.length); |
| 81 | 81 |
| 82 // Print the resulting Dart declaration. | 82 // Print the resulting Dart declaration. |
| 83 print(""" | 83 print(""" |
| 84 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 84 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 85 // for details. All rights reserved. Use of this source code is governed by a | 85 // for details. All rights reserved. Use of this source code is governed by a |
| 86 // BSD-style license that can be found in the LICENSE file. | 86 // BSD-style license that can be found in the LICENSE file. |
| 87 // | 87 // |
| 88 // ----- Generated by create_shard_groups.dart, do not edit! ----- | 88 // ----- Generated by create_shard_groups.dart, do not edit! ----- |
| 89 | 89 |
| 90 part of gardening.shard2group; | 90 part of gardening.shard2group; |
| 91 | 91 |
| 92 const Map<String, List<String>> shardGroups = const { | 92 const Map<String, List<String>> shardGroups = const { |
| 93 """); | 93 """); |
| 94 for (int i = 0; i < groupCount; i++) { | 94 for (int i = 0; i < groupCount; i++) { |
| 95 print(" '${groups[i]}': const <String>["); | 95 print(" '${groups[i]}': const <String>["); |
| 96 for (List<String> shard in shards[i]) { | 96 for (String shard in shards[i]) { |
| 97 print(" '$shard',"); | 97 print(" '$shard',"); |
| 98 } | 98 } |
| 99 print(" ],"); | 99 print(" ],"); |
| 100 } | 100 } |
| 101 print('};'); | 101 print('};'); |
| 102 } | 102 } |
| OLD | NEW |