allow optional direct injection of Config instance into DevFS (#144002)
In service of https://github.com/flutter/flutter/issues/143348
This will make testing of asset transformation hot reload behavior easier (specifically in that we can avoid having to write a test that looks like this: 5d02c27248/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart (L167-L249)
This commit is contained in:
@@ -800,6 +800,7 @@ HostPlatform getCurrentHostPlatform() {
|
||||
|
||||
/// Returns the top-level build output directory.
|
||||
String getBuildDirectory([Config? config, FileSystem? fileSystem]) {
|
||||
// TODO(andrewkolos): Prefer required parameters instead of falling back to globals.
|
||||
// TODO(johnmccutchan): Stop calling this function as part of setting
|
||||
// up command line argument processing.
|
||||
final Config localConfig = config ?? globals.config;
|
||||
@@ -825,8 +826,9 @@ String getAotBuildDirectory() {
|
||||
}
|
||||
|
||||
/// Returns the asset build output directory.
|
||||
String getAssetBuildDirectory() {
|
||||
return globals.fs.path.join(getBuildDirectory(), 'flutter_assets');
|
||||
String getAssetBuildDirectory([Config? config, FileSystem? fileSystem]) {
|
||||
return (fileSystem ?? globals.fs)
|
||||
.path.join(getBuildDirectory(config, fileSystem), 'flutter_assets');
|
||||
}
|
||||
|
||||
/// Returns the iOS build output directory.
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:package_config/package_config.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import 'asset.dart';
|
||||
import 'base/config.dart';
|
||||
import 'base/context.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/io.dart';
|
||||
@@ -456,6 +457,7 @@ class DevFS {
|
||||
HttpClient? httpClient,
|
||||
Duration? uploadRetryThrottle,
|
||||
StopwatchFactory stopwatchFactory = const StopwatchFactory(),
|
||||
Config? config,
|
||||
}) : _vmService = serviceProtocol,
|
||||
_logger = logger,
|
||||
_fileSystem = fileSystem,
|
||||
@@ -468,13 +470,15 @@ class DevFS {
|
||||
httpClient: httpClient ?? ((context.get<HttpClientFactory>() == null)
|
||||
? HttpClient()
|
||||
: context.get<HttpClientFactory>()!())),
|
||||
_stopwatchFactory = stopwatchFactory;
|
||||
_stopwatchFactory = stopwatchFactory,
|
||||
_config = config;
|
||||
|
||||
final FlutterVmService _vmService;
|
||||
final _DevFSHttpWriter _httpWriter;
|
||||
final Logger _logger;
|
||||
final FileSystem _fileSystem;
|
||||
final StopwatchFactory _stopwatchFactory;
|
||||
final Config? _config;
|
||||
|
||||
final String fsName;
|
||||
final Directory? rootDirectory;
|
||||
@@ -615,8 +619,8 @@ class DevFS {
|
||||
|
||||
// The tool writes the assets into the AssetBundle working dir so that they
|
||||
// are in the same location in DevFS and the iOS simulator.
|
||||
final String assetBuildDirPrefix = _asUriPath(getAssetBuildDirectory());
|
||||
final String assetDirectory = getAssetBuildDirectory();
|
||||
final String assetDirectory = getAssetBuildDirectory(_config, _fileSystem);
|
||||
final String assetBuildDirPrefix = _asUriPath(assetDirectory);
|
||||
bundle.entries.forEach((String archivePath, AssetBundleEntry entry) {
|
||||
// If the content is backed by a real file, isModified will file stat and return true if
|
||||
// it was modified since the last time this was called.
|
||||
|
||||
Reference in New Issue
Block a user