Repository navigation
ci: Support --target_arch option in prepare_package.dart - #190960
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a target_arch option to the package preparation script, allowing Flutter SDK archives to be built for a specific target architecture. It propagates this setting to subprocesses via the FLUTTER_HOST_ARCH environment variable and the --host-arch flag, and validates that the downloaded Dart SDK matches the requested architecture. The review feedback correctly identifies a bug in the new tests where the mismatch exception is expected during repository initialization instead of archive creation.
| await expectLater( | ||
| creator.initializeRepo, | ||
| throwsA( | ||
| isA<PreparePackageException>().having( | ||
| (PreparePackageException error) => error.message, | ||
| 'message', | ||
| contains('Requested an archive for x64, but the Dart SDK in the archive is arm64'), | ||
| ), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
The test expects creator.initializeRepo to throw PreparePackageException. However, the architecture mismatch check is performed inside _versionMap, which is called during creator.createArchive(), not creator.initializeRepo(). Therefore, creator.initializeRepo will complete successfully, and the test will fail to catch the expected exception. We should first await creator.initializeRepo() and then expect creator.createArchive to throw.
await creator.initializeRepo();
await expectLater(
creator.createArchive,
throwsA(
isA<PreparePackageException>().having(
(PreparePackageException error) => error.message,
'message',
contains('Requested an archive for x64, but the Dart SDK in the archive is arm64'),
),
),
);There was a problem hiding this comment.
the architecture mismatch check is performed inside _versionMap, which is called during creator.createArchive(), not creator.initializeRepo().
... think you got that one backwards there Gemini...
I don't touch _versionMap anywhere in the current patch, and that mismatch check isn't called from createArchive.
The arch check lives in _getVersion(), and as far as I can tell from grepping the code, the only caller is initializeRepo():
createArchive() doesn't call _getVersion() or initializeRepo(). In fact, it asserts _version.isNotEmpty which (I assume) it does because initializeRepo() has already populated it.
The check on initializeRepo() seems right to me...
Adds a `--target_arch=<x64|arm64>` option to
`dev/bots/prepare_package.dart` to support cross-packaging SDK archives
for a target architecture different from the host architecture.
When target arch is specified, we set `FLUTTER_HOST_ARCH` in the
environment of each subprocess spawned by the packaging script. This is
picked up by `update_dart_sdk.sh` and `update_dart_sdk.ps1` when
choosing which Dart SDK to download, and by
`OperatingSystemUtils.hostPlatform` when the tool picks which host
engine artifacts to cache. Those run from `bin/flutter` before the
flutter tool exists, so the environment is the only means we have to
pass this setting.
This patch allows arm64 macOS CI hosts to download and cache x64 host
engine artifacts when cross-packaging x64 Flutter SDK release archives
on an arm64 host (or theoretically vice-versa, but we'll never do that)
in the `packaging/packaging` recipe in `packaging.py`.
It's worth noting that the scripts and tool this drives are the ones in
the branch being packaged, not the ones this script was run from, so
`--target_arch` depends on that branch having cherry-picks to handle
both `FLUTTER_HOST_ARCH` support in
`bin/internal/update_dart_sdk.{sh,ps1}` (flutter#190421) and the `--host-arch`
option of `flutter precache` (flutter#190480).
See: https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/packaging/packaging.py
Issue: flutter#189144
bb60b07 to
144581d
Compare
…#12453) Manual roll Flutter from 27b098811f3b to c2437523d308 (179 revisions) Manual roll requested by tarrinneal@google.com flutter/flutter@27b0988...c243752 2026-08-12 matt.boetger@gmail.com Enable Gradle CI cache on all test targets that require android_sdk (flutter/flutter#190723) 2026-08-12 bkonyi@google.com [analysis] Reland "Added initial implementation of the flutter_analyzer_plugin (#175679)" (flutter/flutter#191022) 2026-08-12 matt.boetger@gmail.com Switch testing to gradle bin distribution type instead of all (flutter/flutter#190738) 2026-08-12 matt.boetger@gmail.com Convert Mockito instances in Kotlin to Mockk (flutter/flutter#189884) 2026-08-12 chingjun@google.com Report individual test results to LUCI ResultDB (flutter/flutter#190254) 2026-08-12 victorsanniay@gmail.com Toggleable reaction duration respects overrides (flutter/flutter#190857) 2026-08-12 engine-flutter-autoroll@skia.org Roll Skia from e00dbd7448c4 to fee7272f5bc2 (1 revision) (flutter/flutter#191007) 2026-08-12 30870216+gaaclarke@users.noreply.github.com Started caching text shadows by content. (flutter/flutter#190681) 2026-08-12 30870216+gaaclarke@users.noreply.github.com Adds agent skill for spawning led tasks. (flutter/flutter#190937) 2026-08-12 engine-flutter-autoroll@skia.org Roll Packages from aaaf246 to 94485f1 (8 revisions) (flutter/flutter#191008) 2026-08-12 82978131+herdiyana256@users.noreply.github.com flutter_tools: validate plugin identifiers before generating registrant code (flutter/flutter#190462) 2026-08-12 engine-flutter-autoroll@skia.org Roll Skia from 112f36148949 to e00dbd7448c4 (3 revisions) (flutter/flutter#190993) 2026-08-12 engine-flutter-autoroll@skia.org Roll Skia from 7d366c802307 to 112f36148949 (3 revisions) (flutter/flutter#190983) 2026-08-12 okorohelijah@google.com remove bringup for flavors test (flutter/flutter#190940) 2026-08-12 engine-flutter-autoroll@skia.org Roll Skia from 1f10a20bdd61 to 7d366c802307 (2 revisions) (flutter/flutter#190980) 2026-08-12 116356835+AbdeMohlbi@users.noreply.github.com Remove `--no-sim-use-hardfp` flag (flutter/flutter#190790) 2026-08-12 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#190977) 2026-08-12 engine-flutter-autoroll@skia.org Roll Skia from 339bedab6766 to 1f10a20bdd61 (1 revision) (flutter/flutter#190975) 2026-08-12 victorsanniay@gmail.com RawTooltip respects AnimationStyle updates and reverseCurve (flutter/flutter#190889) 2026-08-12 chris@bracken.jp ci: Support --target_arch option in prepare_package.dart (flutter/flutter#190960) 2026-08-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from SFq4FVodIOQAS26Lr... to -uHuSGv3wt7QAlDwa... (flutter/flutter#190973) 2026-08-12 aam@google.com Removes building of ci/android_debug_x86 as nobody should be consuming it. (flutter/flutter#190951) 2026-08-12 30870216+gaaclarke@users.noreply.github.com Adds error about wimp_heavy not being implemented. (flutter/flutter#189945) 2026-08-11 robert.ancell@canonical.com Add clang, cmake, and ninja deps to Linux windowing_test (flutter/flutter#190119) 2026-08-11 269567208+reidbaker-agent@users.noreply.github.com [AGP 9.1.0 Migration #1] Add Android Gradle Plugin Public API migration documentation (flutter/flutter#190842) 2026-08-11 bkonyi@google.com [flutter_tools] Fix deadlock in debug adapters when process exits early (flutter/flutter#190931) 2026-08-11 bkonyi@google.com [tool] Define modular dependency injection containers and bootstrapper (flutter/flutter#190724) 2026-08-11 1961493+harryterkelsen@users.noreply.github.com [web] Unify MaskFilter and ColorFilter primitives across CanvasKit and Skwasm (flutter/flutter#190314) 2026-08-11 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#190958) 2026-08-11 33794642+FelixMittermeier@users.noreply.github.com [Impeller] Move image upload scheduling waits to GPU disable (flutter/flutter#190445) 2026-08-11 30870216+gaaclarke@users.noreply.github.com Started generating the windows platform for macrobenchmarks (flutter/flutter#190932) 2026-08-11 1961493+harryterkelsen@users.noreply.github.com [web] Unify ui.Vertices (flutter/flutter#190563) 2026-08-11 jhy03261997@gmail.com Fix accessibility_inspector service extensions map mutability (flutter/flutter#190888) 2026-08-11 47866232+chunhtai@users.noreply.github.com Add batch3 a11y_assessment for vpat (flutter/flutter#189042) 2026-08-11 15619084+vashworth@users.noreply.github.com Remove Xcode environment when building swift tools in Xcode pre-action (flutter/flutter#190848) 2026-08-11 mdebbar@google.com [tool] Add missing play element in web test index.html to fix warning (flutter/flutter#190675) 2026-08-11 kkmk1999@gmail.com Offload blocking work in ProcessTextPlugin to the background (flutter/flutter#189823) 2026-08-11 bkonyi@google.com [flutter_tools] Replace usages of package:dds/dap.dart with package:dap_adapters/dap_adapters.dart (flutter/flutter#190667) 2026-08-11 15619084+vashworth@users.noreply.github.com Always update swift package dependencies (flutter/flutter#190886) 2026-08-11 bkonyi@google.com [flutter_tools] Add --preset option to flutter test (flutter/flutter#190878) 2026-08-11 jmccandless@google.com Include the examples cross imports checker in the analzyer. (flutter/flutter#190674) 2026-08-11 bkonyi@google.com [devicelab] Remove orphaned screenshot test files (flutter/flutter#190879) 2026-08-11 jason-simmons@users.noreply.github.com Remove the bringup flag from the linux_arm_host_desktop_engine builder (flutter/flutter#190935) 2026-08-11 mdebbar@google.com Reduce web_skwasm_tests subshards from 8 to 2 (flutter/flutter#190728) ...

Adds a
--target_arch=<x64|arm64>option todev/bots/prepare_package.dartto support cross-packaging SDK archives for a target architecture different from the host architecture.When target arch is specified, we set
FLUTTER_HOST_ARCHin the environment of each subprocess spawned by the packaging script. This is picked up byupdate_dart_sdk.shandupdate_dart_sdk.ps1when choosing which Dart SDK to download, and byOperatingSystemUtils.hostPlatformwhen the tool picks which host engine artifacts to cache. Those run frombin/flutterbefore the flutter tool exists, so the environment is the only means we have to pass this setting.This patch allows arm64 macOS CI hosts to download and cache x64 host engine artifacts when cross-packaging x64 Flutter SDK release archives on an arm64 host (or theoretically vice-versa, but we'll never do that) in the
packaging/packagingrecipe inpackaging.py.It's worth noting that the scripts and tool this drives are the ones in the branch being packaged, not the ones this script was run from, so
--target_archdepends on that branch having cherry-picks to handle bothFLUTTER_HOST_ARCHsupport inbin/internal/update_dart_sdk.{sh,ps1}(#190421) and the--host-archoption offlutter precache(#190480).See: https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/packaging/packaging.py
Issue: #189144
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.