simplify toolchain setup
This commit is contained in:
parent
73bee3ae29
commit
653566dd23
@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
@ -118,7 +117,7 @@ class ApplicationPackageStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<ApplicationPackageStore> forConfigs(List<BuildConfiguration> configs) async {
|
static ApplicationPackageStore forConfigs(List<BuildConfiguration> configs) {
|
||||||
AndroidApk android;
|
AndroidApk android;
|
||||||
IOSApp iOS;
|
IOSApp iOS;
|
||||||
|
|
||||||
|
@ -185,8 +185,6 @@ class BuildApkCommand extends FlutterCommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
await downloadToolchain();
|
|
||||||
|
|
||||||
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
|
// TODO(devoncarew): This command should take an arg for the output type (arm / x64).
|
||||||
|
|
||||||
return await buildAndroid(
|
return await buildAndroid(
|
||||||
|
@ -40,10 +40,7 @@ class BuildFlxCommand extends FlutterCommand {
|
|||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
String compilerPath = argResults['compiler'];
|
String compilerPath = argResults['compiler'];
|
||||||
|
if (compilerPath != null)
|
||||||
if (compilerPath == null)
|
|
||||||
await downloadToolchain();
|
|
||||||
else
|
|
||||||
toolchain = new Toolchain(compiler: new SnapshotCompiler(compilerPath));
|
toolchain = new Toolchain(compiler: new SnapshotCompiler(compilerPath));
|
||||||
|
|
||||||
String outputPath = argResults['output-file'];
|
String outputPath = argResults['output-file'];
|
||||||
|
@ -31,13 +31,6 @@ class BuildIOSCommand extends FlutterCommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printTrace('Ensuring toolchains are up to date.');
|
|
||||||
|
|
||||||
await Future.wait([
|
|
||||||
downloadToolchain(),
|
|
||||||
downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
|
|
||||||
IOSApp app = applicationPackages.iOS;
|
IOSApp app = applicationPackages.iOS;
|
||||||
|
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
|
@ -262,11 +262,6 @@ class AppDomain extends Domain {
|
|||||||
Directory.current = new Directory(projectDirectory);
|
Directory.current = new Directory(projectDirectory);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Future.wait([
|
|
||||||
command.downloadToolchain(),
|
|
||||||
command.downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
|
|
||||||
int result = await startApp(
|
int result = await startApp(
|
||||||
device,
|
device,
|
||||||
command.applicationPackages,
|
command.applicationPackages,
|
||||||
@ -304,11 +299,6 @@ class AppDomain extends Domain {
|
|||||||
Directory.current = new Directory(projectDirectory);
|
Directory.current = new Directory(projectDirectory);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Future.wait([
|
|
||||||
command.downloadToolchain(),
|
|
||||||
command.downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
|
|
||||||
ApplicationPackage app = command.applicationPackages.getPackageForPlatform(device.platform);
|
ApplicationPackage app = command.applicationPackages.getPackageForPlatform(device.platform);
|
||||||
return device.stopApp(app);
|
return device.stopApp(app);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -80,8 +80,6 @@ class DriveCommand extends RunCommandBase {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
await toolchainDownloader(this);
|
|
||||||
|
|
||||||
String testFile = _getTestFile();
|
String testFile = _getTestFile();
|
||||||
if (testFile == null) {
|
if (testFile == null) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -311,18 +309,3 @@ Future<int> stopApp(DriveCommand command) async {
|
|||||||
bool stopped = await command.device.stopApp(package);
|
bool stopped = await command.device.stopApp(package);
|
||||||
return stopped ? 0 : 1;
|
return stopped ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Downloads Flutter toolchain.
|
|
||||||
typedef Future<Null> ToolchainDownloader(DriveCommand command);
|
|
||||||
ToolchainDownloader toolchainDownloader = downloadToolchain;
|
|
||||||
void restoreToolchainDownloader() {
|
|
||||||
toolchainDownloader = downloadToolchain;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Null> downloadToolchain(DriveCommand command) async {
|
|
||||||
printTrace('Downloading toolchain.');
|
|
||||||
await Future.wait([
|
|
||||||
command.downloadToolchain(),
|
|
||||||
command.downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
}
|
|
||||||
|
@ -21,8 +21,6 @@ class InstallCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
await downloadApplicationPackages();
|
|
||||||
|
|
||||||
Device device = deviceForCommand;
|
Device device = deviceForCommand;
|
||||||
ApplicationPackage package = applicationPackages.getPackageForPlatform(device.platform);
|
ApplicationPackage package = applicationPackages.getPackageForPlatform(device.platform);
|
||||||
|
|
||||||
|
@ -32,9 +32,6 @@ class ListenCommand extends RunCommandBase {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
await downloadApplicationPackages();
|
|
||||||
await downloadToolchain();
|
|
||||||
|
|
||||||
Iterable<String> directories = () sync* {
|
Iterable<String> directories = () sync* {
|
||||||
yield* argResults.rest;
|
yield* argResults.rest;
|
||||||
yield '.';
|
yield '.';
|
||||||
|
@ -34,13 +34,6 @@ class RefreshCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
printTrace('Downloading toolchain.');
|
|
||||||
|
|
||||||
await Future.wait([
|
|
||||||
downloadToolchain(),
|
|
||||||
downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
|
|
||||||
Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools');
|
Directory tempDir = await Directory.systemTemp.createTemp('flutter_tools');
|
||||||
try {
|
try {
|
||||||
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
String snapshotPath = path.join(tempDir.path, 'snapshot_blob.bin');
|
||||||
|
@ -94,13 +94,6 @@ class RunCommand extends RunCommandBase {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
printTrace('Downloading toolchain.');
|
|
||||||
|
|
||||||
await Future.wait([
|
|
||||||
downloadToolchain(),
|
|
||||||
downloadApplicationPackages(),
|
|
||||||
], eagerError: true);
|
|
||||||
|
|
||||||
bool clearLogs = argResults['clear-logs'];
|
bool clearLogs = argResults['clear-logs'];
|
||||||
|
|
||||||
int debugPort;
|
int debugPort;
|
||||||
|
@ -162,8 +162,6 @@ class RunMojoCommand extends FlutterCommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
await downloadToolchain();
|
|
||||||
|
|
||||||
String targetApp = argResults['app'];
|
String targetApp = argResults['app'];
|
||||||
if (targetApp == null) {
|
if (targetApp == null) {
|
||||||
targetApp = _kDefaultBundlePath;
|
targetApp = _kDefaultBundlePath;
|
||||||
|
@ -21,7 +21,6 @@ class StopCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
await downloadApplicationPackages();
|
|
||||||
Device device = deviceForCommand;
|
Device device = deviceForCommand;
|
||||||
ApplicationPackage app = applicationPackages.getPackageForPlatform(device.platform);
|
ApplicationPackage app = applicationPackages.getPackageForPlatform(device.platform);
|
||||||
printStatus('Stopping apps on ${device.name}.');
|
printStatus('Stopping apps on ${device.name}.');
|
||||||
|
@ -38,8 +38,6 @@ class TraceCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> runInProject() async {
|
Future<int> runInProject() async {
|
||||||
await downloadApplicationPackages();
|
|
||||||
|
|
||||||
ApplicationPackage androidApp = applicationPackages.android;
|
ApplicationPackage androidApp = applicationPackages.android;
|
||||||
AndroidDevice device = deviceForCommand;
|
AndroidDevice device = deviceForCommand;
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import '../base/process.dart';
|
import '../base/process.dart';
|
||||||
@ -9,21 +11,22 @@ import '../base/process.dart';
|
|||||||
const String kCFBundleIdentifierKey = "CFBundleIdentifier";
|
const String kCFBundleIdentifierKey = "CFBundleIdentifier";
|
||||||
|
|
||||||
String getValueFromFile(String plistFilePath, String key) {
|
String getValueFromFile(String plistFilePath, String key) {
|
||||||
// TODO(chinmaygarde): For now, we only need to read from plist files on a
|
// TODO(chinmaygarde): For now, we only need to read from plist files on a mac
|
||||||
// mac host. If this changes, we will need our own Dart plist reader.
|
// host. If this changes, we will need our own Dart plist reader.
|
||||||
|
|
||||||
// Don't use PlistBuddy since that is not guaranteed to be installed.
|
// Don't use PlistBuddy since that is not guaranteed to be installed.
|
||||||
// 'defaults' requires the path to be absolute and without the 'plist'
|
// 'defaults' requires the path to be absolute and without the 'plist'
|
||||||
// extension.
|
// extension.
|
||||||
|
|
||||||
|
if (!FileSystemEntity.isFileSync(plistFilePath))
|
||||||
|
return null;
|
||||||
|
|
||||||
String normalizedPlistPath = path.withoutExtension(path.absolute(plistFilePath));
|
String normalizedPlistPath = path.withoutExtension(path.absolute(plistFilePath));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String value = runCheckedSync(<String>[
|
String value = runCheckedSync(<String>[
|
||||||
'/usr/bin/defaults',
|
'/usr/bin/defaults', 'read', normalizedPlistPath, key
|
||||||
'read',
|
]);
|
||||||
normalizedPlistPath,
|
|
||||||
key
|
|
||||||
]).trim();
|
|
||||||
return value.isEmpty ? null : value;
|
return value.isEmpty ? null : value;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -58,12 +58,12 @@ abstract class FlutterCommand extends Command {
|
|||||||
_usesPubOption = true;
|
_usesPubOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> downloadToolchain() async {
|
void _setupToolchain() {
|
||||||
toolchain ??= await Toolchain.forConfigs(buildConfigurations);
|
toolchain ??= Toolchain.forConfigs(buildConfigurations);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> downloadApplicationPackages() async {
|
void _setupApplicationPackages() {
|
||||||
applicationPackages ??= await ApplicationPackageStore.forConfigs(buildConfigurations);
|
applicationPackages ??= ApplicationPackageStore.forConfigs(buildConfigurations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -126,6 +126,9 @@ abstract class FlutterCommand extends Command {
|
|||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setupToolchain();
|
||||||
|
_setupApplicationPackages();
|
||||||
|
|
||||||
return await runInProject();
|
return await runInProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class Toolchain {
|
|||||||
|
|
||||||
final SnapshotCompiler compiler;
|
final SnapshotCompiler compiler;
|
||||||
|
|
||||||
static Future<Toolchain> forConfigs(List<BuildConfiguration> configs) async {
|
static Toolchain forConfigs(List<BuildConfiguration> configs) {
|
||||||
for (BuildConfiguration config in configs) {
|
for (BuildConfiguration config in configs) {
|
||||||
String compilerPath = _getCompilerPath(config);
|
String compilerPath = _getCompilerPath(config);
|
||||||
if (compilerPath != null)
|
if (compilerPath != null)
|
||||||
|
@ -35,7 +35,6 @@ void main() {
|
|||||||
command = new DriveCommand();
|
command = new DriveCommand();
|
||||||
applyMocksToCommand(command);
|
applyMocksToCommand(command);
|
||||||
useInMemoryFileSystem(cwd: '/some/app');
|
useInMemoryFileSystem(cwd: '/some/app');
|
||||||
toolchainDownloader = (_) async { };
|
|
||||||
targetDeviceFinder = () {
|
targetDeviceFinder = () {
|
||||||
throw 'Unexpected call to targetDeviceFinder';
|
throw 'Unexpected call to targetDeviceFinder';
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user