| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 barback.package_graph; | 5 library barback.package_graph; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset_cascade.dart'; | 9 import 'asset_cascade.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 }); | 80 }); |
| 81 | 81 |
| 82 cascade.onLog.listen(_logger.logEntry); | 82 cascade.onLog.listen(_logger.logEntry); |
| 83 | 83 |
| 84 cascade.results.listen((result) { | 84 cascade.results.listen((result) { |
| 85 _cascadeResults[cascade.package] = result; | 85 _cascadeResults[cascade.package] = result; |
| 86 // If any cascade hasn't yet finished, the overall build isn't finished | 86 // If any cascade hasn't yet finished, the overall build isn't finished |
| 87 // either. | 87 // either. |
| 88 if (_cascadeResults.values.any((result) => result == null)) return; | 88 if (_cascadeResults.values.any((result) => result == null)) return; |
| 89 | 89 |
| 90 var errors = unionAll( | |
| 91 _cascadeResults.values.map((result) => result.errors)); | |
| 92 | |
| 93 var numLogErrors = _cascadeResults.values.fold(0, | |
| 94 (numErrors, result) => result.numErrors - result.errors.length); | |
| 95 | |
| 96 // Include all build errors for all cascades. If no cascades have | 90 // Include all build errors for all cascades. If no cascades have |
| 97 // errors, the result will automatically be considered a success. | 91 // errors, the result will automatically be considered a success. |
| 98 _resultsController.add(new BuildResult(errors, numLogErrors)); | 92 _resultsController.add( |
| 93 new BuildResult.aggregate(_cascadeResults.values)); |
| 99 }, onError: (error) { | 94 }, onError: (error) { |
| 100 _lastUnexpectedError = error; | 95 _lastUnexpectedError = error; |
| 101 _resultsController.addError(error); | 96 _resultsController.addError(error); |
| 102 }); | 97 }); |
| 103 } | 98 } |
| 104 | 99 |
| 105 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors), | 100 _errors = mergeStreams(_cascades.values.map((cascade) => cascade.errors), |
| 106 broadcast: true); | 101 broadcast: true); |
| 107 } | 102 } |
| 108 | 103 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 131 } | 126 } |
| 132 | 127 |
| 133 // If an unexpected error occurred, complete with that. | 128 // If an unexpected error occurred, complete with that. |
| 134 if (_lastUnexpectedError != null) { | 129 if (_lastUnexpectedError != null) { |
| 135 var error = _lastUnexpectedError; | 130 var error = _lastUnexpectedError; |
| 136 _lastUnexpectedError = null; | 131 _lastUnexpectedError = null; |
| 137 return new Future.error(error); | 132 return new Future.error(error); |
| 138 } | 133 } |
| 139 | 134 |
| 140 // If the build completed with an error, complete the future with it. | 135 // If the build completed with an error, complete the future with it. |
| 141 var errors = unionAll( | 136 var result = new BuildResult.aggregate(_cascadeResults.values); |
| 142 _cascadeResults.values.map((result) => result.errors)); | 137 if (!result.succeeded) { |
| 143 if (errors.isNotEmpty) { | 138 return new Future.error(BarbackException.aggregate(result.errors)); |
| 144 return new Future.error(BarbackException.aggregate(errors)); | |
| 145 } | 139 } |
| 146 | 140 |
| 147 // Otherwise, return all of the final output assets. | 141 // Otherwise, return all of the final output assets. |
| 148 var assets = unionAll(_cascades.values.map( | 142 var assets = unionAll(_cascades.values.map( |
| 149 (cascade) => cascade.availableOutputs.toSet())); | 143 (cascade) => cascade.availableOutputs.toSet())); |
| 150 | 144 |
| 151 return new Future.value(new AssetSet.from(assets)); | 145 return new Future.value(new AssetSet.from(assets)); |
| 152 } | 146 } |
| 153 | 147 |
| 154 /// Adds [sources] to the graph's known set of source assets. | 148 /// Adds [sources] to the graph's known set of source assets. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 if (cascade == null) throw new ArgumentError("Unknown package $package."); | 165 if (cascade == null) throw new ArgumentError("Unknown package $package."); |
| 172 cascade.removeSources(ids); | 166 cascade.removeSources(ids); |
| 173 }); | 167 }); |
| 174 } | 168 } |
| 175 | 169 |
| 176 void updateTransformers(String package, | 170 void updateTransformers(String package, |
| 177 Iterable<Iterable<Transformer>> transformers) { | 171 Iterable<Iterable<Transformer>> transformers) { |
| 178 _cascades[package].updateTransformers(transformers); | 172 _cascades[package].updateTransformers(transformers); |
| 179 } | 173 } |
| 180 } | 174 } |
| OLD | NEW |