Skip to content

Commit f9ac6d8

Browse files
committed
Track pending build work in Build instead of in the asset graph.
1 parent 396b157 commit f9ac6d8

27 files changed

+622
-1109
lines changed

_test_common/lib/assets.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import 'package:crypto/crypto.dart';
1010
AssetNode makeAssetNode([
1111
String? assetIdString,
1212
List<AssetId>? outputs,
13-
Digest? lastKnownDigest,
13+
Digest? digest,
1414
]) {
1515
var id = makeAssetId(assetIdString);
1616
return AssetNode.source(
1717
id,
18-
lastKnownDigest: lastKnownDigest,
18+
digest: digest,
1919
outputs: outputs,
2020
primaryOutputs: outputs,
2121
);

build_runner/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- Use `built_value` for `AssetNode` and related types.
1515
- Add details of what changed and what is built to `--verbose` logging.
1616
- Compute outputs as needed instead of storing them in the asset graph.
17+
- Refactor invalidation to track current build progress in `Build` instead of
18+
in the asset graph.
1719

1820
## 2.4.15
1921

build_runner/bin/graph_inspector.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,9 @@ class InspectNodeCommand extends Command<bool> {
144144
final nodeState = node.generatedNodeState!;
145145
final nodeConfiguration = node.generatedNodeConfiguration!;
146146
description
147-
..writeln(' state: ${nodeState.pendingBuildAction}')
148-
..writeln(' wasOutput: ${nodeState.wasOutput}')
147+
..writeln(' wasOutput: ${node.wasOutput}')
149148
..writeln(' phase: ${nodeConfiguration.phaseNumber}')
150-
..writeln(' isFailure: ${nodeState.isFailure}');
149+
..writeln(' result: ${nodeState.result}');
151150
}
152151

153152
void printAsset(AssetId asset) =>

build_runner/lib/src/entrypoint/clean.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Future<void> _cleanUpSourceOutputs(
8686
for (var id in assetGraph.outputs) {
8787
if (id.package != packageGraph.root.name) continue;
8888
var node = assetGraph.get(id)!;
89-
if (node.generatedNodeState!.wasOutput) {
89+
if (node.wasOutput) {
9090
// Note that this does a file.exists check in the root package and
9191
// only tries to delete the file if it exists. This way we only
9292
// actually delete to_source outputs, without reading in the build

build_runner/lib/src/server/asset_graph_handler.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,10 @@ class AssetGraphHandler {
151151
node.type == NodeType.generated
152152
? node.generatedNodeConfiguration!.isHidden
153153
: null,
154-
'state':
154+
'wasOutput': node.type == NodeType.generated ? node.wasOutput : null,
155+
'result':
155156
node.type == NodeType.generated
156-
? '${node.generatedNodeState!.pendingBuildAction}'
157-
: node.type == NodeType.glob
158-
? '${node.globNodeState!.pendingBuildAction}'
159-
: null,
160-
'wasOutput':
161-
node.type == NodeType.generated
162-
? node.generatedNodeState!.wasOutput
163-
: null,
164-
'isFailure':
165-
node.type == NodeType.generated
166-
? node.generatedNodeState!.isFailure
157+
? node.generatedNodeState!.result
167158
: null,
168159
'phaseNumber':
169160
node.type == NodeType.generated
@@ -176,7 +167,7 @@ class AssetGraphHandler {
176167
node.type == NodeType.glob
177168
? node.globNodeConfiguration!.glob
178169
: null,
179-
'lastKnownDigest': node.lastKnownDigest.toString(),
170+
'digest': node.digest.toString(),
180171
},
181172
'edges': edges,
182173
'nodes': nodes,

build_runner/lib/src/watcher/change_filter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ FutureOr<bool> shouldProcess(
3434
reader.cache.invalidate([change.id]);
3535
return reader
3636
.digest(change.id)
37-
.then((newDigest) => node.lastKnownDigest != newDigest);
37+
.then((newDigest) => node.digest != newDigest);
3838
}
3939
} else {
4040
if (change.type != ChangeType.ADD) return false;

build_runner/test/generate/watch_test.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,8 @@ void main() {
371371
bCopyId,
372372
phaseNumber: 0,
373373
primaryInput: makeAssetId('a|web/b.txt'),
374-
pendingBuildAction: PendingBuildAction.none,
375-
wasOutput: true,
376-
isFailure: false,
377-
lastKnownDigest: computeDigest(bCopyId, 'b2'),
374+
result: true,
375+
digest: computeDigest(bCopyId, 'b2'),
378376
inputs: [makeAssetId('a|web/b.txt')],
379377
isHidden: false,
380378
);
@@ -395,10 +393,8 @@ void main() {
395393
cCopyId,
396394
phaseNumber: 0,
397395
primaryInput: cTxtId,
398-
pendingBuildAction: PendingBuildAction.none,
399-
wasOutput: true,
400-
isFailure: false,
401-
lastKnownDigest: computeDigest(cCopyId, 'c'),
396+
result: true,
397+
digest: computeDigest(cCopyId, 'c'),
402398
inputs: [makeAssetId('a|web/c.txt')],
403399
isHidden: false,
404400
);

build_runner/test/server/asset_handler_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:build_runner_core/src/asset_graph/post_process_build_step_id.dar
1414
import 'package:build_runner_core/src/generate/build_phases.dart';
1515
import 'package:build_runner_core/src/generate/options.dart';
1616
import 'package:build_runner_core/src/package_graph/target_graph.dart';
17+
import 'package:crypto/crypto.dart';
1718
import 'package:shelf/shelf.dart';
1819
import 'package:test/test.dart';
1920

@@ -137,10 +138,9 @@ void main() {
137138
AssetNode.generated(
138139
AssetId('a', 'web/main.ddc.js'),
139140
phaseNumber: 0,
140-
pendingBuildAction: PendingBuildAction.none,
141141
isHidden: false,
142-
wasOutput: true,
143-
isFailure: true,
142+
digest: Digest([]),
143+
result: false,
144144
primaryInput: AssetId('a', 'web/main.dart'),
145145
),
146146
);

build_runner/test/server/serve_handler_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import 'package:build_runner_core/src/generate/build_phases.dart';
2020
import 'package:build_runner_core/src/generate/options.dart';
2121
import 'package:build_runner_core/src/generate/performance_tracker.dart';
2222
import 'package:build_runner_core/src/package_graph/target_graph.dart';
23+
import 'package:crypto/crypto.dart';
2324
import 'package:logging/logging.dart';
2425
import 'package:shelf/shelf.dart';
2526
import 'package:stream_channel/stream_channel.dart';
@@ -210,10 +211,9 @@ void main() {
210211
AssetNode.generated(
211212
AssetId('a', 'web/main.ddc.js'),
212213
phaseNumber: 0,
213-
pendingBuildAction: PendingBuildAction.none,
214214
isHidden: false,
215-
wasOutput: true,
216-
isFailure: true,
215+
digest: Digest([]),
216+
result: false,
217217
primaryInput: AssetId('a', 'web/main.dart'),
218218
),
219219
);

build_runner_core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
- Compute outputs as needed instead of storing them in the asset graph.
3333
- Check build options for changes in the phase setup instead of storing them
3434
in the asset graph.
35+
- Refactor invalidation to track current build progress in `Build` instead of
36+
in the asset graph.
3537

3638
## 8.0.0
3739

0 commit comments

Comments
 (0)