New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce architecture subdirectory for Windows build (#129805, #116196) #131843
Introduce architecture subdirectory for Windows build (#129805, #116196) #131843
Conversation
@loic-sharma Here it is! For now, I focused on a minimal change, with tests working (on x64 and arm64). |
19d8aaf
to
982ab93
Compare
Fixed error reported by flutter analyze. |
982ab93
to
c094554
Compare
Fixed license message. |
@loic-sharma I'm not sure if the failure (windows plugin_test) means that there is something missing, or if the test script itself (located elsewhere?) should be updated to reflect new path to binary plugintest_test.exe. If you could help on this, that would be nice :). |
@loic-sharma Would you be interested in reviewing this? |
Yup will do! |
@@ -168,6 +189,9 @@ Future<void> _runCmakeGeneration({ | |||
buildDir.path, | |||
'-G', | |||
generator, | |||
'-A', | |||
arch, | |||
'-DFLUTTER_TARGET_PLATFORM=$flutterTargetPlatform', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to the generated configs in _writeGeneratedFlutterConfig
?
flutter/packages/flutter_tools/lib/src/cmake.dart
Lines 101 to 109 in b7acafa
# Generated code do not commit. | |
file(TO_CMAKE_PATH "$escapedFlutterRoot" FLUTTER_ROOT) | |
file(TO_CMAKE_PATH "$escapedProjectDir" PROJECT_DIR) | |
set(FLUTTER_VERSION "$version" PARENT_SCOPE) | |
set(FLUTTER_VERSION_MAJOR ${version.major} PARENT_SCOPE) | |
set(FLUTTER_VERSION_MINOR ${version.minor} PARENT_SCOPE) | |
set(FLUTTER_VERSION_PATCH ${version.patch} PARENT_SCOPE) | |
set(FLUTTER_VERSION_BUILD ${buildVersion ?? 0} PARENT_SCOPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux build adds it directly to the cmake command, and IMHO, it's more explicit that putting it in another function.
FLUTTER_VERSION_* stuff is the same for all architecture, thus it makes sense to factorize it in a single place.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I agree we should align with Linux. If we move FLUTTER_TARGET_PLATFORM
to the generated CMake config file, we would need to also update Linux. That seems out-of-scope for this PR, and we can follow-up with this change later if needed.
That said, I'm curious as to why Linux chose this approach. The generated cmake config file makes it easier to use the CMake project without the Flutter tool. Regardless, I'll close this off!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for accepting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if someone directly invokes a build via cmake without providing -DFLUTTER_TARGET_PLATFORM
?
packages/flutter_tools/lib/src/windows/migrations/build_architecture_migration.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/windows/migrations/build_architecture_migration.dart
Show resolved
Hide resolved
...s/flutter_tools/test/general.shard/windows/migrations/build_architecture_migration_test.dart
Outdated
Show resolved
Hide resolved
...s/flutter_tools/test/general.shard/windows/migrations/build_architecture_migration_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/windows/migrations/build_architecture_migration.dart
Show resolved
Hide resolved
It looks like you'll need to update this: flutter/dev/devicelab/lib/tasks/plugin_tests.dart Lines 296 to 300 in 53082f6
You should be able to run this test locally using these instructions: https://github.com/flutter/flutter/tree/master/dev/devicelab#running-tests-locally TLDR, this should work: cd path/to/flutter
cd dev/devicelab
../../bin/cache/dart-sdk/bin/dart bin/test_runner.dart test -t plugin_test_windows Let me know if you run into any problems! |
c094554
to
972435c
Compare
First fixing failed test, before addressing other comments in review. |
58332e9
to
78f5688
Compare
Pushed resolved changes. |
78f5688
to
4aeef19
Compare
Fixed analyze not happy with raw cmake strings 'if(...'. |
packages/flutter_tools/templates/app_shared/windows.tmpl/flutter/CMakeLists.txt
Outdated
Show resolved
Hide resolved
4aeef19
to
0010f3d
Compare
Added change to hardcode TargetPlatform to getWindowsBuildDirectory. |
To implement windows-arm64 support, it is needed to add architecture as a subdirectory (#129805).
In short, when performing a flutter windows build, we have:
This convention follows what flutter linux build does.
The old "runner" folder is automatically cleaned to prevent confusion for users not aware of this change, and who could continue to use outdated binaries accidentally.
We didn't introduce any change in ephemeral build folder. This might be required when introducing another architecture, but it won't be a breaking change, as those files are not used by end user.
Since we use a fresh cmake folder, we introduce FLUTTER_TARGET_PLATFORM in flutter cmake file (#116196). This will be needed when targeting another architecture than x64, and will avoid to have to clean existing cmake files. An automatic migration was implemented to automate this change in existing applications.
Finally, we set a specific architecture when calling cmake. This fixes existing build and tests on Windows on Arm, where cmake tries to compile native windows-arm64 binaries by default (which fails to link x64 libraries). In more, it will avoid need to clean existing cmake files when introducing another architecture.
Design doc: flutter.dev/go/windows-arm64
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.