diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index ec33659f41b..9b11fde9d8c 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -26,7 +26,6 @@ enum Artifact { flutterPatchedSdkPath, frontendServerSnapshotForEngineDartSdk, engineDartSdkPath, - engineDartBinary, } String _artifactToFileName(Artifact artifact) { @@ -58,8 +57,6 @@ String _artifactToFileName(Artifact artifact) { return 'dart-sdk'; case Artifact.frontendServerSnapshotForEngineDartSdk: return 'frontend_server.dart.snapshot'; - case Artifact.engineDartBinary: - return 'dart'; } assert(false, 'Invalid artifact $artifact.'); return null; @@ -173,8 +170,6 @@ class CachedArtifacts extends Artifacts { return fs.path.join(engineArtifactsPath, platformDirName, _artifactToFileName(artifact)); case Artifact.engineDartSdkPath: return dartSdkPath; - case Artifact.engineDartBinary: - return fs.path.join(dartSdkPath,'bin', _artifactToFileName(artifact)); case Artifact.platformKernelDill: return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); case Artifact.platformLibrariesJson: @@ -257,8 +252,6 @@ class LocalEngineArtifacts extends Artifacts { return fs.path.join(_hostEngineOutPath, 'gen', _artifactToFileName(artifact)); case Artifact.engineDartSdkPath: return fs.path.join(_hostEngineOutPath, 'dart-sdk'); - case Artifact.engineDartBinary: - return fs.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', _artifactToFileName(artifact)); } assert(false, 'Invalid artifact $artifact.'); return null; diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index e374eda5457..251573e25ad 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -357,7 +357,6 @@ class AppDomain extends Domain { @required bool trackWidgetCreation, String projectRootPath, String packagesFilePath, - String dillOutputPath, bool ipv6: false, }) async { if (await device.isLocalEmulator && !options.buildInfo.supportsEmulator) { @@ -372,7 +371,6 @@ class AppDomain extends Domain { device, previewDart2: options.buildInfo.previewDart2, trackWidgetCreation: trackWidgetCreation, - dillOutputPath: dillOutputPath, ); ResidentRunner runner; @@ -386,7 +384,6 @@ class AppDomain extends Domain { applicationBinary: applicationBinary, projectRootPath: projectRootPath, packagesFilePath: packagesFilePath, - dillOutputPath: dillOutputPath, ipv6: ipv6, hostIsIde: true, ); diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 8541b5dce10..b3699873f66 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -147,10 +147,6 @@ class RunCommand extends RunCommandBase { 'results out to "refresh_benchmark.json", and exit. This flag is\n' 'intended for use in generating automated flutter benchmarks.'); - argParser.addOption('output-dill', - hide: !verboseHelp, - help: 'Specify the path to frontend server output kernel file.'); - argParser.addOption(FlutterOptions.kExtraFrontEndOptions, hide: true); argParser.addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true); } @@ -266,7 +262,6 @@ class RunCommand extends RunCommandBase { trackWidgetCreation: argResults['track-widget-creation'], projectRootPath: argResults['project-root'], packagesFilePath: globalResults['packages'], - dillOutputPath: argResults['output-dill'], ipv6: ipv6, ); } catch (error) { @@ -306,7 +301,6 @@ class RunCommand extends RunCommandBase { device, previewDart2: argResults['preview-dart-2'], trackWidgetCreation: argResults['track-widget-creation'], - dillOutputPath: argResults['output-dill'], ); }).toList(); @@ -320,7 +314,6 @@ class RunCommand extends RunCommandBase { applicationBinary: argResults['use-application-binary'], projectRootPath: argResults['project-root'], packagesFilePath: globalResults['packages'], - dillOutputPath: argResults['output-dill'], stayResident: stayResident, ipv6: ipv6, ); diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index f99d21b8e3c..bfee499b37a 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -8,10 +8,24 @@ import 'dart:convert'; import 'package:usage/uuid/uuid.dart'; import 'artifacts.dart'; +import 'base/common.dart'; +import 'base/file_system.dart'; import 'base/io.dart'; import 'base/process_manager.dart'; import 'globals.dart'; +String _dartExecutable() { + final String engineDartSdkPath = artifacts.getArtifactPath( + Artifact.engineDartSdkPath + ); + if (!fs.isDirectorySync(engineDartSdkPath)) { + throwToolExit('No dart sdk Flutter host engine build found at $engineDartSdkPath.\n' + 'Note that corresponding host engine build is required even when targeting particular device platforms.', + exitCode: 2); + } + return fs.path.join(engineDartSdkPath, 'bin', 'dart'); +} + class _StdoutHandler { _StdoutHandler() { reset(); @@ -60,7 +74,7 @@ Future compile( if (!sdkRoot.endsWith('/')) sdkRoot = '$sdkRoot/'; final List command = [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + _dartExecutable(), frontendServer, '--sdk-root', sdkRoot, @@ -140,13 +154,13 @@ class ResidentCompiler { /// Binary file name is returned if compilation was successful, otherwise /// null is returned. Future recompile(String mainPath, List invalidatedFiles, - {String outputPath, String packagesFilePath}) async { + {String outputPath}) async { stdoutHandler.reset(); // First time recompile is called we actually have to compile the app from // scratch ignoring list of invalidated files. if (_server == null) - return _compile(mainPath, outputPath, packagesFilePath); + return _compile(mainPath, outputPath); final String inputKey = new Uuid().generateV4(); _server.stdin.writeln('recompile ${mainPath != null ? mainPath + " ": ""}$inputKey'); @@ -156,12 +170,12 @@ class ResidentCompiler { return stdoutHandler.outputFilename.future; } - Future _compile(String scriptFilename, String outputPath, String packagesFilePath) async { + Future _compile(String scriptFilename, String outputPath) async { final String frontendServer = artifacts.getArtifactPath( Artifact.frontendServerSnapshotForEngineDartSdk ); final List args = [ - artifacts.getArtifactPath(Artifact.engineDartBinary), + _dartExecutable(), frontendServer, '--sdk-root', _sdkRoot, @@ -172,9 +186,6 @@ class ResidentCompiler { if (outputPath != null) { args.addAll(['--output-dill', outputPath]); } - if (packagesFilePath != null) { - args.addAll(['--packages', packagesFilePath]); - } if (_trackWidgetCreation) { args.add('--track-widget-creation'); } diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index efdf3edbc5e..00a79b71053 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -407,7 +407,6 @@ class DevFS { bool bundleDirty: false, Set fileFilter, ResidentCompiler generator, - String dillOutputPath, bool fullRestart: false, }) async { // Mark all entries as possibly deleted. @@ -501,8 +500,7 @@ class DevFS { } final String compiledBinary = await generator.recompile(mainPath, invalidatedFiles, - outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'), - packagesFilePath : _packagesFilePath); + outputPath: fs.path.join(getBuildDirectory(), 'app.dill')); if (compiledBinary != null && compiledBinary.isNotEmpty) dirtyEntries.putIfAbsent( Uri.parse(target + '.dill'), diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 3abc1525ad4..f671cd2fde2 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -35,14 +35,12 @@ class FlutterDevice { DevFS devFS; ApplicationPackage package; ResidentCompiler generator; - String dillOutputPath; StreamSubscription _loggingSubscription; FlutterDevice(this.device, { @required bool previewDart2, @required bool trackWidgetCreation, - this.dillOutputPath, }) { if (previewDart2) { generator = new ResidentCompiler( @@ -388,8 +386,7 @@ class FlutterDevice { bundleDirty: bundleDirty, fileFilter: fileFilter, generator: generator, - fullRestart: fullRestart, - dillOutputPath: dillOutputPath, + fullRestart: fullRestart ); } on DevFSException { devFSStatus.cancel(); diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index b0f65d651fd..f3258f935ae 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -42,7 +42,6 @@ class HotRunner extends ResidentRunner { this.hostIsIde: false, String projectRootPath, String packagesFilePath, - this.dillOutputPath, bool stayResident: true, bool ipv6: false, }) : super(devices, @@ -58,7 +57,6 @@ class HotRunner extends ResidentRunner { final String applicationBinary; final bool hostIsIde; Set _dartDependencies; - final String dillOutputPath; final Map> benchmarkData = >{}; // The initial launch is from a snapshot. @@ -336,12 +334,7 @@ class HotRunner extends ResidentRunner { for (FlutterDevice device in flutterDevices) { final Uri deviceEntryUri = device.devFS.baseUri.resolveUri( fs.path.toUri(entryUri)); - Uri devicePackagesUri; - if (packagesFilePath != null) { - devicePackagesUri = fs.path.toUri(packagesFilePath); - } else { - devicePackagesUri = device.devFS.baseUri.resolve('.packages'); - } + final Uri devicePackagesUri = device.devFS.baseUri.resolve('.packages'); final Uri deviceAssetsDirectoryUri = device.devFS.baseUri.resolveUri( fs.path.toUri(getAssetBuildDirectory())); await _launchInView(device, @@ -396,10 +389,7 @@ class HotRunner extends ResidentRunner { } // We are now running from source. _runningFromSnapshot = false; - final String launchPath = debuggingOptions.buildInfo.previewDart2 - ? dillOutputPath ?? mainPath + '.dill' - : mainPath; - await _launchFromDevFS(launchPath); + await _launchFromDevFS(debuggingOptions.buildInfo.previewDart2 ? mainPath + '.dill' : mainPath); restartTimer.stop(); printTrace('Restart performed in ' '${getElapsedAsMilliseconds(restartTimer.elapsed)}.'); diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 19b45cde744..a51e2b698a1 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -59,8 +59,6 @@ void installHook({ bool machine: false, bool startPaused: false, bool previewDart2: false, - int port: 0, - String dillFilePath, int observatoryPort, InternetAddressType serverType: InternetAddressType.IP_V4, }) { @@ -77,8 +75,6 @@ void installHook({ explicitObservatoryPort: observatoryPort, host: _kHosts[serverType], previewDart2: previewDart2, - port: port, - dillFilePath: dillFilePath, ), ); } @@ -104,8 +100,6 @@ class _FlutterPlatform extends PlatformPlugin { this.explicitObservatoryPort, this.host, this.previewDart2, - this.port, - this.dillFilePath, }) : assert(shellPath != null) { compilerController.stream.listen((CompilationRequest request) async { final bool isEmpty = compilationQueue.isEmpty; @@ -139,8 +133,6 @@ class _FlutterPlatform extends PlatformPlugin { final int explicitObservatoryPort; final InternetAddress host; final bool previewDart2; - final int port; - final String dillFilePath; final StreamController compilerController = new StreamController(); ResidentCompiler compiler = @@ -201,7 +193,7 @@ class _FlutterPlatform extends PlatformPlugin { controller.sink.done.whenComplete(() { controllerSinkClosed = true; }); // ignore: unawaited_futures // Prepare our WebSocket server to talk to the engine subproces. - final HttpServer server = await HttpServer.bind(host, port); + final HttpServer server = await HttpServer.bind(host, 0); finalizers.add(() async { printTrace('test $ourTestCount: shutting down test harness socket server'); await server.close(force: true); @@ -226,71 +218,56 @@ class _FlutterPlatform extends PlatformPlugin { ); // Prepare a temporary directory to store the Dart file that will talk to us. - // If a kernel file is given, then use that to launch the test. - File listenerFile; - if (dillFilePath == null) { - final Directory temporaryDirectory = fs.systemTempDirectory - .createTempSync('dart_test_listener'); - finalizers.add(() async { - printTrace('test $ourTestCount: deleting temporary directory'); - temporaryDirectory.deleteSync(recursive: true); - }); + final Directory temporaryDirectory = fs.systemTempDirectory.createTempSync('dart_test_listener'); + finalizers.add(() async { + printTrace('test $ourTestCount: deleting temporary directory'); + temporaryDirectory.deleteSync(recursive: true); + }); + + // Prepare the Dart file that will talk to us and start the test. + final File listenerFile = fs.file('${temporaryDirectory.path}/listener.dart'); + listenerFile.createSync(); + listenerFile.writeAsStringSync(_generateTestMain( + testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(), + encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl(server)), + )); - // Prepare the Dart file that will talk to us and start the test. - listenerFile = fs.file( - '${temporaryDirectory.path}/listener.dart'); - listenerFile.createSync(); - listenerFile.writeAsStringSync(_generateTestMain( - testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(), - encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl(server)), - )); - } // Start the engine subprocess. printTrace('test $ourTestCount: starting shell process${previewDart2? " in preview-dart-2 mode":""}'); - String mainDart = listenerFile?.path ?? testPath; + String mainDart = listenerFile.path; String bundlePath; if (previewDart2) { - if (dillFilePath == null) { - final Completer completer = new Completer(); - compilerController.add( - new CompilationRequest(listenerFile.path, completer)); - mainDart = await completer.future; + final Completer completer = new Completer(); + compilerController.add(new CompilationRequest(listenerFile.path, completer)); + mainDart = await completer.future; - if (mainDart == null) { - controller.sink.addError( - _getErrorMessage('Compilation failed', testPath, shellPath)); - return null; - } - - // bundlePath needs to point to a folder with `platform.dill` file. - final Directory tempBundleDirectory = fs.systemTempDirectory - .createTempSync('flutter_bundle_directory'); - finalizers.add(() async { - printTrace( - 'test $ourTestCount: deleting temporary bundle directory'); - tempBundleDirectory.deleteSync(recursive: true); - }); - - // copy 'vm_platform_strong.dill' into 'platform.dill' - final File vmPlatformStrongDill = fs.file( - artifacts.getArtifactPath(Artifact.platformKernelDill), - ); - final File platformDill = vmPlatformStrongDill.copySync( - tempBundleDirectory - .childFile('platform.dill') - .path, - ); - if (!platformDill.existsSync()) { - printError('unexpected error copying platform kernel file'); - } - - bundlePath = tempBundleDirectory.path; - } else { - mainDart = dillFilePath; - bundlePath = artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath); + if (mainDart == null) { + controller.sink.addError(_getErrorMessage('Compilation failed', testPath, shellPath)); + return null; } + + // bundlePath needs to point to a folder with `platform.dill` file. + final Directory tempBundleDirectory = fs.systemTempDirectory + .createTempSync('flutter_bundle_directory'); + finalizers.add(() async { + printTrace('test $ourTestCount: deleting temporary bundle directory'); + tempBundleDirectory.deleteSync(recursive: true); + }); + + // copy 'vm_platform_strong.dill' into 'platform.dill' + final File vmPlatformStrongDill = fs.file( + artifacts.getArtifactPath(Artifact.platformKernelDill), + ); + final File platformDill = vmPlatformStrongDill.copySync( + tempBundleDirectory.childFile('platform.dill').path, + ); + if (!platformDill.existsSync()) { + printError('unexpected error copying platform kernel file'); + } + + bundlePath = tempBundleDirectory.path; } final Process process = await _startProcess(