blob: 49f2195fff35b27753a2b5779038b133e6f14554 [file] [log] [blame]
Devon Carewf8374cd2016-03-16 14:37:46 -07001// Copyright 2016 The Chromium Authors. All rights reserved.
Adam Barthcf41a632015-09-17 13:37:53 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Adam Barthcf41a632015-09-17 13:37:53 -07005import 'dart:async';
6
Yegor2f77a072016-07-21 13:27:49 -07007import 'package:meta/meta.dart';
8
Todd Volkert8bb27032017-01-06 16:51:44 -08009import '../base/file_system.dart';
Todd Volkert016b5ab2017-01-09 08:37:00 -080010import '../base/utils.dart';
Devon Carewd5a6fce2016-02-17 00:59:56 -080011import '../globals.dart';
Adam Barth9662d492015-11-28 21:07:16 -080012import '../runner/flutter_command.dart';
Jason Simmons01a27ca2016-04-29 13:44:01 -070013import 'build_aot.dart';
Alexandre Ardhuin8c043d02017-02-23 22:37:26 +010014import 'build_apk.dart';
Devon Carewf8374cd2016-03-16 14:37:46 -070015import 'build_flx.dart';
Devon Carew39efe4a2016-04-06 14:29:54 -070016import 'build_ios.dart';
Adam Barthcf41a632015-09-17 13:37:53 -070017
Adam Barth12f75812015-10-13 10:00:06 -070018class BuildCommand extends FlutterCommand {
Dan Rubel3f68e182016-09-22 05:58:45 -040019 BuildCommand({bool verboseHelp: false}) {
Alexander Aprelev42ca92c2017-11-30 10:36:46 -080020 addSubcommand(new BuildApkCommand(verboseHelp: verboseHelp));
21 addSubcommand(new BuildAotCommand(verboseHelp: verboseHelp));
22 addSubcommand(new BuildIOSCommand(verboseHelp: verboseHelp));
Dan Rubel3f68e182016-09-22 05:58:45 -040023 addSubcommand(new BuildFlxCommand(verboseHelp: verboseHelp));
Devon Carewf8374cd2016-03-16 14:37:46 -070024 }
25
Hixie797e27e2016-03-14 13:31:43 -070026 @override
Adam Barth12f75812015-10-13 10:00:06 -070027 final String name = 'build';
Hixie797e27e2016-03-14 13:31:43 -070028
29 @override
Devon Carewf8374cd2016-03-16 14:37:46 -070030 final String description = 'Flutter build commands.';
Adam Barthcf41a632015-09-17 13:37:53 -070031
Jason Simmons68e71142016-03-11 14:09:29 -080032 @override
Dan Rubel34e466f2016-11-14 14:21:30 -050033 Future<Null> runCommand() async { }
Devon Carewf8374cd2016-03-16 14:37:46 -070034}
35
Yegor2f77a072016-07-21 13:27:49 -070036abstract class BuildSubCommand extends FlutterCommand {
Todd Volkerta08b5e02017-09-25 18:56:37 -070037 BuildSubCommand() {
38 requiresPubspecYaml();
Dan Rubel18212382016-09-16 09:13:35 -040039 }
40
41 @override
42 @mustCallSuper
Dan Rubel34e466f2016-11-14 14:21:30 -050043 Future<Null> runCommand() async {
Yegor2f77a072016-07-21 13:27:49 -070044 if (isRunningOnBot) {
Chris Bracken7a093162017-03-03 17:50:46 -080045 final File dotPackages = fs.file('.packages');
Yegor2f77a072016-07-21 13:27:49 -070046 printStatus('Contents of .packages:');
47 if (dotPackages.existsSync())
48 printStatus(dotPackages.readAsStringSync());
49 else
50 printError('File not found: ${dotPackages.absolute.path}');
51
Chris Bracken7a093162017-03-03 17:50:46 -080052 final File pubspecLock = fs.file('pubspec.lock');
Yegor2f77a072016-07-21 13:27:49 -070053 printStatus('Contents of pubspec.lock:');
54 if (pubspecLock.existsSync())
55 printStatus(pubspecLock.readAsStringSync());
56 else
57 printError('File not found: ${pubspecLock.absolute.path}');
58 }
Yegor2f77a072016-07-21 13:27:49 -070059 }
60}