File size: 3,510 Bytes
88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 b0336a8 88b9d23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | // Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:process/process.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/os.dart';
import '../build_info.dart';
import '../desktop_device.dart';
import '../device.dart';
import '../project.dart';
import 'application_package.dart';
import 'build_windows.dart';
import 'windows_workflow.dart';
/// A device that represents a desktop Windows target.
class WindowsDevice extends DesktopDevice {
WindowsDevice({
required ProcessManager processManager,
required Logger logger,
required FileSystem fileSystem,
required OperatingSystemUtils operatingSystemUtils,
}) : _operatingSystemUtils = operatingSystemUtils,
super(
'windows',
platformType: PlatformType.windows,
ephemeral: false,
processManager: processManager,
logger: logger,
fileSystem: fileSystem,
operatingSystemUtils: operatingSystemUtils,
);
final OperatingSystemUtils _operatingSystemUtils;
@override
bool isSupported() => true;
@override
String get name => 'Windows';
@override
Future<TargetPlatform> get targetPlatform async => _targetPlatform;
TargetPlatform get _targetPlatform => switch (_operatingSystemUtils.hostPlatform) {
HostPlatform.windows_arm64 => TargetPlatform.windows_arm64,
_ => TargetPlatform.windows_x64,
};
@override
bool isSupportedForProject(FlutterProject flutterProject) {
return flutterProject.windows.existsSync();
}
@override
Future<void> buildForDevice({
String? mainPath,
required BuildInfo buildInfo,
bool usingCISystem = false,
}) async {
await buildWindows(
FlutterProject.current().windows,
buildInfo,
_targetPlatform,
target: mainPath,
);
}
@override
String executablePathForDevice(covariant WindowsApp package, BuildInfo buildInfo) {
return package.executable(buildInfo.mode, _targetPlatform);
}
}
class WindowsDevices extends PollingDeviceDiscovery {
WindowsDevices({
required ProcessManager processManager,
required Logger logger,
required FileSystem fileSystem,
required OperatingSystemUtils operatingSystemUtils,
required WindowsWorkflow windowsWorkflow,
}) : _fileSystem = fileSystem,
_logger = logger,
_processManager = processManager,
_operatingSystemUtils = operatingSystemUtils,
_windowsWorkflow = windowsWorkflow,
super('windows devices');
final FileSystem _fileSystem;
final Logger _logger;
final ProcessManager _processManager;
final OperatingSystemUtils _operatingSystemUtils;
final WindowsWorkflow _windowsWorkflow;
@override
bool get supportsPlatform => _windowsWorkflow.appliesToHostPlatform;
@override
bool get canListAnything => _windowsWorkflow.canListDevices;
@override
Future<List<Device>> pollingGetDevices({Duration? timeout}) async {
if (!canListAnything) {
return const <Device>[];
}
return <Device>[
WindowsDevice(
fileSystem: _fileSystem,
logger: _logger,
processManager: _processManager,
operatingSystemUtils: _operatingSystemUtils,
),
];
}
@override
Future<List<String>> getDiagnostics() async => const <String>[];
@override
List<String> get wellKnownIds => const <String>['windows'];
}
|