Skip to content

Commit 026adb8

Browse files
authored
Adds vmservices for getting iOS build options (#121736)
Adds vmservices for getting iOS build options
1 parent 33ffdd7 commit 026adb8

File tree

11 files changed

+198
-87
lines changed

11 files changed

+198
-87
lines changed

packages/flutter_tools/lib/src/isolated/resident_web_runner.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,18 +560,13 @@ class ResidentWebRunner extends ResidentRunner {
560560
// thrown if we're not already subscribed.
561561
}
562562
await setUpVmService(
563-
(String isolateId, {
564-
bool? force,
565-
bool? pause,
566-
}) async {
563+
reloadSources: (String isolateId, {bool? force, bool? pause}) async {
567564
await restart(pause: pause);
568565
},
569-
null,
570-
null,
571-
device!.device,
572-
null,
573-
printStructuredErrorLog,
574-
_vmService.service,
566+
device: device!.device,
567+
flutterProject: flutterProject,
568+
printStructuredErrorLogMethod: printStructuredErrorLog,
569+
vmService: _vmService.service,
575570
);
576571

577572

packages/flutter_tools/lib/src/resident_runner.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class FlutterDevice {
329329
restart: restart,
330330
compileExpression: compileExpression,
331331
getSkSLMethod: getSkSLMethod,
332+
flutterProject: FlutterProject.current(),
332333
printStructuredErrorLogMethod: printStructuredErrorLogMethod,
333334
device: device,
334335
logger: globals.logger,

packages/flutter_tools/lib/src/vmservice.dart

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ import 'base/logger.dart';
1414
import 'base/utils.dart';
1515
import 'convert.dart';
1616
import 'device.dart';
17+
import 'ios/xcodeproj.dart';
18+
import 'project.dart';
1719
import 'version.dart';
1820

21+
const String kResultType = 'type';
22+
const String kResultTypeSuccess = 'Success';
23+
1924
const String kGetSkSLsMethod = '_flutter.getSkSLs';
2025
const String kSetAssetBundlePathMethod = '_flutter.setAssetBundlePath';
2126
const String kFlushUIThreadTasksMethod = '_flutter.flushUIThreadTasks';
@@ -165,6 +170,7 @@ typedef VMServiceConnector = Future<FlutterVmService> Function(Uri httpUri, {
165170
Restart? restart,
166171
CompileExpression? compileExpression,
167172
GetSkSLMethod? getSkSLMethod,
173+
FlutterProject? flutterProject,
168174
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
169175
io.CompressionOptions compression,
170176
Device? device,
@@ -175,15 +181,16 @@ typedef VMServiceConnector = Future<FlutterVmService> Function(Uri httpUri, {
175181
/// callbacks.
176182
///
177183
/// All parameters besides [vmService] may be null.
178-
Future<vm_service.VmService> setUpVmService(
184+
Future<vm_service.VmService> setUpVmService({
179185
ReloadSources? reloadSources,
180186
Restart? restart,
181187
CompileExpression? compileExpression,
182188
Device? device,
183189
GetSkSLMethod? skSLMethod,
190+
FlutterProject? flutterProject,
184191
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
185-
vm_service.VmService vmService
186-
) async {
192+
required vm_service.VmService vmService,
193+
}) async {
187194
// Each service registration requires a request to the attached VM service. Since the
188195
// order of these requests does not matter, store each future in a list and await
189196
// all at the end of this method.
@@ -198,7 +205,7 @@ Future<vm_service.VmService> setUpVmService(
198205

199206
return <String, Object>{
200207
'result': <String, Object>{
201-
'type': 'Success',
208+
kResultType: kResultTypeSuccess,
202209
},
203210
};
204211
});
@@ -211,7 +218,7 @@ Future<vm_service.VmService> setUpVmService(
211218
await restart(pause: pause);
212219
return <String, Object>{
213220
'result': <String, Object>{
214-
'type': 'Success',
221+
kResultType: kResultTypeSuccess,
215222
},
216223
};
217224
});
@@ -225,7 +232,7 @@ Future<vm_service.VmService> setUpVmService(
225232
versionJson['engineRevisionShort'] = version.engineRevisionShort;
226233
return <String, Object>{
227234
'result': <String, Object>{
228-
'type': 'Success',
235+
kResultType: kResultTypeSuccess,
229236
...versionJson,
230237
},
231238
};
@@ -246,7 +253,7 @@ Future<vm_service.VmService> setUpVmService(
246253
expression, definitions, typeDefinitions, libraryUri, klass,
247254
isStatic);
248255
return <String, Object>{
249-
'type': 'Success',
256+
kResultType: kResultTypeSuccess,
250257
'result': <String, String>{'kernelBytes': kernelBytesBase64},
251258
};
252259
});
@@ -257,7 +264,7 @@ Future<vm_service.VmService> setUpVmService(
257264
final MemoryInfo result = await device.queryMemoryInfo();
258265
return <String, Object>{
259266
'result': <String, Object>{
260-
'type': 'Success',
267+
kResultType: kResultTypeSuccess,
261268
...result.toJson(),
262269
},
263270
};
@@ -270,19 +277,44 @@ Future<vm_service.VmService> setUpVmService(
270277
if (filename == null) {
271278
return <String, Object>{
272279
'result': <String, Object>{
273-
'type': 'Success',
280+
kResultType: kResultTypeSuccess,
274281
},
275282
};
276283
}
277284
return <String, Object>{
278285
'result': <String, Object>{
279-
'type': 'Success',
286+
kResultType: kResultTypeSuccess,
280287
'filename': filename,
281288
},
282289
};
283290
});
284291
registrationRequests.add(vmService.registerService('flutterGetSkSL', 'Flutter Tools'));
285292
}
293+
294+
if (flutterProject != null) {
295+
vmService.registerServiceCallback('flutterGetIOSBuildOptions', (Map<String, Object?> params) async {
296+
final XcodeProjectInfo? info = await flutterProject.ios.projectInfo();
297+
if (info == null) {
298+
return <String, Object>{
299+
'result': <String, Object>{
300+
kResultType: kResultTypeSuccess,
301+
},
302+
};
303+
}
304+
return <String, Object>{
305+
'result': <String, Object>{
306+
kResultType: kResultTypeSuccess,
307+
'targets': info.targets,
308+
'schemes': info.schemes,
309+
'buildConfigurations': info.buildConfigurations,
310+
},
311+
};
312+
});
313+
registrationRequests.add(
314+
vmService.registerService('flutterGetIOSBuildOptions', 'Flutter Tools'),
315+
);
316+
}
317+
286318
if (printStructuredErrorLogMethod != null) {
287319
vmService.onExtensionEvent.listen(printStructuredErrorLogMethod);
288320
registrationRequests.add(vmService
@@ -319,15 +351,16 @@ Future<vm_service.VmService> setUpVmService(
319351
/// See: https://github.com/dart-lang/sdk/commit/df8bf384eb815cf38450cb50a0f4b62230fba217
320352
Future<FlutterVmService> connectToVmService(
321353
Uri httpUri, {
322-
ReloadSources? reloadSources,
323-
Restart? restart,
324-
CompileExpression? compileExpression,
325-
GetSkSLMethod? getSkSLMethod,
326-
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
327-
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
328-
Device? device,
329-
required Logger logger,
330-
}) async {
354+
ReloadSources? reloadSources,
355+
Restart? restart,
356+
CompileExpression? compileExpression,
357+
GetSkSLMethod? getSkSLMethod,
358+
FlutterProject? flutterProject,
359+
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
360+
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
361+
Device? device,
362+
required Logger logger,
363+
}) async {
331364
final VMServiceConnector connector = context.get<VMServiceConnector>() ?? _connect;
332365
return connector(httpUri,
333366
reloadSources: reloadSources,
@@ -336,6 +369,7 @@ Future<FlutterVmService> connectToVmService(
336369
compression: compression,
337370
device: device,
338371
getSkSLMethod: getSkSLMethod,
372+
flutterProject: flutterProject,
339373
printStructuredErrorLogMethod: printStructuredErrorLogMethod,
340374
logger: logger,
341375
);
@@ -362,6 +396,7 @@ Future<FlutterVmService> _connect(
362396
Restart? restart,
363397
CompileExpression? compileExpression,
364398
GetSkSLMethod? getSkSLMethod,
399+
FlutterProject? flutterProject,
365400
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
366401
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
367402
Device? device,
@@ -373,13 +408,14 @@ Future<FlutterVmService> _connect(
373408
);
374409

375410
final vm_service.VmService service = await setUpVmService(
376-
reloadSources,
377-
restart,
378-
compileExpression,
379-
device,
380-
getSkSLMethod,
381-
printStructuredErrorLogMethod,
382-
delegateService,
411+
reloadSources: reloadSources,
412+
restart: restart,
413+
compileExpression: compileExpression,
414+
device: device,
415+
skSLMethod: getSkSLMethod,
416+
flutterProject: flutterProject,
417+
printStructuredErrorLogMethod: printStructuredErrorLogMethod,
418+
vmService: delegateService,
383419
);
384420

385421
// This call is to ensure we are able to establish a connection instead of

packages/flutter_tools/test/general.shard/cold_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
1111
import 'package:flutter_tools/src/compile.dart';
1212
import 'package:flutter_tools/src/devfs.dart';
1313
import 'package:flutter_tools/src/device.dart';
14+
import 'package:flutter_tools/src/project.dart';
1415
import 'package:flutter_tools/src/resident_runner.dart';
1516
import 'package:flutter_tools/src/run_cold.dart';
1617
import 'package:flutter_tools/src/tracing.dart';
@@ -213,6 +214,7 @@ class TestFlutterDevice extends FlutterDevice {
213214
Restart? restart,
214215
CompileExpression? compileExpression,
215216
GetSkSLMethod? getSkSLMethod,
217+
FlutterProject? flutterProject,
216218
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
217219
bool enableDds = true,
218220
bool cacheStartupProfile = false,

packages/flutter_tools/test/general.shard/drive/drive_service_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_info.dart';
1515
import 'package:flutter_tools/src/convert.dart';
1616
import 'package:flutter_tools/src/device.dart';
1717
import 'package:flutter_tools/src/drive/drive_service.dart';
18+
import 'package:flutter_tools/src/project.dart';
1819
import 'package:flutter_tools/src/resident_runner.dart';
1920
import 'package:flutter_tools/src/version.dart';
2021
import 'package:flutter_tools/src/vmservice.dart';
@@ -443,6 +444,7 @@ FlutterDriverService setUpDriverService({
443444
Restart? restart,
444445
CompileExpression? compileExpression,
445446
GetSkSLMethod? getSkSLMethod,
447+
FlutterProject? flutterProject,
446448
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
447449
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
448450
Device? device,

packages/flutter_tools/test/general.shard/hot_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_system/targets/shader_compiler.dart';
1616
import 'package:flutter_tools/src/compile.dart';
1717
import 'package:flutter_tools/src/devfs.dart';
1818
import 'package:flutter_tools/src/device.dart';
19+
import 'package:flutter_tools/src/project.dart';
1920
import 'package:flutter_tools/src/reporting/reporting.dart';
2021
import 'package:flutter_tools/src/resident_devtools_handler.dart';
2122
import 'package:flutter_tools/src/resident_runner.dart';
@@ -678,6 +679,7 @@ class TestFlutterDevice extends FlutterDevice {
678679
Restart? restart,
679680
CompileExpression? compileExpression,
680681
GetSkSLMethod? getSkSLMethod,
682+
FlutterProject? flutterProject,
681683
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
682684
bool disableServiceAuthCodes = false,
683685
bool enableDds = true,

packages/flutter_tools/test/general.shard/integration_test_device_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart' as io;
88
import 'package:flutter_tools/src/base/logger.dart';
99
import 'package:flutter_tools/src/build_info.dart';
1010
import 'package:flutter_tools/src/device.dart';
11+
import 'package:flutter_tools/src/project.dart';
1112
import 'package:flutter_tools/src/test/integration_test_device.dart';
1213
import 'package:flutter_tools/src/test/test_device.dart';
1314
import 'package:flutter_tools/src/vmservice.dart';
@@ -135,6 +136,7 @@ void main() {
135136
Restart? restart,
136137
CompileExpression? compileExpression,
137138
GetSkSLMethod? getSkSLMethod,
139+
FlutterProject? flutterProject,
138140
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
139141
io.CompressionOptions? compression,
140142
Device? device,
@@ -154,6 +156,7 @@ void main() {
154156
Restart? restart,
155157
CompileExpression? compileExpression,
156158
GetSkSLMethod? getSkSLMethod,
159+
FlutterProject? flutterProject,
157160
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
158161
io.CompressionOptions? compression,
159162
Device? device,
@@ -184,6 +187,7 @@ void main() {
184187
Restart? restart,
185188
CompileExpression? compileExpression,
186189
GetSkSLMethod? getSkSLMethod,
190+
FlutterProject? flutterProject,
187191
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
188192
io.CompressionOptions? compression,
189193
Device? device,
@@ -213,6 +217,7 @@ void main() {
213217
Restart? restart,
214218
CompileExpression? compileExpression,
215219
GetSkSLMethod? getSkSLMethod,
220+
FlutterProject? flutterProject,
216221
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
217222
io.CompressionOptions? compression,
218223
Device? device,
@@ -230,6 +235,7 @@ void main() {
230235
Restart? restart,
231236
CompileExpression? compileExpression,
232237
GetSkSLMethod? getSkSLMethod,
238+
FlutterProject? flutterProject,
233239
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
234240
io.CompressionOptions? compression,
235241
Device? device,

packages/flutter_tools/test/general.shard/resident_runner_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import 'package:flutter_tools/src/device.dart';
2727
import 'package:flutter_tools/src/device_port_forwarder.dart';
2828
import 'package:flutter_tools/src/features.dart';
2929
import 'package:flutter_tools/src/globals.dart' as globals;
30+
import 'package:flutter_tools/src/project.dart';
3031
import 'package:flutter_tools/src/reporting/reporting.dart';
3132
import 'package:flutter_tools/src/resident_devtools_handler.dart';
3233
import 'package:flutter_tools/src/resident_runner.dart';
@@ -2147,6 +2148,7 @@ flutter:
21472148
Restart? restart,
21482149
CompileExpression? compileExpression,
21492150
GetSkSLMethod? getSkSLMethod,
2151+
FlutterProject? flutterProject,
21502152
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
21512153
io.CompressionOptions? compression,
21522154
Device? device,
@@ -2181,6 +2183,7 @@ flutter:
21812183
Restart? restart,
21822184
CompileExpression? compileExpression,
21832185
GetSkSLMethod? getSkSLMethod,
2186+
FlutterProject? flutterProject,
21842187
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
21852188
io.CompressionOptions? compression,
21862189
Device? device,
@@ -2214,6 +2217,7 @@ flutter:
22142217
Restart? restart,
22152218
CompileExpression? compileExpression,
22162219
GetSkSLMethod? getSkSLMethod,
2220+
FlutterProject? flutterProject,
22172221
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
22182222
io.CompressionOptions? compression,
22192223
Device? device,
@@ -2248,6 +2252,7 @@ flutter:
22482252
Restart? restart,
22492253
CompileExpression? compileExpression,
22502254
GetSkSLMethod? getSkSLMethod,
2255+
FlutterProject? flutterProject,
22512256
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
22522257
io.CompressionOptions? compression,
22532258
Device? device,
@@ -2289,6 +2294,7 @@ flutter:
22892294
Restart? restart,
22902295
CompileExpression? compileExpression,
22912296
GetSkSLMethod? getSkSLMethod,
2297+
FlutterProject? flutterProject,
22922298
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
22932299
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
22942300
Device? device,
@@ -2344,6 +2350,7 @@ flutter:
23442350
Restart? restart,
23452351
CompileExpression? compileExpression,
23462352
GetSkSLMethod? getSkSLMethod,
2353+
FlutterProject? flutterProject,
23472354
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
23482355
io.CompressionOptions compression = io.CompressionOptions.compressionDefault,
23492356
Device? device,
@@ -2576,6 +2583,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
25762583
Restart? restart,
25772584
CompileExpression? compileExpression,
25782585
GetSkSLMethod? getSkSLMethod,
2586+
FlutterProject? flutterProject,
25792587
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
25802588
int? hostVmServicePort,
25812589
int? ddsPort,
@@ -2629,6 +2637,7 @@ class FakeDelegateFlutterDevice extends FlutterDevice {
26292637
bool ipv6 = false,
26302638
CompileExpression? compileExpression,
26312639
GetSkSLMethod? getSkSLMethod,
2640+
FlutterProject? flutterProject,
26322641
int? hostVmServicePort,
26332642
int? ddsPort,
26342643
PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,

0 commit comments

Comments
 (0)