@@ -14,18 +14,25 @@ import 'package:meta/meta.dart';
14
14
/// It contains the output path followed by a colon then a space-separated list
15
15
/// of input paths. Spaces in paths are backslash-escaped.
16
16
class Depfile {
17
+ final String outputPath;
17
18
final String depfilePath;
18
19
final String digestPath;
19
20
20
- /// Input and output paths parsed from the depfile.
21
+ /// Input paths parsed from the depfile.
21
22
Set <String >? _depfilePaths;
22
23
23
- Depfile ({required this .depfilePath, required this .digestPath});
24
+ Depfile ({
25
+ required this .outputPath,
26
+ required this .depfilePath,
27
+ required this .digestPath,
28
+ });
24
29
25
- /// Checks whether the output mentioned in the depfile is fresh.
30
+ /// Checks whether the inputs mentioned in the depfile are fresh.
26
31
///
27
32
/// It is fresh if it has not changed and none of its inputs have changed.
28
33
FreshnessResult checkFreshness () {
34
+ final outputFile = File (outputPath);
35
+ if (! outputFile.existsSync ()) return FreshnessResult (outputIsFresh: false );
29
36
final depsFile = File (depfilePath);
30
37
if (! depsFile.existsSync ()) return FreshnessResult (outputIsFresh: false );
31
38
final digestFile = File (digestPath);
@@ -43,8 +50,8 @@ class Depfile {
43
50
/// [writeDigest] , throws if neither was called.
44
51
bool isDependency (String path) => _depfilePaths! .contains (path);
45
52
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] .
48
55
void writeDigest () {
49
56
File (digestPath).writeAsStringSync (_computeDigest ());
50
57
}
@@ -71,11 +78,7 @@ class Depfile {
71
78
.split (' ' )
72
79
.map ((item) => item.replaceAll ('\u 0000' , ' ' ));
73
80
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 ();
79
82
// File ends in a newline.
80
83
result.last = result.last.substring (0 , result.last.length - 1 );
81
84
return result;
0 commit comments