Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect changes from inputs #3902

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build_runner_core/lib/src/asset_graph/graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class AssetGraph {
Future Function(AssetId id) delete,
AssetReader digestReader,
) async {
print('Updating graph! ${StackTrace.current} from $updates');
var newIds = <AssetId>{};
var modifyIds = <AssetId>{};
var removeIds = <AssetId>{};
Expand Down Expand Up @@ -402,6 +403,8 @@ class AssetGraph {
_removeRecursive(id);
}

print('Returning: $invalidatedIds');

return invalidatedIds;
}

Expand Down
2 changes: 1 addition & 1 deletion build_runner_core/lib/src/asset_graph/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SourceAssetNode extends AssetNode {
SourceAssetNode(super.id, {super.lastKnownDigest});

@override
String toString() => 'SourceAssetNode: $id';
String toString() => 'SourceAssetNode: $id, $lastKnownDigest';
}

/// States for nodes that can be invalidated.
Expand Down
15 changes: 11 additions & 4 deletions build_runner_core/lib/src/generate/build_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ final _logger = Logger('BuildDefinition');

class BuildDefinition {
final AssetGraph assetGraph;
Map<AssetId, ChangeType>? updates;
final TargetGraph targetGraph;

final AssetReader reader;
Expand All @@ -57,6 +58,7 @@ class BuildDefinition {

BuildDefinition._(
this.assetGraph,
this.updates,
this.targetGraph,
this.reader,
this.writer,
Expand Down Expand Up @@ -132,6 +134,7 @@ class AssetTracker {
Set<AssetId> internalSources,
AssetGraph assetGraph,
) async {
print('compute source updates');
final allSources =
<AssetId>{}
..addAll(inputSources)
Expand Down Expand Up @@ -171,6 +174,7 @@ class AssetTracker {
if (originalDigest == null) return;
await _reader.cache.invalidate([id]);
var currentDigest = await _reader.digest(id);
print('$id $originalDigest -> $currentDigest');
if (currentDigest != originalDigest) {
updates[id] = ChangeType.MODIFY;
}
Expand Down Expand Up @@ -243,8 +247,9 @@ class _Loader {
var internalSources = await assetTracker._findInternalSources();

BuildScriptUpdates? buildScriptUpdates;
Map<AssetId, ChangeType>? updates;
if (assetGraph != null) {
var updates = await logTimedAsync(
updates = await logTimedAsync(
_logger,
'Checking for updates since last build',
() => _updateAssetGraph(
Expand All @@ -265,7 +270,7 @@ class _Loader {

var buildScriptUpdated =
!_options.skipBuildScriptCheck &&
buildScriptUpdates.hasBeenUpdated(updates.keys.toSet());
buildScriptUpdates.hasBeenUpdated(updates!.keys.toSet());
if (buildScriptUpdated) {
_logger.warning('Invalidating asset graph due to build script update!');

Expand Down Expand Up @@ -341,6 +346,7 @@ class _Loader {

return BuildDefinition._(
assetGraph!,
updates,
_options.targetGraph,
_copyReaderWithBuildCacheAssetPathProvider(
_environment.reader,
Expand Down Expand Up @@ -550,7 +556,8 @@ class _Loader {
assetGraph,
);
updates.addAll(_computeBuilderOptionsUpdates(assetGraph, buildPhases));
await assetGraph.updateAndInvalidate(
// build_impl also wants to do this, and uses the results
/*await assetGraph.updateAndInvalidate(
_buildPhases,
updates,
_options.packageGraph.root.name,
Expand All @@ -562,7 +569,7 @@ class _Loader {
_environment.reader,
assetGraph,
),
);
);*/
return updates;
}

Expand Down
Loading
Loading