Skip to content

[flutter_tools] Move CpuArch to flutter_tools_core and define HostPlatform by osName and cpuArch - #195841

Merged
auto-submit[bot] merged 16 commits into
flutter:masterfrom
bkonyi:ft-ext-step10a-cpu-arch
Nov 12, 2026
Merged

auto-submit[bot] merged 16 commits into
flutter:masterfrom
bkonyi:ft-ext-step10a-cpu-arch

Conversation

@bkonyi

@bkonyi bkonyi commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Moves CpuArch to package:flutter_tools_core as an extensible @immutable final class (re-exported from build_info.dart) and updates HostPlatform to be defined by osName and cpuArch, exposing cpuArchName, cliName, and name getters while validating single-segment lowercase alphanumeric OS and architecture identifiers. Replaces CpuArch.fromHostPlatform call sites with HostPlatform.cpuArch.

Stack

Part of #190755
Part of #190754

…vice to tool extensions

Adds `HostPlatform` and `ArtifactDependency` to `package:flutter_tools_core`, `ArtifactService` to `package:flutter_tools_extension`, and `LinuxArtifactService` to `package:flutter_tools_extension_linux_prototype` so tool extensions can declare custom artifact dependencies over the extension protocol.

Part of flutter#190755
Part of flutter#190754
…_test

Remove the redundant `package:flutter_tools/src/base/os.dart` import in `extension_device_test.dart` after merging `origin/master`, as `HostPlatform` is re-exported by `package:flutter_tools_core/flutter_tools_core.dart`.
…fact-service

# Conflicts:
#	packages/flutter_tools/test/general.shard/extension_protocol/extension_device_test.dart
Re-exports `HostPlatform` from `package:flutter_tools_core/flutter_tools_core.dart` in `packages/flutter_tools/lib/src/base/os.dart` instead of declaring a `typedef`, avoiding `ambiguous_import` conflicts when importing both `os.dart` and `flutter_tools_core.dart`.
…fact-service

Adds the `artifact` service to the Linux prototype's `config.yaml` and to the `extension_discovery_test.dart` fixture as required by the manifest services check from flutter#194590, and fixes the `'artifacts'` namespace in the `ExtensionPackageConfig` docs.
…tform by osName and cpuArch

Moves CpuArch to package:flutter_tools_core as an extensible @immutable final class (re-exported from build_info.dart) and updates HostPlatform to be defined by osName and cpuArch, exposing cpuArchName, cliName, and name getters while validating single-segment lowercase alphanumeric OS and architecture identifiers. Replaces CpuArch.fromHostPlatform call sites with HostPlatform.cpuArch.

Part of flutter#190755
Part of flutter#190754
@bkonyi bkonyi added tool Affects the "flutter" command-line tool. See also t: labels. CICD Run CI/CD labels Nov 2, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically 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 Nov 2, 2026
…arch

# Conflicts:
#	packages/flutter_tools/lib/src/build_info.dart
#	packages/flutter_tools/lib/src/experimental/extension_manager.dart
#	packages/flutter_tools/packages/flutter_tools_core/lib/src/artifacts.dart
#	packages/flutter_tools/packages/flutter_tools_core/test/artifacts_test.dart
#	packages/flutter_tools/packages/flutter_tools_extension/lib/src/artifacts.dart
#	packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/lib/src/artifact.dart
#	packages/flutter_tools/packages/flutter_tools_extension_linux_prototype/test/linux_artifact_test.dart
#	packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart
#	packages/flutter_tools/test/general.shard/build_info_test.dart
#	packages/flutter_tools/test/general.shard/extension_protocol/artifact_service_test.dart
@bkonyi
bkonyi marked this pull request as ready for review November 4, 2026 21:08
@bkonyi
bkonyi requested a review from loic-sharma November 4, 2026 21:08
@bkonyi
bkonyi requested review from a team as code owners November 4, 2026 21:08
loic-sharma
loic-sharma previously approved these changes Nov 6, 2026

@loic-sharma loic-sharma left a comment

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.

LGTM modulo nits

@bkonyi
bkonyi requested a review from loic-sharma November 10, 2026 01:20
@bkonyi
bkonyi marked this pull request as draft November 10, 2026 16:39
Updates `CpuArchExtension` (`dartName`, `darwinArchName`, and `androidPlatformName`) to derive architecture and platform names from `CpuArch.name` and `TargetPlatform.getName()` rather than duplicating string literals.

Deduplicates `CpuArch` and `HostPlatform` single-segment identifier validation into a shared `_validIdentifierRegExp` in `artifacts.dart`.

Part of flutter#190755
Part of flutter#190754
@bkonyi
bkonyi marked this pull request as ready for review November 10, 2026 17:33

@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 refactors CpuArch from an enum in flutter_tools to a class in flutter_tools_core, and updates HostPlatform to use this new CpuArch class directly instead of storing the architecture as a string. Various references across the codebase have been updated to use the new class and its properties. Feedback suggests that HostPlatform.tryFromName should use CpuArch.tryFromName instead of CpuArch.fromName to avoid calling throwing methods within a non-throwing try method.

final int separatorIndex = normalizedCli.indexOf('-');
final String os = normalizedCli.substring(0, separatorIndex);
final String arch = normalizedCli.substring(separatorIndex + 1);
final archValue = CpuArch.fromName(arch);

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

Since HostPlatform.tryFromName is designed as a non-throwing "try" method, it should ideally avoid calling throwing methods like CpuArch.fromName. Although the current _validNameRegExp guarantees that the parsed arch string is a valid identifier, using CpuArch.tryFromName is more defensive and protects against potential future changes to CpuArch validation rules.

    final archValue = CpuArch.tryFromName(arch);
    if (archValue == null) {
      return null;
    }

@loic-sharma loic-sharma left a comment

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.

LGTM, nice work!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 10, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 10, 2026
@auto-submit

auto-submit Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/195841, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@robert-ancell robert-ancell 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.

LGTM

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into flutter:master with commit 8d46843 Nov 12, 2026
11 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 12, 2026
flutter/flutter@b98afb5...9c427b5

2026-11-12 [email protected] Roll Skia from d67d0f22e3ec to 9aa2513a4ac9 (2 revisions) (flutter/flutter#196429)
2026-11-12 [email protected] [flutter_tools] Move CpuArch to flutter_tools_core and define HostPlatform by osName and cpuArch (flutter/flutter#195841)
2026-11-12 [email protected] Roll Skia from 23e7e63789b8 to d67d0f22e3ec (2 revisions) (flutter/flutter#196424)
2026-11-12 [email protected] Uber compactify (flutter/flutter#196392)
2026-11-12 [email protected] Roll Skia from 3d7e335da165 to 23e7e63789b8 (12 revisions) (flutter/flutter#196422)
2026-11-12 [email protected] Roll Dart SDK from 13af329ea4f2 to e5add7a25b32 (1 revision) (flutter/flutter#196413)
2026-11-12 [email protected] Don't terminate the shared EGL display when an engine is disposed (flutter/flutter#194520)
2026-11-11 [email protected] Adds manifest flag to turn on SDFs for Android. (flutter/flutter#196056)
2026-11-11 [email protected] Remove bringup from Linux_pixel_7pro integration_ui_keyboard_inset_jump (flutter/flutter#196334)
2026-11-11 [email protected] Uses system default locale for text rendering when preferred locale isn't supported (flutter/flutter#195997)
2026-11-11 [email protected] [android]: prewarms shaders when the context is created (flutter/flutter#196069)
2026-11-11 [email protected] iOS: Recomposite platform views only if their parameters change (flutter/flutter#196287)
2026-11-11 [email protected] [flutter_tools] Forward encoding in ErrorHandlingFile.readAsStringSync (flutter/flutter#196136)
2026-11-11 [email protected] Roll Skia from b89c24bbab8c to 3d7e335da165 (8 revisions) (flutter/flutter#196390)
2026-11-11 [email protected] Add Flutter Gardener instructions on how to disable a test (flutter/flutter#196312)
2026-11-11 [email protected] [Impeller] Enable malioc analysis for framebuffer_blend shaders (flutter/flutter#196343)
2026-11-11 [email protected] [flutter_tools] Migrate general.shard Android, asset, and build tests off globals (flutter/flutter#196125)
2026-11-11 [email protected] Roll Dart SDK from 8f15c4ca2d41 to 13af329ea4f2 (1 revision) (flutter/flutter#196386)
2026-11-11 [email protected] [Impeller] Do not clamp the local coverage limit to the root render target (flutter/flutter#195860)
2026-11-11 [email protected] [Impeller] Use separate uniform buffers on VMware SVGA3D (flutter/flutter#196022)
2026-11-11 [email protected] [flutter_tools] Introduce AndroidSdkProvider for lazy native_assets SDK lookup (flutter/flutter#196122)
2026-11-11 [email protected] Moves linux to ThinLTO. (flutter/flutter#196314)
2026-11-11 [email protected] [flutter_tools] Migrate bin/fuchsia_tester.dart off globals and runInContext (flutter/flutter#196074)
2026-11-11 [email protected] Changes the tolerances for frame_rate_main_test.dart. (flutter/flutter#196304)
2026-11-11 [email protected] Roll Packages from 08faf64 to 653628e (16 revisions) (flutter/flutter#196381)
2026-11-11 [email protected] Allow SliverCrossAxisGroup children to lay out with zero cross-axis extent instead of asserting (flutter/flutter#191287)
2026-11-11 [email protected] Roll Skia from cc4c54f752ba to b89c24bbab8c (4 revisions) (flutter/flutter#196375)
2026-11-11 [email protected] [Linux] Fix layer offset when compositing with glBlitFramebuffer (flutter/flutter#196189)
2026-11-11 [email protected] [flutter_tools] Inject CrashReportSender into SwiftPM migration (flutter/flutter#196315)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode 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
bkonyi added a commit to bkonyi/flutter that referenced this pull request Nov 13, 2026
…er#196264)

Replaces the ambiguously named `TargetPlatform.simpleName` getter with a
strongly typed `CpuArch get cpuArch` getter on `TargetPlatform`
(following up on review feedback from
flutter#195841). Updates
`getLinuxBuildDirectory`, `getWindowsBuildDirectory`, and
`BuildLinuxCommand` to resolve architectures through
`TargetPlatform.cpuArch` and `HostPlatform.cpuArch`, and throws
`UnsupportedError` on multi-architecture, architecture-independent, or
non-native platforms (including removing the legacy
`TargetPlatform.darwin => 'x64'` mapping).

Part of flutter#190755

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.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-linux Building on or for Linux specifically platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows 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