Adam Barth 4aae718f85 Download sky_engine and sky_services from cloud storage
Downloading these packages from cloud storage simplifies our deployment
story because we can upload to cloud storage automatically from the
buildbot.

This patch also switches the responsibility for downloading the engine
artifacts to update_engine.sh. Centralizing this responsibility ensures
that the packages and the binaries are always in sync.
2016-02-20 13:25:01 -08:00

70 lines
2.0 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:args/command_runner.dart';
import '../application_package.dart';
import '../build_configuration.dart';
import '../device.dart';
import '../globals.dart';
import '../toolchain.dart';
import 'flutter_command_runner.dart';
typedef bool Validator();
abstract class FlutterCommand extends Command {
FlutterCommandRunner get runner => super.runner;
/// Whether this command needs to be run from the root of a project.
bool get requiresProjectRoot => true;
List<BuildConfiguration> get buildConfigurations => runner.buildConfigurations;
Future downloadApplicationPackages() async {
if (applicationPackages == null)
applicationPackages = await ApplicationPackageStore.forConfigs(buildConfigurations);
}
Future downloadToolchain() async {
if (toolchain == null)
toolchain = await Toolchain.forConfigs(buildConfigurations);
}
void connectToDevices() {
if (devices == null)
devices = new DeviceStore.forConfigs(buildConfigurations);
}
Future downloadApplicationPackagesAndConnectToDevices() async {
await downloadApplicationPackages();
connectToDevices();
}
Future<int> run() async {
if (requiresProjectRoot && !projectRootValidator())
return 1;
return await runInProject();
}
// This is a field so that you can modify the value for testing.
Validator projectRootValidator = () {
if (!FileSystemEntity.isFileSync('pubspec.yaml')) {
printError('Error: No pubspec.yaml file found.\n'
'This command should be run from the root of your Flutter project.\n'
'Do not run this command from the root of your git clone of Flutter.');
return false;
}
return true;
};
Future<int> runInProject();
ApplicationPackageStore applicationPackages;
Toolchain toolchain;
DeviceStore devices;
}