Reverts "Enable native compilation for windows-arm64 " (#141809)

Reverts flutter/flutter#137618
Initiated by: Jasguerrero
This change reverts the following previous change:
Original Description:
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.
This commit is contained in:
auto-submit[bot]
2024-01-18 22:48:16 +00:00
committed by GitHub
parent 9d9bd884ea
commit 1901d6fa10
41 changed files with 110 additions and 258 deletions

View File

@@ -78,7 +78,7 @@ abstract class WindowsApp extends ApplicationPackage {
@override
String get displayName => id;
String executable(BuildMode buildMode, TargetPlatform targetPlatform);
String executable(BuildMode buildMode);
}
class PrebuiltWindowsApp extends WindowsApp implements PrebuiltApplicationPackage {
@@ -91,7 +91,7 @@ class PrebuiltWindowsApp extends WindowsApp implements PrebuiltApplicationPackag
final String _executable;
@override
String executable(BuildMode buildMode, TargetPlatform targetPlatform) => _executable;
String executable(BuildMode buildMode) => _executable;
@override
String get name => _executable;
@@ -108,10 +108,10 @@ class BuildableWindowsApp extends WindowsApp {
final WindowsProject project;
@override
String executable(BuildMode buildMode, TargetPlatform targetPlatform) {
String executable(BuildMode buildMode) {
final String? binaryName = getCmakeExecutableName(project);
return globals.fs.path.join(
getWindowsBuildDirectory(targetPlatform),
getWindowsBuildDirectory(TargetPlatform.windows_x64),
'runner',
sentenceCase(buildMode.cliName),
'$binaryName.exe',

View File

@@ -30,10 +30,7 @@ import 'visual_studio.dart';
const String _kBadCharacters = r"'#!$^&*=|,;<>?";
/// Builds the Windows project using msbuild.
Future<void> buildWindows(
WindowsProject windowsProject,
BuildInfo buildInfo,
TargetPlatform targetPlatform, {
Future<void> buildWindows(WindowsProject windowsProject, BuildInfo buildInfo, {
String? target,
VisualStudio? visualStudioOverride,
SizeAnalyzer? sizeAnalyzer,
@@ -59,6 +56,8 @@ Future<void> buildWindows(
'to learn about adding Windows support to a project.');
}
// TODO(pbo-linaro): Add support for windows-arm64 platform, https://github.com/flutter/flutter/issues/129807
const TargetPlatform targetPlatform = TargetPlatform.windows_x64;
final Directory buildDirectory = globals.fs.directory(globals.fs.path.join(
projectPath,
getWindowsBuildDirectory(targetPlatform),
@@ -84,7 +83,6 @@ Future<void> buildWindows(
platform: globals.platform,
logger: globals.logger,
processManager: globals.processManager,
osUtils: globals.os,
);
final String? cmakePath = visualStudio.cmakePath;
final String? cmakeGenerator = visualStudio.cmakeGenerator;
@@ -101,9 +99,9 @@ Future<void> buildWindows(
await _runCmakeGeneration(
cmakePath: cmakePath,
generator: cmakeGenerator,
targetPlatform: targetPlatform,
buildDir: buildDirectory,
sourceDir: windowsProject.cmakeFile.parent,
targetPlatform: targetPlatform,
);
if (visualStudio.displayVersion == '17.1.0') {
_fixBrokenCmakeGeneration(buildDirectory);
@@ -130,7 +128,7 @@ Future<void> buildWindows(
}
if (buildInfo.codeSizeDirectory != null && sizeAnalyzer != null) {
final String arch = getNameForTargetPlatform(targetPlatform);
final String arch = getNameForTargetPlatform(TargetPlatform.windows_x64);
final File codeSizeFile = globals.fs.directory(buildInfo.codeSizeDirectory)
.childFile('snapshot.$arch.json');
final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory)
@@ -167,26 +165,23 @@ Future<void> buildWindows(
}
}
String getCmakeWindowsArch(TargetPlatform targetPlatform) {
return switch (targetPlatform) {
TargetPlatform.windows_x64 => 'x64',
TargetPlatform.windows_arm64 => 'ARM64',
_ => throw Exception('Unsupported target platform "$targetPlatform".'),
};
}
Future<void> _runCmakeGeneration({
required String cmakePath,
required String generator,
required TargetPlatform targetPlatform,
required Directory buildDir,
required Directory sourceDir,
required TargetPlatform targetPlatform,
}) async {
if (targetPlatform != TargetPlatform.windows_x64) {
throwToolExit('Windows build supports only x64 target architecture');
}
final Stopwatch sw = Stopwatch()..start();
await buildDir.create(recursive: true);
int result;
const String arch = 'x64';
const String flutterTargetPlatform = 'windows-x64';
try {
result = await globals.processUtils.stream(
<String>[
@@ -198,8 +193,8 @@ Future<void> _runCmakeGeneration({
'-G',
generator,
'-A',
getCmakeWindowsArch(targetPlatform),
'-DFLUTTER_TARGET_PLATFORM=${getNameForTargetPlatform(targetPlatform)}',
arch,
'-DFLUTTER_TARGET_PLATFORM=$flutterTargetPlatform',
],
trace: true,
);

View File

@@ -72,7 +72,6 @@ Future<CCompilerConfig> cCompilerConfigWindows() async {
platform: globals.platform,
logger: globals.logger,
processManager: globals.processManager,
osUtils: globals.os,
);
return CCompilerConfig(

View File

@@ -9,7 +9,6 @@ import '../base/common.dart';
import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart';
import '../base/os.dart' show HostPlatform, OperatingSystemUtils;
import '../base/platform.dart';
import '../base/process.dart';
import '../base/version.dart';
@@ -22,18 +21,15 @@ class VisualStudio {
required ProcessManager processManager,
required Platform platform,
required Logger logger,
required OperatingSystemUtils osUtils,
}) : _platform = platform,
_fileSystem = fileSystem,
_processUtils = ProcessUtils(processManager: processManager, logger: logger),
_logger = logger,
_osUtils = osUtils;
_logger = logger;
final FileSystem _fileSystem;
final Platform _platform;
final ProcessUtils _processUtils;
final Logger _logger;
final OperatingSystemUtils _osUtils;
/// Matches the description property from the vswhere.exe JSON output.
final RegExp _vswhereDescriptionProperty = RegExp(r'\s*"description"\s*:\s*".*"\s*,?');
@@ -212,8 +208,6 @@ class VisualStudio {
return null;
}
final String arch = _osUtils.hostPlatform == HostPlatform.windows_arm64 ? 'arm64': 'x64';
return _fileSystem.path.joinAll(<String>[
details.installationPath!,
'VC',
@@ -221,8 +215,8 @@ class VisualStudio {
'MSVC',
details.msvcVersion!,
'bin',
'Host$arch',
arch,
'Hostx64',
'x64',
executable,
]);
}
@@ -235,14 +229,12 @@ class VisualStudio {
return null;
}
final String arch = _osUtils.hostPlatform == HostPlatform.windows_arm64 ? 'arm64': '64';
return _fileSystem.path.joinAll(<String>[
details.installationPath!,
'VC',
'Auxiliary',
'Build',
'vcvars$arch.bat',
'vcvars64.bat',
]);
}

View File

@@ -24,8 +24,7 @@ class WindowsDevice extends DesktopDevice {
required Logger logger,
required FileSystem fileSystem,
required OperatingSystemUtils operatingSystemUtils,
}) : _operatingSystemUtils = operatingSystemUtils,
super(
}) : super(
'windows',
platformType: PlatformType.windows,
ephemeral: false,
@@ -35,8 +34,6 @@ class WindowsDevice extends DesktopDevice {
operatingSystemUtils: operatingSystemUtils,
);
final OperatingSystemUtils _operatingSystemUtils;
@override
bool isSupported() => true;
@@ -44,12 +41,7 @@ class WindowsDevice extends DesktopDevice {
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,
};
Future<TargetPlatform> get targetPlatform async => TargetPlatform.windows_x64;
@override
bool isSupportedForProject(FlutterProject flutterProject) {
@@ -64,14 +56,13 @@ class WindowsDevice extends DesktopDevice {
await buildWindows(
FlutterProject.current().windows,
buildInfo,
_targetPlatform,
target: mainPath,
);
}
@override
String executablePathForDevice(covariant WindowsApp package, BuildInfo buildInfo) {
return package.executable(buildInfo.mode, _targetPlatform);
return package.executable(buildInfo.mode);
}
}