From 4ff0e842e2dd2880e65f19d3893e475637e5df9d Mon Sep 17 00:00:00 2001 From: pq Date: Mon, 18 Apr 2016 09:03:31 -0700 Subject: [PATCH] Analyze CLI option to specify a custom Dart SDK. Handy for testing against specific local SDK builds. (Note that the option is hidden.) --- packages/flutter_tools/lib/src/base/process.dart | 7 ++++--- packages/flutter_tools/lib/src/commands/analyze.dart | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index e8465a0375..e4d43f2b80 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart @@ -92,9 +92,10 @@ String runSync(List cmd, { String workingDirectory }) { } /// Return the platform specific name for the given Dart SDK binary. So, `pub` -/// ==> `pub.bat`. -String sdkBinaryName(String name) { - return path.absolute(path.join(dartSdkPath, 'bin', Platform.isWindows ? '$name.bat' : name)); +/// ==> `pub.bat`. The default SDK location can be overridden with a specified +/// [sdkLocation]. +String sdkBinaryName(String name, {String sdkLocation}) { + return path.absolute(path.join(sdkLocation ?? dartSdkPath, 'bin', Platform.isWindows ? '$name.bat' : name)); } bool exitsHappy(List cli) { diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 04e37ad00c..4e8ad38608 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -100,6 +100,8 @@ class AnalyzeCommand extends FlutterCommand { argParser.addFlag('preamble', help: 'Display the number of files that will be analyzed.', defaultsTo: true); argParser.addFlag('congratulate', help: 'Show output even when there are no errors, warnings, hints, or lints.', defaultsTo: true); argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false); + argParser.addOption('dart-sdk', help: 'The path to the Dart SDK.', hide: true); + usesPubOption(); } @@ -293,7 +295,7 @@ class AnalyzeCommand extends FlutterCommand { File packagesFile = new File(path.join(host.path, '.packages'))..writeAsStringSync(packagesBody.toString()); List cmd = [ - sdkBinaryName('dartanalyzer'), + sdkBinaryName('dartanalyzer', sdkLocation: argResults['dart-sdk']), // do not set '--warnings', since that will include the entire Dart SDK '--ignore-unrecognized-flags', '--enable_type_checks',