From 7e8b111bccd17b3c6692ec968b990a2c15b2d5bb Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 9 Nov 2015 13:31:49 -0800 Subject: [PATCH] Search all the build configurations for sky_snapshot Previously, we assumed the first build configuration would have one. Now we keep looking until we find one. Also, re-ordered the configurations so that you'll get the Android one if you have both, which is probably what you would expect. Fixes #100 --- .../src/commands/flutter_command_runner.dart | 24 +++++++++---------- packages/flutter_tools/lib/src/toolchain.dart | 18 ++++++++++---- 2 files changed, 25 insertions(+), 17 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 ee1760836df..ecd69a8748e 100644 --- a/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/commands/flutter_command_runner.dart @@ -195,19 +195,19 @@ class FlutterCommandRunner extends CommandRunner { configs.add(new BuildConfiguration.local( type: BuildType.debug, hostPlatform: hostPlatform, - targetPlatform: hostPlatformAsTarget, + targetPlatform: TargetPlatform.android, enginePath: enginePath, - buildPath: globalResults['host-debug-build-path'], - testable: true + buildPath: globalResults['android-debug-build-path'], + deviceId: globalResults['android-device-id'] )); configs.add(new BuildConfiguration.local( type: BuildType.debug, hostPlatform: hostPlatform, - targetPlatform: TargetPlatform.android, + targetPlatform: hostPlatformAsTarget, enginePath: enginePath, - buildPath: globalResults['android-debug-build-path'], - deviceId: globalResults['android-device-id'] + buildPath: globalResults['host-debug-build-path'], + testable: true )); if (Platform.isMacOS) { @@ -233,19 +233,19 @@ class FlutterCommandRunner extends CommandRunner { configs.add(new BuildConfiguration.local( type: BuildType.release, hostPlatform: hostPlatform, - targetPlatform: hostPlatformAsTarget, + targetPlatform: TargetPlatform.android, enginePath: enginePath, - buildPath: globalResults['host-release-build-path'], - testable: true + buildPath: globalResults['android-release-build-path'], + deviceId: globalResults['android-device-id'] )); configs.add(new BuildConfiguration.local( type: BuildType.release, hostPlatform: hostPlatform, - targetPlatform: TargetPlatform.android, + targetPlatform: hostPlatformAsTarget, enginePath: enginePath, - buildPath: globalResults['android-release-build-path'], - deviceId: globalResults['android-device-id'] + buildPath: globalResults['host-release-build-path'], + testable: true )); if (Platform.isMacOS) { diff --git a/packages/flutter_tools/lib/src/toolchain.dart b/packages/flutter_tools/lib/src/toolchain.dart index 34301ec9ae3..e88ac6b82d6 100644 --- a/packages/flutter_tools/lib/src/toolchain.dart +++ b/packages/flutter_tools/lib/src/toolchain.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'package:path/path.dart' as path; @@ -29,8 +30,12 @@ class Compiler { } Future _getCompilerPath(BuildConfiguration config) async { - if (config.type != BuildType.prebuilt) - return path.join(config.buildDir, 'clang_x64', 'sky_snapshot'); + if (config.type != BuildType.prebuilt) { + String compilerPath = path.join(config.buildDir, 'clang_x64', 'sky_snapshot'); + if (FileSystemEntity.isFileSync(compilerPath)) + return compilerPath; + return null; + } Artifact artifact = ArtifactStore.getArtifact( type: ArtifactType.snapshot, hostPlatform: config.hostPlatform); return await ArtifactStore.getPath(artifact); @@ -42,8 +47,11 @@ class Toolchain { final Compiler compiler; static Future forConfigs(List configs) async { - // TODO(abarth): Shouldn't we consider all the configs? - String compilerPath = await _getCompilerPath(configs.first); - return new Toolchain(compiler: new Compiler(compilerPath)); + for (BuildConfiguration config in configs) { + String compilerPath = await _getCompilerPath(config); + if (compilerPath != null) + return new Toolchain(compiler: new Compiler(compilerPath)); + } + return null; } }