Skip to content

Commit 9af6bae

Browse files
author
Jonah Williams
authored
[flutter_tools] pass through enable impeller flag to macOS. (flutter#128720)
Allow passing through the --enable-impeller flag to macOS.
1 parent a70f935 commit 9af6bae

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

packages/flutter_tools/lib/src/desktop_device.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ abstract class DesktopDevice extends Device {
209209
/// steps to be run.
210210
void onAttached(ApplicationPackage package, BuildInfo buildInfo, Process process) {}
211211

212+
bool get supportsImpeller => false;
213+
212214
/// Computes a set of environment variables used to pass debugging information
213215
/// to the engine without interfering with application level command line
214216
/// arguments.
@@ -266,6 +268,15 @@ abstract class DesktopDevice extends Device {
266268
if (debuggingOptions.purgePersistentCache) {
267269
addFlag('purge-persistent-cache=true');
268270
}
271+
if (supportsImpeller) {
272+
switch (debuggingOptions.enableImpeller) {
273+
case ImpellerStatus.enabled:
274+
addFlag('enable-impeller=true');
275+
case ImpellerStatus.disabled:
276+
case ImpellerStatus.platformDefault:
277+
addFlag('enable-impeller=false');
278+
}
279+
}
269280
// Options only supported when there is a VM Service connection between the
270281
// tool and the device, usually in debug or profile mode.
271282
if (debuggingOptions.debuggingEnabled) {

packages/flutter_tools/lib/src/macos/macos_device.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ class MacOSDevice extends DesktopDevice {
4747
@override
4848
String get name => 'macOS';
4949

50+
@override
51+
bool get supportsImpeller => true;
52+
5053
@override
5154
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin;
5255

5356
@override
5457
Future<String> get targetPlatformDisplayName async {
5558
if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm64) {
5659
return 'darwin-arm64';
57-
} else {
58-
return 'darwin-x64';
5960
}
61+
return 'darwin-x64';
6062
}
6163

6264
@override

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,66 @@ void main() {
300300
),
301301
);
302302
});
303+
304+
testWithoutContext('Desktop devices that support impeller pass through the enable-impeller flag', () async {
305+
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
306+
const FakeCommand(
307+
command: <String>['debug'],
308+
exitCode: -1,
309+
environment: <String, String>{
310+
'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true',
311+
'FLUTTER_ENGINE_SWITCH_2': 'enable-impeller=true',
312+
'FLUTTER_ENGINE_SWITCH_3': 'enable-checked-mode=true',
313+
'FLUTTER_ENGINE_SWITCH_4': 'verify-entry-points=true',
314+
'FLUTTER_ENGINE_SWITCHES': '4'
315+
}
316+
),
317+
]);
318+
final FakeDesktopDevice device = setUpDesktopDevice(
319+
processManager: processManager,
320+
supportsImpeller: true,
321+
);
322+
323+
final FakeApplicationPackage package = FakeApplicationPackage();
324+
await device.startApp(
325+
package,
326+
prebuiltApplication: true,
327+
debuggingOptions: DebuggingOptions.enabled(
328+
BuildInfo.debug,
329+
enableImpeller: ImpellerStatus.enabled,
330+
dartEntrypointArgs: <String>[],
331+
),
332+
);
333+
});
334+
335+
testWithoutContext('Desktop devices that do not support impeller ignore the enable-impeller flag', () async {
336+
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
337+
const FakeCommand(
338+
command: <String>['debug'],
339+
exitCode: -1,
340+
environment: <String, String>{
341+
'FLUTTER_ENGINE_SWITCH_1': 'enable-dart-profiling=true',
342+
'FLUTTER_ENGINE_SWITCH_2': 'enable-checked-mode=true',
343+
'FLUTTER_ENGINE_SWITCH_3': 'verify-entry-points=true',
344+
'FLUTTER_ENGINE_SWITCHES': '3'
345+
}
346+
),
347+
]);
348+
final FakeDesktopDevice device = setUpDesktopDevice(
349+
processManager: processManager,
350+
);
351+
352+
final FakeApplicationPackage package = FakeApplicationPackage();
353+
await device.startApp(
354+
package,
355+
prebuiltApplication: true,
356+
debuggingOptions: DebuggingOptions.enabled(
357+
BuildInfo.debug,
358+
enableImpeller: ImpellerStatus.enabled,
359+
dartEntrypointArgs: <String>[],
360+
),
361+
);
362+
});
303363
}
304364

305365
FakeDesktopDevice setUpDesktopDevice({
@@ -308,13 +368,15 @@ FakeDesktopDevice setUpDesktopDevice({
308368
ProcessManager? processManager,
309369
OperatingSystemUtils? operatingSystemUtils,
310370
bool nullExecutablePathForDevice = false,
371+
bool supportsImpeller = false,
311372
}) {
312373
return FakeDesktopDevice(
313374
fileSystem: fileSystem ?? MemoryFileSystem.test(),
314375
logger: logger ?? BufferLogger.test(),
315376
processManager: processManager ?? FakeProcessManager.any(),
316377
operatingSystemUtils: operatingSystemUtils ?? FakeOperatingSystemUtils(),
317378
nullExecutablePathForDevice: nullExecutablePathForDevice,
379+
supportsImpeller: supportsImpeller,
318380
);
319381
}
320382

@@ -326,6 +388,7 @@ class FakeDesktopDevice extends DesktopDevice {
326388
required FileSystem fileSystem,
327389
required OperatingSystemUtils operatingSystemUtils,
328390
this.nullExecutablePathForDevice = false,
391+
this.supportsImpeller = false,
329392
}) : super(
330393
'dummy',
331394
platformType: PlatformType.linux,
@@ -344,6 +407,9 @@ class FakeDesktopDevice extends DesktopDevice {
344407

345408
final bool nullExecutablePathForDevice;
346409

410+
@override
411+
final bool supportsImpeller;
412+
347413
@override
348414
String get name => 'dummy';
349415

0 commit comments

Comments
 (0)