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

@@ -7,12 +7,10 @@ import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_windows.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/windows/build_windows.dart';
import 'package:flutter_tools/src/windows/visual_studio.dart';
import 'package:test/fake.dart';
import 'package:unified_analytics/unified_analytics.dart';
@@ -83,7 +81,6 @@ void main() {
FakeCommand cmakeGenerationCommand({
void Function()? onRun,
String generator = _defaultGenerator,
TargetPlatform targetPlatform = TargetPlatform.windows_x64,
}) {
return FakeCommand(
command: <String>[
@@ -95,7 +92,7 @@ void main() {
'-G',
generator,
'-A',
getCmakeWindowsArch(targetPlatform),
'x64',
'-DFLUTTER_TARGET_PLATFORM=windows-x64',
],
onRun: onRun,
@@ -129,7 +126,7 @@ void main() {
}
testUsingContext('Windows build fails when there is no cmake path', () async {
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = FakeVisualStudio(cmakePath: null);
setUpMockProjectFilesForBuild();
@@ -145,7 +142,7 @@ void main() {
testUsingContext('Windows build fails when there is no windows project', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockCoreProjectFiles();
@@ -163,7 +160,7 @@ void main() {
testUsingContext('Windows build fails on non windows platform', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -179,7 +176,7 @@ void main() {
testUsingContext('Windows build fails when feature is disabled', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -195,7 +192,7 @@ void main() {
testUsingContext('Windows build does not spew stdout to status logger', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -220,7 +217,7 @@ void main() {
testUsingContext('Windows build sends timing events', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -260,7 +257,7 @@ void main() {
testUsingContext('Windows build extracts errors from stdout', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -318,7 +315,7 @@ C:\foo\windows\x64\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identif
testUsingContext('Windows verbose build sets VERBOSE_SCRIPT_LOGGING', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -344,7 +341,7 @@ C:\foo\windows\x64\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identif
testUsingContext('Windows build works around CMake generation bug', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(displayVersion: '17.1.0');
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -481,7 +478,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build invokes build and writes generated files', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -551,7 +548,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows profile build passes Profile configuration', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -574,7 +571,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
const String generator = 'A different generator';
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(
cmakeGenerator: generator);
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -595,7 +592,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext("Windows build uses pubspec's version", () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -641,7 +638,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build uses build-name and build-number', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -685,7 +682,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build build-name overrides pubspec', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -732,7 +729,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build build-number overrides pubspec', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -779,7 +776,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build build-name and build-number override pubspec', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -827,7 +824,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build warns on non-numeric build-number', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -877,7 +874,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Windows build warns on complex build-number', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -926,14 +923,14 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
});
testUsingContext('hidden when not enabled on Windows host', () {
expect(BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()).hidden, true);
expect(BuildWindowsCommand(logger: BufferLogger.test()).hidden, true);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
Platform: () => windowsPlatform,
});
testUsingContext('Not hidden when enabled and on Windows host', () {
expect(BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()).hidden, false);
expect(BuildWindowsCommand(logger: BufferLogger.test()).hidden, false);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
Platform: () => windowsPlatform,
@@ -941,7 +938,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
testUsingContext('Performs code size analysis and sends analytics', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();
@@ -997,7 +994,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
// is resolved on the VS side, we can allow these paths again
testUsingContext('Test bad path characters', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
fileSystem.currentDirectory = fileSystem.directory("test_'path")
..createSync();
@@ -1024,7 +1021,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
// And tests the case where stdout contains the error about missing assets
testUsingContext('Windows build extracts errors related to pubspec.yaml from stdout', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
..visualStudioOverride = fakeVisualStudio;
setUpMockProjectFilesForBuild();

View File

@@ -160,7 +160,7 @@ void main() {
expect(utils.hostPlatform, HostPlatform.linux_x64);
});
testWithoutContext('Windows default', () async {
testWithoutContext('Windows', () async {
final OperatingSystemUtils utils =
createOSUtils(FakePlatform(operatingSystem: 'windows'));
expect(utils.hostPlatform, HostPlatform.windows_x64);

View File

@@ -55,7 +55,7 @@ void main() {
}
fileSystem.directory('windows').createSync();
await const UnpackWindows(TargetPlatform.windows_x64).build(environment);
await const UnpackWindows().build(environment);
// Output files are copied correctly.
expect(fileSystem.file(r'C:\windows\flutter\ephemeral\flutter_export.h'), exists);
@@ -147,7 +147,7 @@ void main() {
},
));
await const DebugBundleWindowsAssets(TargetPlatform.windows_x64).build(environment);
await const DebugBundleWindowsAssets().build(environment);
// Depfile is created and dill is copied.
expect(environment.buildDir.childFile('flutter_assets.d'), exists);
@@ -175,7 +175,7 @@ void main() {
environment.buildDir.childFile('app.so').createSync(recursive: true);
await const WindowsAotBundle(AotElfProfile(TargetPlatform.windows_x64)).build(environment);
await const ProfileBundleWindowsAssets(TargetPlatform.windows_x64).build(environment);
await const ProfileBundleWindowsAssets().build(environment);
// Depfile is created and so is copied.
expect(environment.buildDir.childFile('flutter_assets.d'), exists);
@@ -202,7 +202,7 @@ void main() {
environment.buildDir.childFile('app.so').createSync(recursive: true);
await const WindowsAotBundle(AotElfRelease(TargetPlatform.windows_x64)).build(environment);
await const ReleaseBundleWindowsAssets(TargetPlatform.windows_x64).build(environment);
await const ReleaseBundleWindowsAssets().build(environment);
// Depfile is created and so is copied.
expect(environment.buildDir.childFile('flutter_assets.d'), exists);

View File

@@ -615,7 +615,7 @@ void main() {
expect(artifacts.getBinaryDirs(), <List<String>>[
<String>['darwin-x64', 'darwin-arm64/font-subset.zip'],
<String>['linux-arm64', 'linux-arm64/font-subset.zip'],
<String>['windows-arm64', 'windows-arm64/font-subset.zip'],
<String>['windows-x64', 'windows-x64/font-subset.zip'], // arm64 windows hosts are not supported now
]);
});

View File

@@ -52,7 +52,7 @@ void main() {
final Platform platform = FakePlatform();
final BufferLogger logger = BufferLogger.test();
final List<FlutterCommand> commands = <FlutterCommand>[
BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()),
BuildWindowsCommand(logger: BufferLogger.test()),
BuildLinuxCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()),
BuildMacosCommand(logger: BufferLogger.test(), verboseHelp: false),
BuildWebCommand(fileSystem: fileSystem, logger: BufferLogger.test(), verboseHelp: false),

View File

@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/windows/visual_studio.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fakes.dart';
const String programFilesPath = r'C:\Program Files (x86)';
const String visualStudioPath = programFilesPath + r'\Microsoft Visual Studio\2017\Community';
@@ -345,7 +344,6 @@ VisualStudioFixture setUpVisualStudio() {
platform: windowsPlatform,
logger: logger,
processManager: processManager,
osUtils: FakeOperatingSystemUtils(),
);
return VisualStudioFixture(visualStudio, fileSystem, processManager, logger);
}
@@ -384,7 +382,6 @@ void main() {
fileSystem: MemoryFileSystem.test(style: FileSystemStyle.windows),
platform: FakePlatform(operatingSystem: 'windows'),
processManager: FakeProcessManager.any(),
osUtils: FakeOperatingSystemUtils(),
);
expect(() => visualStudio.isInstalled,
@@ -407,7 +404,6 @@ void main() {
fileSystem: fileSystem,
platform: windowsPlatform,
processManager: fakeProcessManager,
osUtils: FakeOperatingSystemUtils(),
);
expect(visualStudio.isInstalled, false);
@@ -430,7 +426,6 @@ void main() {
fileSystem: fileSystem,
platform: windowsPlatform,
processManager: fakeProcessManager,
osUtils: FakeOperatingSystemUtils(),
);
expect(visualStudio.isInstalled, false);

View File

@@ -130,5 +130,5 @@ WindowsDevice setUpWindowsDevice({
class FakeWindowsApp extends Fake implements WindowsApp {
@override
String executable(BuildMode buildMode, TargetPlatform targetPlatform) => '${buildMode.cliName}/executable';
String executable(BuildMode buildMode) => '${buildMode.cliName}/executable';
}

View File

@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ffi' show Abi;
import 'dart:io' as io;
import 'package:file/file.dart';
@@ -42,18 +41,11 @@ void main() {
projectRoot = tempDir.childDirectory('hello');
final String arch;
if (Abi.current() == Abi.windowsArm64) {
arch = 'arm64';
} else {
arch = 'x64';
}
releaseDir = fileSystem.directory(fileSystem.path.join(
projectRoot.path,
'build',
'windows',
arch,
'x64',
'runner',
'Release',
));