Repository navigation
[tool] Migrate Apple build subcommands and toolchain to modular dependency injection - #190780
Conversation
ce6f1c4 to
06645da
Compare
06645da to
7f04e0b
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors BuildCommand and its subcommands to use constructor dependency injection for dependencies like ToolContext and AppleContext instead of relying on global variables. The corresponding unit tests are updated to use helper functions for instantiating these commands with mock contexts. Feedback on the changes includes a potential regression in BuildIOSCommand where reading the device ID directly from globalResults bypasses the FLUTTER_DEVICE_ID environment variable, an inconsistency in BuildCommand where the passed platform parameter is not used uniformly, and instances where the terminal variable is typed as the concrete AnsiTerminal instead of the generic Terminal interface.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the BuildCommand and its subcommands in flutter_tools to use a new ToolContext and AppleContext for dependency injection, replacing the previous global-based access pattern. It also updates several test files to support these changes by introducing helper functions for command creation. The review feedback identifies missing imports in test files that are necessary to resolve compilation errors for the newly introduced Fake classes.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors various build commands, including BuildCommand, BuildIOSCommand, and BuildMacOSFrameworkCommand, to accept dependency-injected contexts (AppleContext, ToolContext, and BuildSystem) instead of relying on global variables, which improves testability. Corresponding unit tests are updated to utilize helper methods for instantiating these commands with fake contexts. Feedback on the changes suggests refactoring the constructor of BuildCommand to eliminate redundant instantiations of CocoaPods and Xcode when setting up the effective AppleContext.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors BuildCommand and its subcommands (including BuildIOSCommand, BuildIOSFrameworkCommand, BuildMacosCommand, and BuildMacOSFrameworkCommand) to use dependency injection via ToolContext and AppleContext instead of relying on global variables. Unit tests are updated to use helper instantiation methods. Feedback on these changes suggests simplifying the BuildCommand constructor by moving the inline dependency graph construction to a factory, and warns against using the PersistentToolState.test() constructor in production code paths.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors several build commands in flutter_tools to accept injected contexts (AppleContext, ToolContext, and BuildSystem) instead of relying on global variables, improving testability. The corresponding unit tests have been updated to use helper methods for command instantiation. Feedback includes using effectivePlatform instead of platform when instantiating the fallback AnsiTerminal in build.dart, and accessing the private _toolContext field instead of the public getter toolContext in build_ios.dart for consistency.
…ff-Refiner-self-adb31f30
Migrates `_toolContext` and `_appleContext` field extractions to Dart 3 object pattern destructuring in `BuildIOSArchiveCommand.runCommand`.
Migrates context field extractions to Dart 3 object pattern destructuring in `build_ios_framework.dart` and `build_macos_framework.dart`.
…lar context objects
Refactors XcodeCodeSigningSettings to provide context constructors
(XcodeCodeSigningSettings({required PlistParser plistParser, required ToolContext toolContext})
and XcodeCodeSigningSettings.fromContexts({required AppleContext appleContext, required ToolContext toolContext}))
instead of requiring callers to unpack 8+ individual arguments. Adds
DarwinAddToAppCodesigning.fromContexts and refactors BuildCommand to instantiate
codesigning from context objects and pass directly to subcommands.
flutter/flutter@5a6cfa7...63170e9 2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339) 2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338) 2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333) 2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331) 2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329) 2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317) 2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321) 2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316) 2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173) 2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314) 2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773) 2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780) 2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089) 2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765) 2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768) 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] 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
…dependency injection (flutter#192250) ## Summary Part 15b of the modular dependency injection migration. Migrates `BuildIOSCommand` and `BuildIOSArchiveCommand` (`flutter build ios`, `flutter build ipa`) to modular dependency injection with `ToolContext`, `AppleContext`, and `BuildSystem`, eliminating direct dependencies on `globals.dart`. Stacked on flutter#190780 Compare: bkonyi/flutter@di/15-apple-build-and-toolchain...di/15b-ios-build-commands Part of flutter#47161
…r#12767) flutter/flutter@5a6cfa7...63170e9 2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339) 2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338) 2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333) 2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331) 2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329) 2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317) 2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321) 2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316) 2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173) 2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314) 2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773) 2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780) 2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089) 2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765) 2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768) 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] 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
…r#12767) flutter/flutter@5a6cfa7...63170e9 2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339) 2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338) 2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333) 2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331) 2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329) 2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317) 2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321) 2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316) 2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173) 2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314) 2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773) 2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780) 2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089) 2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765) 2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768) 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] 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
Summary
Part 15 of the modular dependency injection migration.
BuildIOSCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})BuildIOSFrameworkCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})BuildMacOSCommand({required BuildSystem buildSystem, required ToolContext toolContext, required bool verboseHelp})BuildMacOSFrameworkCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})appleContext,toolContext) and eliminates ambient globals.fake_build_command.darttest helper and addsTerminalsupport toFakeToolContext.test/commands.shard/hermetic/build_ios_test.dart,build_macos_test.dart, andbuild_darwin_framework_test.dartto hermetictestWithoutContext.Part of #188471