@@ -51,9 +51,30 @@ void main(List<String> args) {
51
51
}
52
52
53
53
String ? clangd = results['clangd' ] as String ? ;
54
- final Map <String , Object ?> entry = compileCommands.first! as Map <String , Object ?>;
54
+ // To improve determinism, check the first clangd item that matches the asset fixture file.
55
+ Map <String , Object ?>? selectedEntry;
56
+ for (final Object ? entry in compileCommands) {
57
+ if (entry is Map <String , Object ?>) {
58
+ final String ? file = entry['file' ] as String ? ;
59
+ if (file != null && file.endsWith ('_fl__fl_assets_fixtures.cc' )) {
60
+ selectedEntry = entry;
61
+ break ;
62
+ }
63
+ } else {
64
+ io.stderr.writeln ('Unexpected: compile_commands.json has an unexpected format' );
65
+ io.stderr.writeln ('First entry: ${const JsonEncoder .withIndent (' ' ).convert (entry )}' );
66
+ io.exitCode = 1 ;
67
+ return ;
68
+ }
69
+ }
70
+ if (selectedEntry == null ) {
71
+ io.stderr.writeln ('No compile_commands.json entry found for _fl__fl_assets_fixtures.cc' );
72
+ io.exitCode = 1 ;
73
+ return ;
74
+ }
75
+
55
76
final String checkFile;
56
- if (entry case {
77
+ if (selectedEntry case {
57
78
'command' : final String command,
58
79
'directory' : final String directory,
59
80
'file' : final String file,
@@ -94,7 +115,7 @@ void main(List<String> args) {
94
115
}
95
116
} else {
96
117
io.stderr.writeln ('Unexpected: compile_commands.json has an unexpected format' );
97
- io.stderr.writeln ('First entry: ${const JsonEncoder .withIndent (' ' ).convert (entry )}' );
118
+ io.stderr.writeln ('First entry: ${const JsonEncoder .withIndent (' ' ).convert (selectedEntry )}' );
98
119
io.exitCode = 1 ;
99
120
return ;
100
121
}
@@ -134,7 +155,7 @@ void main(List<String> args) {
134
155
}
135
156
} on io.ProcessException catch (e) {
136
157
io.stderr.writeln ('Failed to run clangd: $e ' );
137
- io.stderr.writeln (const JsonEncoder .withIndent (' ' ).convert (entry ));
158
+ io.stderr.writeln (const JsonEncoder .withIndent (' ' ).convert (selectedEntry ));
138
159
io.exitCode = 1 ;
139
160
} finally {
140
161
// Remove the copied .clangd file from the engine root directory.
0 commit comments