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

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

Issue 22854022: Remove the transformless phase from AssetCascade. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « no previous file | pkg/barback/lib/src/phase.dart » ('j') | pkg/barback/lib/src/phase.dart » ('J')
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 /// Creates a new [AssetCascade]. 86 /// Creates a new [AssetCascade].
87 /// 87 ///
88 /// It loads source assets within [package] using [provider] and then uses 88 /// It loads source assets within [package] using [provider] and then uses
89 /// [transformerPhases] to generate output files from them. 89 /// [transformerPhases] to generate output files from them.
90 //TODO(rnystrom): Better way of specifying transformers and their ordering. 90 //TODO(rnystrom): Better way of specifying transformers and their ordering.
91 AssetCascade(this.graph, this.package, 91 AssetCascade(this.graph, this.package,
92 Iterable<Iterable<Transformer>> transformerPhases) { 92 Iterable<Iterable<Transformer>> transformerPhases) {
93 // Flatten the phases to a list so we can traverse backwards to wire up 93 // Flatten the phases to a list so we can traverse backwards to wire up
94 // each phase to its next. 94 // each phase to its next.
95 var phases = transformerPhases.toList(); 95 var phases = transformerPhases.toList();
96 96 if (phases.isEmpty) phases = [[]];
97 // Each phase writes its outputs as inputs to the next phase after it.
98 // Add a phase at the end for the final outputs of the last phase.
99 phases.add([]);
100 97
101 Phase nextPhase = null; 98 Phase nextPhase = null;
102 for (var transformers in phases.reversed) { 99 for (var transformers in phases.reversed) {
103 nextPhase = new Phase(this, _phases.length, transformers.toList(), 100 nextPhase = new Phase(this, transformers.toList(), nextPhase);
104 nextPhase);
105 nextPhase.onDirty.listen((_) { 101 nextPhase.onDirty.listen((_) {
106 _newChanges = true; 102 _newChanges = true;
107 _waitForProcess(); 103 _waitForProcess();
108 }); 104 });
109 _phases.insert(0, nextPhase); 105 _phases.insert(0, nextPhase);
110 } 106 }
111 } 107 }
112 108
113 /// Gets the asset identified by [id]. 109 /// Gets the asset identified by [id].
114 /// 110 ///
115 /// If [id] is for a generated or transformed asset, this will wait until it 111 /// If [id] is for a generated or transformed asset, this will wait until it
116 /// has been created and return it. This means that the returned asset will 112 /// has been created and return it. This means that the returned asset will
117 /// always be [AssetState.AVAILABLE]. 113 /// always be [AssetState.AVAILABLE].
118 /// 114 ///
119 /// If the asset cannot be found, returns null. 115 /// If the asset cannot be found, returns null.
120 Future<AssetNode> getAssetNode(AssetId id) { 116 Future<AssetNode> getAssetNode(AssetId id) {
121 assert(id.package == package); 117 assert(id.package == package);
122 118
123 // TODO(rnystrom): Waiting for the entire build to complete is unnecessary 119 // TODO(rnystrom): Waiting for the entire build to complete is unnecessary
124 // in some cases. Should optimize: 120 // in some cases. Should optimize:
125 // * [id] may be generated before the compilation is finished. We should 121 // * [id] may be generated before the compilation is finished. We should
126 // be able to quickly check whether there are any more in-place 122 // be able to quickly check whether there are any more in-place
127 // transformations that can be run on it. If not, we can return it early. 123 // transformations that can be run on it. If not, we can return it early.
128 // * If [id] has never been generated and all active transformers provide 124 // * If [id] has never been generated and all active transformers provide
129 // metadata about the file names of assets it can emit, we can prove that 125 // metadata about the file names of assets it can emit, we can prove that
130 // none of them can emit [id] and fail early. 126 // none of them can emit [id] and fail early.
131 return _phases.last.getInput(id).then((node) { 127 return _phases.last.getOutput(id).then((node) {
132 // If the requested asset is available, we can just return it. 128 // If the requested asset is available, we can just return it.
133 if (node != null && node.state.isAvailable) return node; 129 if (node != null && node.state.isAvailable) return node;
134 130
135 // If there's a build running, that build might generate the asset, so we 131 // If there's a build running, that build might generate the asset, so we
136 // wait for it to complete and then try again. 132 // wait for it to complete and then try again.
137 if (_processDone != null) { 133 if (_processDone != null) {
138 return _processDone.then((_) => getAssetNode(id)); 134 return _processDone.then((_) => getAssetNode(id));
139 } 135 }
140 136
141 // If the asset hasn't been built and nothing is building now, the asset 137 // If the asset hasn't been built and nothing is building now, the asset
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 242
247 // Otherwise, everything is done. 243 // Otherwise, everything is done.
248 return; 244 return;
249 } 245 }
250 246
251 // Process that phase and then loop onto the next. 247 // Process that phase and then loop onto the next.
252 return future.then((_) => _process()); 248 return future.then((_) => _process());
253 }); 249 });
254 } 250 }
255 } 251 }
OLDNEW
« no previous file with comments | « no previous file | pkg/barback/lib/src/phase.dart » ('j') | pkg/barback/lib/src/phase.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698