Skip to content

Commit 423ca3d

Browse files
authored
Stop digesting dill output. (#4232)
1 parent 7dc2870 commit 423ca3d

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

build_runner/lib/src/bootstrap/depfile.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
1616
class 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('\u0000', ' '));
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;

build_runner/lib/src/bootstrap/kernel_compiler.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const entrypointDillDigestPath = '$entrypointScriptPath.dill.digest';
1515
/// Compiles the build script to kernel.
1616
class KernelCompiler {
1717
final Depfile _outputDepfile = Depfile(
18+
outputPath: entrypointDillPath,
1819
depfilePath: entrypointDillDepfilePath,
1920
digestPath: entrypointDillDigestPath,
2021
);

build_runner/test/bootstrap/depfile_test.dart

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import 'package:test/test.dart';
88
void main() {
99
group('Depfile', () {
1010
test('parses', () async {
11-
expect(Depfile.parse('output: input1 input2\n'), [
12-
'output',
13-
'input1',
14-
'input2',
15-
]);
11+
expect(Depfile.parse('output: input1 input2\n'), ['input1', 'input2']);
1612
});
1713

1814
test('parses when filenames have spaces and backslashes', () async {
@@ -21,14 +17,7 @@ void main() {
2117
r'output: input1 input2 input\ with\ space input4 path\\input5'
2218
'\n',
2319
),
24-
[
25-
'output',
26-
'input1',
27-
'input2',
28-
'input with space',
29-
'input4',
30-
r'path\input5',
31-
],
20+
['input1', 'input2', 'input with space', 'input4', r'path\input5'],
3221
);
3322
});
3423
});

0 commit comments

Comments
 (0)