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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 /// | 49 /// |
50 /// This will not emit programming errors from barback itself. Those will be | 50 /// This will not emit programming errors from barback itself. Those will be |
51 /// emitted through the [results] stream's error channel. | 51 /// emitted through the [results] stream's error channel. |
52 Stream<BarbackException> get errors => _errors; | 52 Stream<BarbackException> get errors => _errors; |
53 Stream<BarbackException> _errors; | 53 Stream<BarbackException> _errors; |
54 | 54 |
55 /// Creates a new [PackageGraph] that will transform assets in all packages | 55 /// Creates a new [PackageGraph] that will transform assets in all packages |
56 /// made available by [provider]. | 56 /// made available by [provider]. |
57 PackageGraph(this.provider) { | 57 PackageGraph(this.provider) { |
58 for (var package in provider.packages) { | 58 for (var package in provider.packages) { |
59 var cascade = new AssetCascade(this, package, | 59 var cascade = new AssetCascade(this, package); |
60 provider.getTransformers(package)); | |
61 // The initial result for each cascade is "success" since the cascade | 60 // The initial result for each cascade is "success" since the cascade |
62 // doesn't start building until some source in that graph is updated. | 61 // doesn't start building until some source in that graph is updated. |
63 _cascadeResults[package] = new BuildResult.success(); | 62 _cascadeResults[package] = new BuildResult.success(); |
64 _cascades[package] = cascade; | 63 _cascades[package] = cascade; |
65 | 64 |
66 cascade.results.listen((result) { | 65 cascade.results.listen((result) { |
67 _cascadeResults[cascade.package] = result; | 66 _cascadeResults[cascade.package] = result; |
68 // If any cascade hasn't yet finished, the overall build isn't finished | 67 // If any cascade hasn't yet finished, the overall build isn't finished |
69 // either. | 68 // either. |
70 if (_cascadeResults.values.any((result) => result == null)) return; | 69 if (_cascadeResults.values.any((result) => result == null)) return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 107 |
109 /// Removes [removed] from the graph's known set of source assets. | 108 /// Removes [removed] from the graph's known set of source assets. |
110 void removeSources(Iterable<AssetId> sources) { | 109 void removeSources(Iterable<AssetId> sources) { |
111 groupBy(sources, (id) => id.package).forEach((package, ids) { | 110 groupBy(sources, (id) => id.package).forEach((package, ids) { |
112 var cascade = _cascades[package]; | 111 var cascade = _cascades[package]; |
113 if (cascade == null) throw new ArgumentError("Unknown package $package."); | 112 if (cascade == null) throw new ArgumentError("Unknown package $package."); |
114 _cascadeResults[package] = null; | 113 _cascadeResults[package] = null; |
115 cascade.removeSources(ids); | 114 cascade.removeSources(ids); |
116 }); | 115 }); |
117 } | 116 } |
117 | |
118 void updateTransformers(String package, | |
119 Iterable<Iterable<Transformer>> transformers) { | |
120 _cascadeResults[package] = null; | |
Bob Nystrom
2013/08/20 19:08:54
What if the set of transformers are unchanged?
nweiz
2013/08/20 21:39:17
We always want to trigger a rebuild so that the ca
Bob Nystrom
2013/08/20 22:18:12
Ensuring a result is sent is fine, but it sucks to
| |
121 _cascades[package].updateTransformers(transformers); | |
122 } | |
118 } | 123 } |
OLD | NEW |