Show macOS arm64 architecture in doctor and devices list (#69245)
This commit is contained in:
parent
bd121ecd22
commit
de5bf09e7a
@ -621,6 +621,10 @@ abstract class Device {
|
|||||||
/// The device's platform.
|
/// The device's platform.
|
||||||
Future<TargetPlatform> get targetPlatform;
|
Future<TargetPlatform> get targetPlatform;
|
||||||
|
|
||||||
|
/// Platform name for display only.
|
||||||
|
Future<String> get targetPlatformDisplayName async =>
|
||||||
|
getNameForTargetPlatform(await targetPlatform);
|
||||||
|
|
||||||
Future<String> get sdkNameAndVersion;
|
Future<String> get sdkNameAndVersion;
|
||||||
|
|
||||||
/// Create a platform-specific [DevFSWriter] for the given [app], or
|
/// Create a platform-specific [DevFSWriter] for the given [app], or
|
||||||
@ -749,7 +753,7 @@ abstract class Device {
|
|||||||
table.add(<String>[
|
table.add(<String>[
|
||||||
'${device.name} (${device.category})',
|
'${device.name} (${device.category})',
|
||||||
device.id,
|
device.id,
|
||||||
getNameForTargetPlatform(targetPlatform),
|
await device.targetPlatformDisplayName,
|
||||||
'${await device.sdkNameAndVersion}$supportIndicator',
|
'${await device.sdkNameAndVersion}$supportIndicator',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
@required OperatingSystemUtils operatingSystemUtils,
|
@required OperatingSystemUtils operatingSystemUtils,
|
||||||
}) : _processManager = processManager,
|
}) : _processManager = processManager,
|
||||||
_logger = logger,
|
_logger = logger,
|
||||||
|
_operatingSystemUtils = operatingSystemUtils,
|
||||||
super(
|
super(
|
||||||
'macos',
|
'macos',
|
||||||
platformType: PlatformType.macos,
|
platformType: PlatformType.macos,
|
||||||
@ -39,6 +40,7 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
|
|
||||||
final ProcessManager _processManager;
|
final ProcessManager _processManager;
|
||||||
final Logger _logger;
|
final Logger _logger;
|
||||||
|
final OperatingSystemUtils _operatingSystemUtils;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isSupported() => true;
|
bool isSupported() => true;
|
||||||
@ -46,9 +48,20 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
@override
|
@override
|
||||||
String get name => 'macOS';
|
String get name => 'macOS';
|
||||||
|
|
||||||
|
/// Returns [TargetPlatform.darwin_x64] even on macOS ARM devices.
|
||||||
|
///
|
||||||
|
/// Build system, artifacts rely on Rosetta to translate to x86_64 on ARM.
|
||||||
@override
|
@override
|
||||||
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin_x64;
|
Future<TargetPlatform> get targetPlatform async => TargetPlatform.darwin_x64;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> get targetPlatformDisplayName async {
|
||||||
|
if (_operatingSystemUtils.hostPlatform == HostPlatform.darwin_arm) {
|
||||||
|
return 'darwin-arm64';
|
||||||
|
}
|
||||||
|
return super.targetPlatformDisplayName;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isSupportedForProject(FlutterProject flutterProject) {
|
bool isSupportedForProject(FlutterProject flutterProject) {
|
||||||
return flutterProject.macos.existsSync();
|
return flutterProject.macos.existsSync();
|
||||||
|
@ -604,6 +604,9 @@ void main() {
|
|||||||
when(device.id).thenReturn(id);
|
when(device.id).thenReturn(id);
|
||||||
when(device.isLocalEmulator).thenAnswer((_) async => false);
|
when(device.isLocalEmulator).thenAnswer((_) async => false);
|
||||||
when(device.sdkNameAndVersion).thenAnswer((_) async => 'Android 46');
|
when(device.sdkNameAndVersion).thenAnswer((_) async => 'Android 46');
|
||||||
|
when(device.targetPlatformDisplayName)
|
||||||
|
.thenAnswer((_) async => 'android');
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,5 +1059,6 @@ class MockDevice extends Mock implements Device {
|
|||||||
when(id).thenReturn('device-id');
|
when(id).thenReturn('device-id');
|
||||||
when(isLocalEmulator).thenAnswer((_) => Future<bool>.value(false));
|
when(isLocalEmulator).thenAnswer((_) => Future<bool>.value(false));
|
||||||
when(targetPlatform).thenAnswer((_) => Future<TargetPlatform>.value(TargetPlatform.android));
|
when(targetPlatform).thenAnswer((_) => Future<TargetPlatform>.value(TargetPlatform.android));
|
||||||
|
when(targetPlatformDisplayName).thenAnswer((_) async => 'android');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,8 @@ void main() {
|
|||||||
when(mockDevice.id).thenReturn('mock-id');
|
when(mockDevice.id).thenReturn('mock-id');
|
||||||
when(mockDevice.name).thenReturn('mock-name');
|
when(mockDevice.name).thenReturn('mock-name');
|
||||||
when(mockDevice.platformType).thenReturn(PlatformType.android);
|
when(mockDevice.platformType).thenReturn(PlatformType.android);
|
||||||
|
when(mockDevice.targetPlatformDisplayName)
|
||||||
|
.thenAnswer((Invocation invocation) async => 'mock-platform');
|
||||||
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('api-14'));
|
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('api-14'));
|
||||||
|
|
||||||
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) {
|
||||||
|
@ -166,6 +166,34 @@ void main() {
|
|||||||
expect(device.isSupportedForProject(flutterProject), true);
|
expect(device.isSupportedForProject(flutterProject), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWithoutContext('target platform display name on x86_64', () async {
|
||||||
|
final FakeOperatingSystemUtils fakeOperatingSystemUtils =
|
||||||
|
FakeOperatingSystemUtils();
|
||||||
|
fakeOperatingSystemUtils.hostPlatform = HostPlatform.darwin_x64;
|
||||||
|
final MacOSDevice device = MacOSDevice(
|
||||||
|
fileSystem: MemoryFileSystem.test(),
|
||||||
|
logger: BufferLogger.test(),
|
||||||
|
processManager: FakeProcessManager.any(),
|
||||||
|
operatingSystemUtils: fakeOperatingSystemUtils,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await device.targetPlatformDisplayName, 'darwin-x64');
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('target platform display name on ARM', () async {
|
||||||
|
final FakeOperatingSystemUtils fakeOperatingSystemUtils =
|
||||||
|
FakeOperatingSystemUtils();
|
||||||
|
fakeOperatingSystemUtils.hostPlatform = HostPlatform.darwin_arm;
|
||||||
|
final MacOSDevice device = MacOSDevice(
|
||||||
|
fileSystem: MemoryFileSystem.test(),
|
||||||
|
logger: BufferLogger.test(),
|
||||||
|
processManager: FakeProcessManager.any(),
|
||||||
|
operatingSystemUtils: fakeOperatingSystemUtils,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await device.targetPlatformDisplayName, 'darwin-arm64');
|
||||||
|
});
|
||||||
|
|
||||||
testUsingContext('isSupportedForProject is false with no host app', () async {
|
testUsingContext('isSupportedForProject is false with no host app', () async {
|
||||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||||
final MacOSDevice device = MacOSDevice(
|
final MacOSDevice device = MacOSDevice(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user