
* Remove the workaround that pinned args to v0.13.6 This reverts most of the changes in commit 6331b6c8b5d964ec0dbf2cd9bb84c60c650a0878 * throw exception if exit code is not an integer * rework command infrastructure to throw ToolExit when non-zero exitCode * convert commands to return Future<Null> * cleanup remaining commands to use throwToolExit for non-zero exit code * remove isUnusual exception message * add type annotations for updated args package
102 lines
2.5 KiB
Dart
102 lines
2.5 KiB
Dart
// Copyright 2016 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:meta/meta.dart';
|
|
|
|
import '../build_info.dart';
|
|
import '../globals.dart';
|
|
import '../runner/flutter_command.dart';
|
|
import '../base/common.dart';
|
|
import '../base/utils.dart';
|
|
import 'build_apk.dart';
|
|
import 'build_aot.dart';
|
|
import 'build_flx.dart';
|
|
import 'build_ios.dart';
|
|
|
|
class BuildCommand extends FlutterCommand {
|
|
BuildCommand({bool verboseHelp: false}) {
|
|
addSubcommand(new BuildApkCommand());
|
|
addSubcommand(new BuildAotCommand());
|
|
addSubcommand(new BuildCleanCommand());
|
|
addSubcommand(new BuildIOSCommand());
|
|
addSubcommand(new BuildFlxCommand(verboseHelp: verboseHelp));
|
|
}
|
|
|
|
@override
|
|
final String name = 'build';
|
|
|
|
@override
|
|
final String description = 'Flutter build commands.';
|
|
|
|
@override
|
|
Future<Null> verifyThenRunCommand() async {
|
|
commandValidator();
|
|
return super.verifyThenRunCommand();
|
|
}
|
|
|
|
@override
|
|
Future<Null> runCommand() async { }
|
|
}
|
|
|
|
abstract class BuildSubCommand extends FlutterCommand {
|
|
@override
|
|
@mustCallSuper
|
|
Future<Null> verifyThenRunCommand() async {
|
|
commandValidator();
|
|
return super.verifyThenRunCommand();
|
|
}
|
|
|
|
@override
|
|
@mustCallSuper
|
|
Future<Null> runCommand() async {
|
|
if (isRunningOnBot) {
|
|
File dotPackages = new File('.packages');
|
|
printStatus('Contents of .packages:');
|
|
if (dotPackages.existsSync())
|
|
printStatus(dotPackages.readAsStringSync());
|
|
else
|
|
printError('File not found: ${dotPackages.absolute.path}');
|
|
|
|
File pubspecLock = new File('pubspec.lock');
|
|
printStatus('Contents of pubspec.lock:');
|
|
if (pubspecLock.existsSync())
|
|
printStatus(pubspecLock.readAsStringSync());
|
|
else
|
|
printError('File not found: ${pubspecLock.absolute.path}');
|
|
}
|
|
}
|
|
}
|
|
|
|
class BuildCleanCommand extends FlutterCommand {
|
|
@override
|
|
final String name = 'clean';
|
|
|
|
@override
|
|
final String description = 'Delete the build/ directory.';
|
|
|
|
@override
|
|
Future<Null> verifyThenRunCommand() async {
|
|
commandValidator();
|
|
return super.verifyThenRunCommand();
|
|
}
|
|
|
|
@override
|
|
Future<Null> runCommand() async {
|
|
Directory buildDir = new Directory(getBuildDirectory());
|
|
printStatus("Deleting '${buildDir.path}${Platform.pathSeparator}'.");
|
|
|
|
if (!buildDir.existsSync())
|
|
return;
|
|
|
|
try {
|
|
buildDir.deleteSync(recursive: true);
|
|
} catch (error) {
|
|
throwToolExit(error.toString());
|
|
}
|
|
}
|
|
}
|