@@ -14,18 +14,25 @@ import 'package:meta/meta.dart';
1414/// It contains the output path followed by a colon then a space-separated list
1515/// of input paths. Spaces in paths are backslash-escaped.
1616class Depfile {
17+ final String outputPath;
1718 final String depfilePath;
1819 final String digestPath;
1920
20- /// Input and output paths parsed from the depfile.
21+ /// Input paths parsed from the depfile.
2122 Set <String >? _depfilePaths;
2223
23- Depfile ({required this .depfilePath, required this .digestPath});
24+ Depfile ({
25+ required this .outputPath,
26+ required this .depfilePath,
27+ required this .digestPath,
28+ });
2429
25- /// Checks whether the output mentioned in the depfile is fresh.
30+ /// Checks whether the inputs mentioned in the depfile are fresh.
2631 ///
2732 /// It is fresh if it has not changed and none of its inputs have changed.
2833 FreshnessResult checkFreshness () {
34+ final outputFile = File (outputPath);
35+ if (! outputFile.existsSync ()) return FreshnessResult (outputIsFresh: false );
2936 final depsFile = File (depfilePath);
3037 if (! depsFile.existsSync ()) return FreshnessResult (outputIsFresh: false );
3138 final digestFile = File (digestPath);
@@ -43,8 +50,8 @@ class Depfile {
4350 /// [writeDigest] , throws if neither was called.
4451 bool isDependency (String path) => _depfilePaths! .contains (path);
4552
46- /// Writes a digest of all input files and the output file mentioned in
47- /// [depfilePath] to [ digestPath] .
53+ /// Writes a digest of all input files mentioned in [depfilePath] to
54+ /// [digestPath] .
4855 void writeDigest () {
4956 File (digestPath).writeAsStringSync (_computeDigest ());
5057 }
@@ -71,11 +78,7 @@ class Depfile {
7178 .split (' ' )
7279 .map ((item) => item.replaceAll ('\u 0000' , ' ' ));
7380
74- var outputPath = items.first;
75- // Strip off trailing ':'.
76- outputPath = outputPath.substring (0 , outputPath.length - 1 );
77- final result = [outputPath];
78- result.addAll (items.skip (1 ));
81+ final result = items.skip (1 ).toList ();
7982 // File ends in a newline.
8083 result.last = result.last.substring (0 , result.last.length - 1 );
8184 return result;
0 commit comments