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

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: code review 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
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/lib/src/asset_node.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /// Force all [LazyTransformer]s' transforms in this cascade to begin
237 /// producing concrete assets.
238 void forceAllTransforms() {
239 for (var phase in _phases) {
240 phase.forceAllTransforms();
241 }
242 }
243
236 void reportError(BarbackException error) { 244 void reportError(BarbackException error) {
237 _accumulatedErrors.add(error); 245 _accumulatedErrors.add(error);
238 _errorsController.add(error); 246 _errorsController.add(error);
239 } 247 }
240 248
241 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream. 249 /// Add [phase] to the end of [_phases] and watch its [onDirty] stream.
242 void _addPhase(Phase phase) { 250 void _addPhase(Phase phase) {
243 _onDirtyPool.add(phase.onDirty); 251 _onDirtyPool.add(phase.onDirty);
244 _onLogPool.add(phase.onLog); 252 _onLogPool.add(phase.onLog);
245 phase.onDirty.listen((_) { 253 phase.onDirty.listen((_) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 return null; 312 return null;
305 } 313 }
306 314
307 // Process that phase and then loop onto the next. 315 // Process that phase and then loop onto the next.
308 return future.then((_) => _process()); 316 return future.then((_) => _process());
309 }); 317 });
310 } 318 }
311 319
312 String toString() => "cascade for $package"; 320 String toString() => "cascade for $package";
313 } 321 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/lib/src/asset_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698