mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

It's now possible to natively compile a flutter app for windows-arm64. Cross-compilation is not yet implemented. Uses arm64 artifacts now available for Dart/Flutter. Platform detection is based on Abi class, provided by Dart. Depending if Dart is an arm64 or x64 binary, the Abi is set accordingly. Initial bootstrap of dart artifacts (update_dart_sdk.ps1) is checking PROCESSOR_ARCHITECTURE environment variable, which is the way to detect host architecture on Windows. This is available only for master channel (on other channels, it fallbacks to windows-x64). On windows-x64, it produces an x64 app. On windows-arm64, it produces an arm64 app.
83 lines
2.7 KiB
Dart
83 lines
2.7 KiB
Dart
// 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 'package:meta/meta.dart';
|
|
|
|
import '../base/analyze_size.dart';
|
|
import '../base/common.dart';
|
|
import '../base/os.dart';
|
|
import '../build_info.dart';
|
|
import '../cache.dart';
|
|
import '../features.dart';
|
|
import '../globals.dart' as globals;
|
|
import '../project.dart';
|
|
import '../runner/flutter_command.dart' show FlutterCommandResult;
|
|
import '../windows/build_windows.dart';
|
|
import '../windows/visual_studio.dart';
|
|
import 'build.dart';
|
|
|
|
/// A command to build a windows desktop target through a build shell script.
|
|
class BuildWindowsCommand extends BuildSubCommand {
|
|
BuildWindowsCommand({
|
|
required super.logger,
|
|
required OperatingSystemUtils operatingSystemUtils,
|
|
bool verboseHelp = false,
|
|
}) : _operatingSystemUtils = operatingSystemUtils,
|
|
super(verboseHelp: verboseHelp) {
|
|
addCommonDesktopBuildOptions(verboseHelp: verboseHelp);
|
|
}
|
|
|
|
final OperatingSystemUtils _operatingSystemUtils;
|
|
|
|
@override
|
|
final String name = 'windows';
|
|
|
|
@override
|
|
bool get hidden => !featureFlags.isWindowsEnabled || !globals.platform.isWindows;
|
|
|
|
@override
|
|
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
|
|
DevelopmentArtifact.windows,
|
|
};
|
|
|
|
@override
|
|
String get description => 'Build a Windows desktop application.';
|
|
|
|
@visibleForTesting
|
|
VisualStudio? visualStudioOverride;
|
|
|
|
@override
|
|
Future<FlutterCommandResult> runCommand() async {
|
|
final FlutterProject flutterProject = FlutterProject.current();
|
|
final BuildInfo buildInfo = await getBuildInfo();
|
|
if (!featureFlags.isWindowsEnabled) {
|
|
throwToolExit('"build windows" is not currently supported. To enable, run "flutter config --enable-windows-desktop".');
|
|
}
|
|
if (!globals.platform.isWindows) {
|
|
throwToolExit('"build windows" only supported on Windows hosts.');
|
|
}
|
|
|
|
final String defaultTargetPlatform = (_operatingSystemUtils.hostPlatform == HostPlatform.windows_arm64) ?
|
|
'windows-arm64' : 'windows-x64';
|
|
final TargetPlatform targetPlatform = getTargetPlatformForName(defaultTargetPlatform);
|
|
|
|
displayNullSafetyMode(buildInfo);
|
|
await buildWindows(
|
|
flutterProject.windows,
|
|
buildInfo,
|
|
targetPlatform,
|
|
target: targetFile,
|
|
visualStudioOverride: visualStudioOverride,
|
|
sizeAnalyzer: SizeAnalyzer(
|
|
fileSystem: globals.fs,
|
|
logger: globals.logger,
|
|
appFilenamePattern: 'app.so',
|
|
flutterUsage: globals.flutterUsage,
|
|
analytics: analytics,
|
|
),
|
|
);
|
|
return FlutterCommandResult.success();
|
|
}
|
|
}
|