From 0d3c2d93363af07d2ca59d117de2740fffdc8c21 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 20 Nov 2015 15:09:04 -0800 Subject: [PATCH] flutter build --engine-src-dir= produces poor error message This patch improves the error message. Fixes #468 --- .../src/commands/flutter_command_runner.dart | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart b/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart index 5dd87db7243..e351e487a9e 100644 --- a/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart @@ -178,6 +178,12 @@ class FlutterCommandRunner extends CommandRunner { return 0; } + String _tryEnginePath(String enginePath) { + if (FileSystemEntity.isDirectorySync(path.join(enginePath, 'out'))) + return enginePath; + return null; + } + String _findEnginePath(ArgResults globalResults) { String engineSourcePath = globalResults['engine-src-path'] ?? Platform.environment[kFlutterEngineEnvironmentVariableName]; bool isDebug = globalResults['debug']; @@ -194,14 +200,10 @@ class FlutterCommandRunner extends CommandRunner { engineSourcePath = null; } on FileSystemException { } } - if (engineSourcePath == null) { - String tryEnginePath(String enginePath) { - if (FileSystemEntity.isDirectorySync(path.join(enginePath, 'out'))) - return enginePath; - return null; - } - engineSourcePath = tryEnginePath(path.join(ArtifactStore.flutterRoot, '../engine/src')); - } + + if (engineSourcePath == null) + engineSourcePath = _tryEnginePath(path.join(ArtifactStore.flutterRoot, '../engine/src')); + if (engineSourcePath == null) { stderr.writeln('Unable to detect local Flutter engine build directory.\n' 'Either specify a dependency_override for the $kFlutterEnginePackageName package in your pubspec.yaml and\n' @@ -211,6 +213,13 @@ class FlutterCommandRunner extends CommandRunner { } } + if (engineSourcePath != null && _tryEnginePath(engineSourcePath) == null) { + stderr.writeln('Unable to detect a Flutter engine build directory in $engineSourcePath.\n' + 'Please ensure that $engineSourcePath is a Flutter engine \'src\' directory and that\n' + 'you have compiled the engine in that directory, which should produce an \'out\' directory'); + throw new ProcessExit(2); + } + return engineSourcePath; }