Skip to content

Consolidate AndroidArch and DarwinArch into CpuArch - #189315

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
chingjun:cleanup-darwinarch
Jul 24, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
chingjun:cleanup-darwinarch

Conversation

@chingjun

Copy link
Copy Markdown
Contributor

Follow up to #189207, this PR removes all usages of AndroidArch and DarwinArch, replacing them with the newly added CpuArch.

@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically platform-linux Building on or for Linux specifically a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Jul 11, 2026
@chingjun chingjun added the CICD Run CI/CD label Jul 11, 2026
@chingjun
chingjun force-pushed the cleanup-darwinarch branch from 71ca836 to 8956bae Compare July 11, 2026 06:35
@chingjun chingjun added CICD Run CI/CD and removed CICD Run CI/CD labels Jul 11, 2026
@chingjun
chingjun force-pushed the cleanup-darwinarch branch from 8956bae to 45a4daa Compare July 14, 2026 22:50
@github-actions github-actions Bot removed platform-windows Building on or for Windows specifically platform-linux Building on or for Linux specifically team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Jul 14, 2026
@chingjun
chingjun force-pushed the cleanup-darwinarch branch from e5e0005 to 9292ed1 Compare July 15, 2026 16:51
@chingjun

Copy link
Copy Markdown
Contributor Author

Note that this PR is stacked on top of #189478. For easier review, please only look at the top commit. Thanks!

@chingjun
chingjun marked this pull request as ready for review July 15, 2026 22:01
@chingjun
chingjun requested review from a team as code owners July 15, 2026 22:01
@chingjun
chingjun requested review from bkonyi and camsim99 and removed request for a team July 15, 2026 22:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request consolidates the architecture representation in flutter_tools by replacing the platform-specific DarwinArch and AndroidArch enums with a unified CpuArch enum, updating all associated build targets, commands, devices, and tests. A review comment suggests refining an error message in android_device.dart to correctly state that the specific CPU architecture is unsupported, rather than claiming Android platforms in general are unsupported.

Comment on lines +558 to 562
case CpuArch.x86:
case CpuArch.riscv64:
case CpuArch.unknown:
_logger.printError('Android platforms are only supported.');
return LaunchResult.failed();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message 'Android platforms are only supported.' is misleading here because the check is performed on cpuArch (which means the platform is indeed Android, but the specific CPU architecture is unsupported).

Updating the error message to specify that the architecture is unsupported would be much more helpful and aligned with the style guide.

Suggested change
case CpuArch.x86:
case CpuArch.riscv64:
case CpuArch.unknown:
_logger.printError('Android platforms are only supported.');
return LaunchResult.failed();
case CpuArch.x86:
case CpuArch.riscv64:
case CpuArch.unknown:
_logger.printError('Unsupported Android architecture: ${cpuArch.name}.');
return LaunchResult.failed();
References
  1. Error messages should be useful: Every error message is an opportunity to make someone love our product. (link)

case TargetPlatform.windows_x64:
case TargetPlatform.unsupported:
final CpuArch cpuArch = await this.cpuArch;
switch (cpuArch) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be simplified to this:

if (cpuArch case .x86 || .riscv64 || .unknown) {
  _logger.printError('Android platforms are only supported.');
  return LaunchResult.failed();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our style guide says to use switches with no default and not ifs for enums to prevent accidentally missing new cases.

Ref: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-using-if-chains-or--or--with-enum-values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, my bad. I can't wait for analyzer plugins to be fixed so I can look into just adding a rule for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this back to use a switch.

final String localEngineName = localEngineInfo.localTargetName;
if (localEngineName.contains('_arm64')) {
return <DarwinArch>[DarwinArch.arm64];
return <CpuArch>[CpuArch.arm64];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: consider using dot shorthands here and elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return switch (globals.os.hostPlatform) {
HostPlatform.darwin_arm64 => HostPlatform.darwin_arm64,
HostPlatform.darwin_x64 => HostPlatform.darwin_x64,
final HostPlatform unsupported => throw Exception(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this last pattern just be a wildcard?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This function is a bit weird though. I don't know why we still need this now that globals.os.hostPlatform exists. Will send a separate PR to clean this up after this PR lands.

@chingjun
chingjun force-pushed the cleanup-darwinarch branch 3 times, most recently from 10cd7ea to 966efb6 Compare July 17, 2026 16:52
case TargetPlatform.windows_x64:
case TargetPlatform.unsupported:
final CpuArch cpuArch = await this.cpuArch;
switch (cpuArch) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our style guide says to use switches with no default and not ifs for enums to prevent accidentally missing new cases.

Ref: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-using-if-chains-or--or--with-enum-values

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, but basically LGTM!

bool supportsRuntimeMode(BuildMode buildMode) => buildMode != BuildMode.jitRelease;

final DarwinArch cpuArchitecture;
final CpuArch cpuArchitecture;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this anymore or are we just keeping it around to keep this PR smaller? If that's the case, maybe we should add a TODO to update uses of it to cpuArch and remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this to CpuArch _cpuArch instead to make it clear that this is just the field backing Future<CpuArch> get cpuArch.

case TargetPlatform.windows_x64:
case TargetPlatform.unsupported:
final CpuArch cpuArch = await this.cpuArch;
switch (cpuArch) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, my bad. I can't wait for analyzer plugins to be fixed so I can look into just adding a rule for this.

@chingjun
chingjun force-pushed the cleanup-darwinarch branch from 966efb6 to 9d4eb56 Compare July 21, 2026 22:33
bkonyi
bkonyi previously approved these changes Jul 21, 2026
@bkonyi
bkonyi requested a review from cbracken July 21, 2026 22:47
@chingjun

Copy link
Copy Markdown
Contributor Author

@bkonyi would you mind taking another look at this? Thanks!

@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 23, 2026
Merged via the queue into flutter:master with commit 162f1d6 Jul 24, 2026
20 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 24, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 24, 2026
flutter/flutter@2a2a79d...b65f4d9

2026-07-24 [email protected] Add dart_runtime_service_vm_aot.dart.snapshot to the snapshot list in the macOS code signing configuration (flutter/flutter#189981)
2026-07-24 [email protected] Roll Fuchsia Test Scripts from wLST_A-xfOeGT_5mj... to E8hJ1AfK8CtGtaES0... (flutter/flutter#189956)
2026-07-23 [email protected] Consolidate AndroidArch and DarwinArch into CpuArch (flutter/flutter#189315)
2026-07-23 [email protected] Roll Dart SDK from 9258584f98b8 to e3fc57eae9eb (7 revisions) (flutter/flutter#189949)
2026-07-23 [email protected] [flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter/flutter#189952)
2026-07-23 [email protected] Roll Skia from 1d8bf9270d8c to 6e9c4687c001 (15 revisions) (flutter/flutter#189954)
2026-07-23 [email protected] [flutter_tools] Initialize Cache.flutterRoot at the start of the upgrade_test suite (flutter/flutter#189937)
2026-07-23 [email protected] Parse AndroidX property in gradle.properties (flutter/flutter#188372)
2026-07-23 [email protected] [Impeller]Use the IO context for OpenGL program setup (flutter/flutter#185723)
2026-07-23 [email protected] Allow building projects lacking Runner.xcworkspace (flutter/flutter#186239)
2026-07-23 [email protected] [flutter_tools] Invalidate WebEntrypointTarget when plugin set changes (flutter/flutter#189460)
2026-07-23 [email protected] Bump devtools_shared to 13.1.0 (flutter/flutter#189507)
2026-07-23 [email protected] forceNdkDownload should skip configuring cmake when ndk-build is used (flutter/flutter#187201)
2026-07-23 [email protected] Disable execution order shuffling for the flutter_tools upgrade_test suite (flutter/flutter#189920)
2026-07-23 [email protected] Move WindowManager outside of WidgetsApp (flutter/flutter#188866)
2026-07-23 [email protected] Roll Skia from 3424966b8a2b to 1d8bf9270d8c (3 revisions) (flutter/flutter#189901)
2026-07-23 [email protected] Roll Fuchsia Linux SDK from GswhlPRO-D1qSNclx... to 9org0yL3yZkp80x5S... (flutter/flutter#189898)
2026-07-23 [email protected] Remove outdated logs that were added to track #172636 (flutter/flutter#189282)
2026-07-23 [email protected] Roll Skia from 5e183e5aeac5 to 3424966b8a2b (33 revisions) (flutter/flutter#189890)
2026-07-23 [email protected] [examples] Use super parameters in missed spots (flutter/flutter#186194)
2026-07-23 [email protected] [flutter_tools] Bound Spotlight mdfind execution with timeout on macOS (flutter/flutter#189461)
2026-07-23 [email protected] Fix non primary buttons not being captured on windows (flutter/flutter#188394)
2026-07-22 [email protected] Listen to log reader before VM Service and make delay configurable (flutter/flutter#187202)
2026-07-22 [email protected] Roll Dart SDK from 1e65011ee004 to 9258584f98b8 (7 revisions) (flutter/flutter#189883)
2026-07-22 [email protected] Adds skill for generating engine diffs for new releases. (flutter/flutter#189869)
2026-07-22 [email protected] [ios,macos] Add Swift Sourcekit LSP support (flutter/flutter#189761)
2026-07-22 [email protected] [iOS] Mark DisplayLinkManager.shared and init() @mainactor (flutter/flutter#189815)
2026-07-22 [email protected] Fix `Rect::ExpandToMinTransformedSize` to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter/flutter#189808)
2026-07-22 [email protected] Skip emulator.getEmulators test (flutter/flutter#189879)
2026-07-22 [email protected] Fix null terminator in input truncates clipboard (flutter/flutter#188652)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD platform-ios iOS applications specifically platform-macos Building on or for macOS specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants