Commit e4f586d2 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Enable Hot Restart on Windows (#8548)

parent 1bb164ab
...@@ -313,25 +313,23 @@ class HotRunner extends ResidentRunner { ...@@ -313,25 +313,23 @@ class HotRunner extends ResidentRunner {
_devFS = null; _devFS = null;
} }
Future<Null> _launchInView(String entryPath, Future<Null> _launchInView(Uri entryUri,
String packagesPath, Uri packagesUri,
String assetsDirectoryPath) async { Uri assetsDirectoryUri) async {
FlutterView view = vmService.vm.mainView; FlutterView view = vmService.vm.mainView;
return view.runFromSource(entryPath, packagesPath, assetsDirectoryPath); return view.runFromSource(entryUri, packagesUri, assetsDirectoryUri);
} }
Future<Null> _launchFromDevFS(ApplicationPackage package, Future<Null> _launchFromDevFS(ApplicationPackage package,
String mainScript) async { String mainScript) async {
String entryPath = fs.path.relative(mainScript, from: projectRootPath); String entryUri = fs.path.relative(mainScript, from: projectRootPath);
String deviceEntryPath = Uri deviceEntryUri = _devFS.baseUri.resolveUri(fs.path.toUri(entryUri));
_devFS.baseUri.resolve(entryPath).toFilePath(); Uri devicePackagesUri = _devFS.baseUri.resolve('.packages');
String devicePackagesPath = Uri deviceAssetsDirectoryUri =
_devFS.baseUri.resolve('.packages').toFilePath(); _devFS.baseUri.resolveUri(fs.path.toUri(getAssetBuildDirectory()));
String deviceAssetsDirectoryPath = await _launchInView(deviceEntryUri,
_devFS.baseUri.resolve(getAssetBuildDirectory()).toFilePath(); devicePackagesUri,
await _launchInView(deviceEntryPath, deviceAssetsDirectoryUri);
devicePackagesPath,
deviceAssetsDirectoryPath);
} }
Future<OperationResult> _restartFromSources() async { Future<OperationResult> _restartFromSources() async {
......
...@@ -710,15 +710,16 @@ class VM extends ServiceObjectOwner { ...@@ -710,15 +710,16 @@ class VM extends ServiceObjectOwner {
} }
Future<ServiceMap> runInView(String viewId, Future<ServiceMap> runInView(String viewId,
String main, Uri main,
String packages, Uri packages,
String assetsDirectory) { Uri assetsDirectory) {
// TODO(goderbauer): Transfer Uri (instead of file path) when remote end supports it.
return invokeRpc('_flutter.runInView', return invokeRpc('_flutter.runInView',
params: <String, dynamic> { params: <String, dynamic> {
'viewId': viewId, 'viewId': viewId,
'mainScript': main, 'mainScript': main.toFilePath(windows: false),
'packagesFile': packages, 'packagesFile': packages.toFilePath(windows: false),
'assetDirectory': assetsDirectory 'assetDirectory': assetsDirectory.toFilePath(windows: false)
}); });
} }
...@@ -1024,9 +1025,9 @@ class FlutterView extends ServiceObject { ...@@ -1024,9 +1025,9 @@ class FlutterView extends ServiceObject {
} }
// TODO(johnmccutchan): Report errors when running failed. // TODO(johnmccutchan): Report errors when running failed.
Future<Null> runFromSource(String entryPath, Future<Null> runFromSource(Uri entryUri,
String packagesPath, Uri packagesUri,
String assetsDirectoryPath) async { Uri assetsDirectoryUri) async {
final String viewId = id; final String viewId = id;
// When this completer completes the isolate is running. // When this completer completes the isolate is running.
final Completer<Null> completer = new Completer<Null>(); final Completer<Null> completer = new Completer<Null>();
...@@ -1040,9 +1041,9 @@ class FlutterView extends ServiceObject { ...@@ -1040,9 +1041,9 @@ class FlutterView extends ServiceObject {
} }
}); });
await owner.vm.runInView(viewId, await owner.vm.runInView(viewId,
entryPath, entryUri,
packagesPath, packagesUri,
assetsDirectoryPath); assetsDirectoryUri);
await completer.future; await completer.future;
await owner.vm.refreshViews(); await owner.vm.refreshViews();
await subscription.cancel(); await subscription.cancel();
......
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