@@ -77,30 +77,9 @@ final class BuildTarget {
77
77
Future <Map <String , BuildTarget >> findTargets (
78
78
Environment environment, Directory buildDir) async {
79
79
final Map <String , BuildTarget > r = < String , BuildTarget > {};
80
- final List <String > getBuildInfoCommandLine = < String > [
81
- gnBinPath (environment),
82
- 'desc' ,
83
- buildDir.path,
84
- '*' ,
85
- '--format=json' ,
86
- ];
87
-
88
- final ProcessRunnerResult result = await environment.processRunner.runProcess (
89
- getBuildInfoCommandLine,
90
- workingDirectory: environment.engine.srcDir,
91
- failOk: true );
92
-
93
- // Handle any process failures.
94
- fatalIfFailed (environment, getBuildInfoCommandLine, result);
95
-
96
- late final Map <String , Object ?> jsonResult;
97
- try {
98
- jsonResult = jsonDecode (result.stdout) as Map <String , Object ?>;
99
- } catch (e) {
100
- environment.logger.fatal (
101
- 'gn desc output could not be parsed:\n E=$e \n IN=${result .stdout }\n ' );
102
- }
103
80
81
+ final Map <String , Object ?> jsonResult =
82
+ await _gnDesc (buildDir.path, '*' , environment);
104
83
for (final MapEntry <String , Object ?> targetEntry in jsonResult.entries) {
105
84
final String label = targetEntry.key;
106
85
if (targetEntry.value == null ) {
@@ -120,7 +99,7 @@ Future<Map<String, BuildTarget>> findTargets(
120
99
}
121
100
final bool testOnly = getBool (properties, 'testonly' );
122
101
final List <String > outputs =
123
- getListOfString (properties, 'outputs' ) ?? < String > [] ;
102
+ await _gnOutputs (buildDir.path, label, environment) ;
124
103
File ? executable;
125
104
if (type == BuildTargetType .executable) {
126
105
if (outputs.isEmpty) {
@@ -135,6 +114,48 @@ Future<Map<String, BuildTarget>> findTargets(
135
114
return r;
136
115
}
137
116
117
+ Future <Map <String , Object ?>> _gnDesc (
118
+ String buildDir, String label, Environment environment) async {
119
+ final List <String > getBuildInfoCommandLine = < String > [
120
+ gnBinPath (environment),
121
+ 'desc' ,
122
+ buildDir,
123
+ label,
124
+ '--format=json' ,
125
+ ];
126
+
127
+ final ProcessRunnerResult result = await environment.processRunner.runProcess (
128
+ getBuildInfoCommandLine,
129
+ workingDirectory: environment.engine.srcDir,
130
+ failOk: true );
131
+
132
+ // Handle any process failures.
133
+ fatalIfFailed (environment, getBuildInfoCommandLine, result);
134
+
135
+ late final Map <String , Object ?> jsonResult;
136
+ try {
137
+ jsonResult = jsonDecode (result.stdout) as Map <String , Object ?>;
138
+ } catch (e) {
139
+ environment.logger.fatal (
140
+ 'gn desc output could not be parsed:\n E=$e \n IN=${result .stdout }\n ' );
141
+ }
142
+ return jsonResult;
143
+ }
144
+
145
+ Future <List <String >> _gnOutputs (
146
+ String buildDir, String label, Environment environment) async {
147
+ final List <String > getOutputsCommandLine = < String > [
148
+ gnBinPath (environment),
149
+ 'outputs' ,
150
+ buildDir,
151
+ label,
152
+ ];
153
+ final ProcessRunnerResult outputsResult = await environment.processRunner
154
+ .runProcess (getOutputsCommandLine,
155
+ workingDirectory: environment.engine.srcDir, failOk: true );
156
+ return outputsResult.stdout.split ('\n ' );
157
+ }
158
+
138
159
/// Process selectors and filter allTargets for matches.
139
160
///
140
161
/// We support:
0 commit comments