Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: pkg/barback/lib/src/asset_cascade.dart

Issue 149243009: Add support for lazy transformers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.asset_cascade; 5 library barback.asset_cascade;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'asset.dart'; 10 import 'asset.dart';
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // * [id] may be generated before the compilation is finished. We should 144 // * [id] may be generated before the compilation is finished. We should
145 // be able to quickly check whether there are any more in-place 145 // be able to quickly check whether there are any more in-place
146 // transformations that can be run on it. If not, we can return it early. 146 // transformations that can be run on it. If not, we can return it early.
147 // * If [id] has never been generated and all active transformers provide 147 // * If [id] has never been generated and all active transformers provide
148 // metadata about the file names of assets it can emit, we can prove that 148 // metadata about the file names of assets it can emit, we can prove that
149 // none of them can emit [id] and fail early. 149 // none of them can emit [id] and fail early.
150 return _phases.last.getOutput(id).then((node) { 150 return _phases.last.getOutput(id).then((node) {
151 // If the requested asset is available, we can just return it. 151 // If the requested asset is available, we can just return it.
152 if (node != null && node.state.isAvailable) return node; 152 if (node != null && node.state.isAvailable) return node;
153 153
154 // If there's a build running, that build might generate the asset, so we
155 // wait for it to complete and then try again.
156 if (_processDone != null) { 154 if (_processDone != null) {
155 // If there's a build running, that build might generate the asset, so
156 // we wait for it to complete and then try again.
157 return _processDone.then((_) => getAssetNode(id)); 157 return _processDone.then((_) => getAssetNode(id));
158 } 158 }
159 159
160 // If the asset hasn't been built and nothing is building now, the asset 160 // If the asset hasn't been built and nothing is building now, the asset
161 // won't be generated, so we return null. 161 // won't be generated, so we return null.
162 return null; 162 return null;
163 }); 163 });
164 } 164 }
165 165
166 /// Adds [sources] to the graph's known set of source assets. 166 /// Adds [sources] to the graph's known set of source assets.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 227
228 if (transformers.length == 0) { 228 if (transformers.length == 0) {
229 _phases.last.updateTransformers([]); 229 _phases.last.updateTransformers([]);
230 } else if (transformers.length < _phases.length) { 230 } else if (transformers.length < _phases.length) {
231 _phases[transformers.length - 1].removeFollowing(); 231 _phases[transformers.length - 1].removeFollowing();
232 _phases.removeRange(transformers.length, _phases.length); 232 _phases.removeRange(transformers.length, _phases.length);
233 } 233 }
234 } 234 }
235 235
236 /// Materialize all [LazyTransformer]s' transforms in this cascade.
237 void materializeAllTransforms() {
238 for (var phase in _phases) {
239 phase.materializeAllTransforms();
240 }
241 }
242
236 void reportError(BarbackException error) { 243 void reportError(BarbackException error) {
237 _accumulatedErrors.add(error); 244 _accumulatedErrors.add(error);
238 _errorsController.add(error); 245 _errorsController.add(error);
239 } 246 }
240 247
241 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. 248 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream.
242 void _addPhase(Phase phase) { 249 void _addPhase(Phase phase) {
243 _onDirtyPool.add(phase.onDirty); 250 _onDirtyPool.add(phase.onDirty);
244 _onLogPool.add(phase.onLog); 251 _onLogPool.add(phase.onLog);
245 phase.onDirty.listen((_) { 252 phase.onDirty.listen((_) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 309
303 // Otherwise, everything is done. 310 // Otherwise, everything is done.
304 return null; 311 return null;
305 } 312 }
306 313
307 // Process that phase and then loop onto the next. 314 // Process that phase and then loop onto the next.
308 return future.then((_) => _process()); 315 return future.then((_) => _process());
309 }); 316 });
310 } 317 }
311 } 318 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698