Unverified Commit ddab09f5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] enable LocalDevFSWriter for desktop devices, iOS simulator (#66678)

* [flutter_tools] enable LocalDevFSWriter for desktop devices, iOS simulator

* Update device.dart

* Update desktop_device_test.dart

* fix analysis errors
parent ccdaa370
...@@ -47,8 +47,10 @@ abstract class DesktopDevice extends Device { ...@@ -47,8 +47,10 @@ abstract class DesktopDevice extends Device {
final Set<Process> _runningProcesses = <Process>{}; final Set<Process> _runningProcesses = <Process>{};
final DesktopLogReader _deviceLogReader = DesktopLogReader(); final DesktopLogReader _deviceLogReader = DesktopLogReader();
DevFSWriter get devFSWriter => _desktopDevFSWriter ??= LocalDevFSWriter(fileSystem: _fileSystem); @override
LocalDevFSWriter _desktopDevFSWriter; DevFSWriter createDevFSWriter(covariant ApplicationPackage app, String userIdentifier) {
return LocalDevFSWriter(fileSystem: _fileSystem);
}
// Since the host and target devices are the same, no work needs to be done // Since the host and target devices are the same, no work needs to be done
// to install the application. // to install the application.
......
...@@ -27,6 +27,7 @@ import 'base/terminal.dart'; ...@@ -27,6 +27,7 @@ import 'base/terminal.dart';
import 'base/user_messages.dart' hide userMessages; import 'base/user_messages.dart' hide userMessages;
import 'base/utils.dart'; import 'base/utils.dart';
import 'build_info.dart'; import 'build_info.dart';
import 'devfs.dart';
import 'features.dart'; import 'features.dart';
import 'fuchsia/fuchsia_device.dart'; import 'fuchsia/fuchsia_device.dart';
import 'fuchsia/fuchsia_sdk.dart'; import 'fuchsia/fuchsia_sdk.dart';
...@@ -622,6 +623,18 @@ abstract class Device { ...@@ -622,6 +623,18 @@ abstract class Device {
Future<String> get sdkNameAndVersion; Future<String> get sdkNameAndVersion;
/// Create a platform-specific [DevFSWriter] for the given [app], or
/// null if the device does not support them.
///
/// For example, the destkop device classes can use a writer which
/// copies the files across the local file system.
DevFSWriter createDevFSWriter(
covariant ApplicationPackage app,
String userIdentifier,
) {
return null;
}
/// Get a log reader for this device. /// Get a log reader for this device.
/// ///
/// If `app` is specified, this will return a log reader specific to that /// If `app` is specified, this will return a log reader specific to that
......
...@@ -296,8 +296,10 @@ class IOSSimulator extends Device { ...@@ -296,8 +296,10 @@ class IOSSimulator extends Device {
final SimControl _simControl; final SimControl _simControl;
final Xcode _xcode; final Xcode _xcode;
DevFSWriter get devFSWriter => _desktopDevFSWriter ??= LocalDevFSWriter(fileSystem: globals.fs); @override
LocalDevFSWriter _desktopDevFSWriter; DevFSWriter createDevFSWriter(covariant ApplicationPackage app, String userIdentifier) {
return LocalDevFSWriter(fileSystem: globals.fs);
}
@override @override
Future<bool> get isLocalEmulator async => true; Future<bool> get isLocalEmulator async => true;
......
...@@ -185,6 +185,8 @@ class FlutterDevice { ...@@ -185,6 +185,8 @@ class FlutterDevice {
final ResidentCompiler generator; final ResidentCompiler generator;
final BuildInfo buildInfo; final BuildInfo buildInfo;
final String userIdentifier; final String userIdentifier;
DevFSWriter devFSWriter;
Stream<Uri> observatoryUris; Stream<Uri> observatoryUris;
vm_service.VmService vmService; vm_service.VmService vmService;
DevFS devFS; DevFS devFS;
...@@ -573,6 +575,7 @@ class FlutterDevice { ...@@ -573,6 +575,7 @@ class FlutterDevice {
globals.printError(message); globals.printError(message);
return 1; return 1;
} }
devFSWriter = device.createDevFSWriter(package, userIdentifier);
final Map<String, dynamic> platformArgs = <String, dynamic>{}; final Map<String, dynamic> platformArgs = <String, dynamic>{};
...@@ -620,6 +623,7 @@ class FlutterDevice { ...@@ -620,6 +623,7 @@ class FlutterDevice {
buildInfo: coldRunner.debuggingOptions.buildInfo, buildInfo: coldRunner.debuggingOptions.buildInfo,
applicationBinary: coldRunner.applicationBinary, applicationBinary: coldRunner.applicationBinary,
); );
devFSWriter = device.createDevFSWriter(package, userIdentifier);
final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName; final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName;
final bool prebuiltMode = coldRunner.applicationBinary != null; final bool prebuiltMode = coldRunner.applicationBinary != null;
...@@ -715,7 +719,7 @@ class FlutterDevice { ...@@ -715,7 +719,7 @@ class FlutterDevice {
pathToReload: pathToReload, pathToReload: pathToReload,
invalidatedFiles: invalidatedFiles, invalidatedFiles: invalidatedFiles,
packageConfig: packageConfig, packageConfig: packageConfig,
devFSWriter: null, devFSWriter: devFSWriter,
); );
} on DevFSException { } on DevFSException {
devFSStatus.cancel(); devFSStatus.cancel();
......
...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/desktop_device.dart'; import 'package:flutter_tools/src/desktop_device.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
...@@ -242,6 +243,12 @@ void main() { ...@@ -242,6 +243,12 @@ void main() {
expect(result, 2); expect(result, 2);
expect(portForwarder.forwardedPorts.isEmpty, true); expect(portForwarder.forwardedPorts.isEmpty, true);
}); });
testUsingContext('createDevFSWriter returns a LocalDevFSWriter', () {
final FakeDesktopDevice device = setUpDesktopDevice();
expect(device.createDevFSWriter(null, ''), isA<LocalDevFSWriter>());
});
} }
FakeDesktopDevice setUpDesktopDevice({ FakeDesktopDevice setUpDesktopDevice({
......
...@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/mac.dart'; import 'package:flutter_tools/src/ios/mac.dart';
...@@ -1000,6 +1001,16 @@ flutter: ...@@ -1000,6 +1001,16 @@ flutter:
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('createDevFSWriter returns a LocalDevFSWriter', () {
final IOSSimulator simulator = IOSSimulator(
'test',
simControl: mockSimControl,
xcode: mockXcode,
);
expect(simulator.createDevFSWriter(null, ''), isA<LocalDevFSWriter>());
});
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment