Repository navigation
Conversation
…che for tool extensions Introduce `ArtifactService` (`artifact.getArtifacts` and `artifact.downloadArtifacts`), `ArtifactDependency`, `HostPlatform`, and `ExtensionArtifactManager` so tool extensions can declare and download platform-specific SDK artifacts with SHA-256 verification and `flutter precache` integration.
Pass null targetPlatforms in PrecacheCommand when downloading default or all platform artifacts so custom extension target platforms are included by default, while filtering when explicit platform flags are set. Guard AssembleCommand extension artifact downloads behind non-built-in targets, validate ArtifactDependency.name and sha256 as single path segments, remove the RpcException re-export from flutter_tools_extension, and strengthen hermetic test coverage.
…support multiple targetPlatforms Refactor ExtensionArtifactManager to accept ToolContext and decompose _downloadAndVerifyArtifact into private helper methods. Update ArtifactService and LinuxArtifactService to accept Set<String>? targetPlatforms and parameterize LinuxArtifactService storageBaseUrl and engineRevision.
…ster Replaced the direct dart:convert import in ExtensionArtifactManager with ../convert.dart, defaulted LinuxArtifactService to an empty artifact list in production, added cross-process lockfile synchronization via FileSystem.runLocked, wrapped network and unzip errors in ToolExit, reverted the unused AssembleCommand hook, normalized targetPlatforms and --force handling in PrecacheCommand and RunCommand, and tightened SHA-256 and URL scheme validation in ArtifactDependency.fromJson.
…ts in ExtensionArtifactManager
…acts # Conflicts: # packages/flutter_tools/test/src/fakes.dart
…BuildCommand, RunCommand, and PrecacheCommand
…xtensionArtifactManager docs
…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
…ifacts # Conflicts: # 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_linux_prototype/lib/src/artifact.dart
…and drop sha256Url Simplifies `ExtensionArtifactManager` by removing `_fetchRemoteSha256` and `sha256Url` handling, unifying cached single-file and extracted archive verification via `.sha256` stamp files in `_isArtifactCachedAndVerified`, deleting `_verifyCachedFile` and `_verifyCachedDirectory`, and enforcing built-in artifact precedence in `resolveExtensionBuildTargetArtifacts`. Part of flutter#190755 Part of flutter#190754
…n ArtifactDependency
…_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.
… tighten artifact validation Renames ArtifactService.downloadArtifacts to listRequiredArtifacts, makes _isValidSinglePathSegment private with an allowlist regular expression disallowing trailing dots, throws FormatException from ArtifactDependency.listFromJson on non-list or non-map payloads, asserts cliName ends with - in HostPlatform, and maps darwin to macos in ExtensionManager.hostPlatformName. Part of flutter#190755 Part of flutter#190754
…ifacts # Conflicts: # packages/flutter_tools/lib/src/commands/build.dart # packages/flutter_tools/lib/src/context/tool_dependencies.dart # packages/flutter_tools/test/commands.shard/hermetic/tool_extensions_build_test.dart # packages/flutter_tools/test/src/fakes.dart
…tent-addressed artifact cache layout Convert `ArtifactDependency` in `package:flutter_tools_core` into a sealed class hierarchy with `RemoteArtifactDependency` (`ArtifactDependency.remote`) and `LocalArtifactDependency` (`ArtifactDependency.local`), including `type` JSON discrimination and `file:` URI validation for `localUri` and optional `stampUri`. Update `ExtensionArtifactManager` to resolve `LocalArtifactDependency` directly on disk (validating `localUri` and `stampUri` existence), cache `RemoteArtifactDependency` downloads under `<sharedRoot>/<extensionName>/<sha256>/<name>` using `$DART_DATA_HOME/flutter_tool_extensions/artifacts` or `$HOME/.flutter_tool_extensions/artifacts`, and guard concurrent downloads with in-process future deduplication and cross-process `FileSystem.runLocked`. Part of flutter#190755 Part of flutter#190751
…tform by osName and cpuArch (flutter#195841) 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 - flutter#195352 (merged) - **flutter#195841 (this PR)** - flutter#194588 Part of flutter#190755 Part of flutter#190754
Wire `ExtensionArtifactManager` through `FlutterDeviceManager`, `ExtensionDevices`, and `ExtensionBackedDevice.startApp` so `flutter run`, `flutter drive`, and `flutter test integration_test` resolve and pass `extensionArtifacts` scoped to the owning extension rather than failing on custom `ArtifactService` dependencies. Add `executables` (`Set<String>`) and `isExecutable` (`bool`) to `RemoteArtifactDependency` and apply `chmod a+x` during `ExtensionArtifactManager` staging (rejecting missing or symlinked paths), require `type` and `archiveFormat` on the JSON wire, scope `ExtensionBuildSubCommand` artifact resolution to the target's owning extension, and normalize the `macos` host alias to `darwin` on `HostPlatform`. Part of flutter#190755 Part of flutter#190754
There was a problem hiding this comment.
Code Review
This pull request introduces ExtensionArtifactManager to manage querying, downloading, and verifying custom artifacts required by tool extensions in a shared content-addressed cache. It refactors ArtifactDependency into a sealed class supporting both remote and local variants, normalizes the 'macos' host platform alias to 'darwin', and integrates artifact resolution into build, precache, and device commands. Feedback on the changes suggests retrieving the globally configured HttpClient from the context in ExtensionArtifactManager instead of instantiating it directly, which ensures system proxies, custom certificates, and user-agent settings are respected.
| import 'package:flutter_tools_extension/flutter_tools_extension.dart'; | ||
| import 'package:meta/meta.dart'; | ||
|
|
||
| import '../base/common.dart'; |
| required this._toolContext, | ||
| @visibleForTesting this._cacheDir, | ||
| @visibleForTesting HttpClient? httpClient, | ||
| }) : _httpClient = httpClient ?? HttpClient(); |
There was a problem hiding this comment.
Using HttpClient() directly bypasses the configured system proxies, custom certificates, and user-agent settings of the Flutter tool. Retrieve the globally configured HttpClient from the context instead, falling back to a new HttpClient instance if not available.
| }) : _httpClient = httpClient ?? HttpClient(); | |
| }) : _httpClient = httpClient ?? context.get<HttpClient>() ?? HttpClient(); |
… caching Wire `ExtensionArtifactManager` into `AssembleCommand` and `ExtensionTarget` so custom `ExtensionArtifactSource` and `ExtensionHostArtifactSource` inputs resolve for reachable assemble targets and track `LocalArtifactDependency.stampUri` (or remote `.zip` `.sha256` stamp files) without walking directory trees. Filter `ensureArtifactsDownloaded` by declared `artifactNames` during `flutter build`, `flutter run`, and `flutter assemble` (preventing unrequested downloads and undeclared keys in `resolvedArtifacts`), simplify content-addressed cache checks and `ArtifactDependency` validation, use `os.makeExecutable`, collapse `HostPlatform.fromOsAndArch`, and make `ExtensionArtifactManager` non-nullable across `ExtensionDevices`, `ExtensionBackedDevice`, and `ExtensionBuildSubCommand`. Part of flutter#190755 Part of flutter#190754
Adds
ExtensionArtifactManagerto query active tool extensions implementingArtifactService(artifact.listRequiredArtifacts), verify SHA-256 checksums, and cache remote artifacts in a shared content-addressed cache under$DART_DATA_HOME/flutter_tool_extensions/artifacts/<extensionName>/<sha256>/<name>(falling back to%LOCALAPPDATA%\flutter_tool_extensions\artifacts,%USERPROFILE%\.flutter_tool_extensions\artifacts, or$HOME/.flutter_tool_extensions/artifactswhenDART_DATA_HOMEis unset), using cross-process file locking (FileSystemLocking.runLocked), atomic staging renames,.sha256completion stamps for extracted.ziparchives, and in-process download deduplication.Also updates
ArtifactDependencyand host command integration:ArtifactDependencyinto sealedRemoteArtifactDependency(with required wiretypeandarchiveFormat, plusexecutablesandisExecutablemarking binaries executable viaos.makeExecutableduring staging while rejecting missing or symlinked paths) andLocalArtifactDependency(resolved directly on disk with optionalstampUritracking).'macos'host OS alias to'darwin'acrossHostPlatformconstructors and parsers so'macos-arm64'and'darwin-arm64'resolve identically.ExtensionArtifactManagerintoToolDependencies,flutter precache(requesting all extension target platforms on default or--all-platformsruns since built-inDevelopmentArtifactflags do not enumerate out-of-tree platforms),flutter build,flutter assemble(ExtensionTargettrackingLocalArtifactDependency.stampUriand remote.zip.sha256stamp files without walking directory trees), andExtensionBackedDevice.startApp(filtering downloads to declared artifact names and scoping resolution per owning extension acrossflutter run,flutter drive, andflutter test integration_test).Part of #190755
Part of #190754