@@ -34,8 +34,8 @@ class BuildImpl {
3434 bool _buildRunning = false ;
3535 final _logger = new Logger ('Build' );
3636
37- BuildImpl (this ._assetGraph, this ._reader, this ._writer,
38- this ._packageGraph, this . _phaseGroups);
37+ BuildImpl (this ._assetGraph, this ._reader, this ._writer, this ._packageGraph,
38+ this ._phaseGroups);
3939
4040 /// Runs a build
4141 ///
@@ -61,11 +61,13 @@ class BuildImpl {
6161 _logger.info ('Running build phases' );
6262 var result = await _runPhases ();
6363
64- // Write out the new build_outputs file.
64+ /// Write out the new build_outputs file.
65+ var allOuputs = _assetGraph.allNodes
66+ .where ((node) => node is GeneratedAssetNode && node.wasOutput);
6567 var buildOutputsAsset = new Asset (
6668 _buildOutputsId,
6769 JSON .encode (
68- result.outputs .map ((output) => output.id.serialize ()).toList ()));
70+ allOuputs .map ((output) => output.id.serialize ()).toList ()));
6971 await _writer.writeAsString (buildOutputsAsset);
7072
7173 return result;
@@ -280,7 +282,7 @@ class BuildImpl {
280282 _assetGraph.addIfAbsent (
281283 output,
282284 () => new GeneratedAssetNode (
283- builder, input, phaseGroupNum, true , output));
285+ builder, input, phaseGroupNum, true , false , output));
284286 }
285287
286288 /// Skip the build step if none of the outputs need updating.
@@ -291,7 +293,7 @@ class BuildImpl {
291293 /// any files which were output last time, so they can be used by
292294 /// subsequent phases.
293295 for (var output in expectedOutputs) {
294- if (await _reader. hasInput (output)) {
296+ if ((_assetGraph. get (output) as GeneratedAssetNode ).wasOutput ) {
295297 groupOutputs.add (output);
296298 }
297299 }
@@ -304,22 +306,27 @@ class BuildImpl {
304306 await builder.build (buildStep);
305307 await buildStep.complete ();
306308
307- /// Mark all outputs as no longer needing an update.
309+ /// Mark all outputs as no longer needing an update, and mark `wasOutput`
310+ /// as `false` for now (this will get reset to true later one).
308311 for (var output in expectedOutputs) {
309- (_assetGraph.get (output) as GeneratedAssetNode ).needsUpdate = false ;
312+ (_assetGraph.get (output) as GeneratedAssetNode )
313+ ..needsUpdate = false
314+ ..wasOutput = false ;
310315 }
311316
312317 /// Update the asset graph based on the dependencies discovered.
313318 for (var dependency in buildStep.dependencies) {
314319 var dependencyNode = _assetGraph.addIfAbsent (
315320 dependency, () => new AssetNode (dependency));
316321
317- /// We care about all [expectedOutputs] , not just real outputs.
322+ /// We care about all [expectedOutputs] , not just real outputs. Updates
323+ /// to dependencies may cause a file to be output which wasn't before.
318324 dependencyNode.outputs.addAll (expectedOutputs);
319325 }
320326
321327 /// Yield the outputs.
322328 for (var output in buildStep.outputs) {
329+ (_assetGraph.get (output.id) as GeneratedAssetNode ).wasOutput = true ;
323330 groupOutputs.add (output.id);
324331 yield output;
325332 }
0 commit comments