|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 | import 'dart:async'; |
5 | | -import 'dart:collection'; |
6 | 5 | import 'dart:convert'; |
7 | 6 |
|
8 | 7 | import '../asset/asset.dart'; |
9 | 8 | import '../asset/id.dart'; |
10 | | -import '../asset/reader.dart'; |
11 | | -import '../asset/writer.dart'; |
12 | 9 |
|
13 | 10 | /// A single step in the build processes. This represents a single input and |
14 | | -/// its expected and real outputs. It also handles tracking of dependencies. |
| 11 | +/// it also handles tracking of dependencies. |
15 | 12 | class BuildStep { |
16 | 13 | /// The primary input for this build step. |
17 | 14 | final Asset input; |
18 | 15 |
|
19 | | - /// The list of all outputs which are expected/allowed to be output from this |
20 | | - /// step. |
21 | | - final List<AssetId> expectedOutputs; |
22 | | - |
23 | | - /// The actual outputs of this build step. |
24 | | - UnmodifiableListView<Asset> get outputs => new UnmodifiableListView(_outputs); |
25 | | - final List<Asset> _outputs = []; |
26 | | - |
27 | | - /// A future that completes once all outputs current are done writing. |
28 | | - /// |
29 | | - /// TODO(jakemac): This is not typically needed inside of a Builder, we could |
30 | | - /// consider moving it out to a separate class which wraps a [BuildStep] and |
31 | | - /// this future? Another option would be an `Output` class which wraps an |
32 | | - /// [Asset] and a [Future] that completes once its done writing. |
33 | | - Future get outputsCompleted => _outputsCompleted; |
34 | | - Future _outputsCompleted = new Future(() {}); |
35 | | - |
36 | | - /// The dependencies read in during this build step. |
37 | | - UnmodifiableListView<AssetId> get dependencies => |
38 | | - new UnmodifiableListView(_dependencies); |
39 | | - final Set<AssetId> _dependencies = new Set<AssetId>(); |
40 | | - |
41 | | - /// Used internally for reading files. |
42 | | - final AssetReader _reader; |
43 | | - |
44 | | - /// Used internally for writing files. |
45 | | - final AssetWriter _writer; |
46 | | - |
47 | | - BuildStep( |
48 | | - this.input, List<AssetId> expectedOutputs, this._reader, this._writer) |
49 | | - : expectedOutputs = new List.unmodifiable(expectedOutputs) { |
50 | | - /// The [input] is always a dependency. |
51 | | - _dependencies.add(input.id); |
52 | | - } |
53 | | - |
54 | 16 | /// Reads an [Asset] by [id] as a [String] using [encoding]. |
55 | 17 | /// |
56 | 18 | /// If [trackAsDependency] is true, then [id] will be marked as a dependency |
57 | 19 | /// of all [expectedOutputs]. |
58 | 20 | Future<String> readAsString(AssetId id, |
59 | | - {Encoding encoding: UTF8, bool trackAsDependency: true}) { |
60 | | - if (trackAsDependency) _dependencies.add(id); |
61 | | - return _reader.readAsString(id, encoding: encoding); |
62 | | - } |
| 21 | + {Encoding encoding: UTF8, bool trackAsDependency: true}); |
63 | 22 |
|
64 | 23 | /// Outputs an [Asset] using the current [AssetWriter], and adds [asset] to |
65 | 24 | /// [outputs]. |
66 | | - void writeAsString(Asset asset, {Encoding encoding: UTF8}) { |
67 | | - _outputs.add(asset); |
68 | | - var done = _writer.writeAsString(asset, encoding: encoding); |
69 | | - _outputsCompleted = _outputsCompleted.then((_) => done); |
70 | | - } |
| 25 | + void writeAsString(Asset asset, {Encoding encoding: UTF8}); |
71 | 26 |
|
72 | 27 | /// Explicitly adds [id] as a dependency of all [expectedOutputs]. This is |
73 | 28 | /// not generally necessary unless forcing `trackAsDependency: false` when |
74 | 29 | /// calling [readAsString]. |
75 | | - void addDependency(AssetId id) { |
76 | | - _dependencies.add(id); |
77 | | - } |
| 30 | + void addDependency(AssetId id); |
78 | 31 | } |
0 commit comments