Devon Carew | f8374cd | 2016-03-16 14:37:46 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
Adam Barth | cf41a63 | 2015-09-17 13:37:53 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Adam Barth | cf41a63 | 2015-09-17 13:37:53 -0700 | [diff] [blame] | 5 | import 'dart:async'; |
| 6 | |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 7 | import 'package:meta/meta.dart'; |
| 8 | |
Todd Volkert | 8bb2703 | 2017-01-06 16:51:44 -0800 | [diff] [blame] | 9 | import '../base/file_system.dart'; |
Todd Volkert | 016b5ab | 2017-01-09 08:37:00 -0800 | [diff] [blame] | 10 | import '../base/utils.dart'; |
Devon Carew | d5a6fce | 2016-02-17 00:59:56 -0800 | [diff] [blame] | 11 | import '../globals.dart'; |
Adam Barth | 9662d49 | 2015-11-28 21:07:16 -0800 | [diff] [blame] | 12 | import '../runner/flutter_command.dart'; |
Jason Simmons | 01a27ca | 2016-04-29 13:44:01 -0700 | [diff] [blame] | 13 | import 'build_aot.dart'; |
Alexandre Ardhuin | 8c043d0 | 2017-02-23 22:37:26 +0100 | [diff] [blame] | 14 | import 'build_apk.dart'; |
Devon Carew | f8374cd | 2016-03-16 14:37:46 -0700 | [diff] [blame] | 15 | import 'build_flx.dart'; |
Devon Carew | 39efe4a | 2016-04-06 14:29:54 -0700 | [diff] [blame] | 16 | import 'build_ios.dart'; |
Adam Barth | cf41a63 | 2015-09-17 13:37:53 -0700 | [diff] [blame] | 17 | |
Adam Barth | 12f7581 | 2015-10-13 10:00:06 -0700 | [diff] [blame] | 18 | class BuildCommand extends FlutterCommand { |
Dan Rubel | 3f68e18 | 2016-09-22 05:58:45 -0400 | [diff] [blame] | 19 | BuildCommand({bool verboseHelp: false}) { |
Alexander Aprelev | 42ca92c | 2017-11-30 10:36:46 -0800 | [diff] [blame] | 20 | addSubcommand(new BuildApkCommand(verboseHelp: verboseHelp)); |
| 21 | addSubcommand(new BuildAotCommand(verboseHelp: verboseHelp)); |
| 22 | addSubcommand(new BuildIOSCommand(verboseHelp: verboseHelp)); |
Dan Rubel | 3f68e18 | 2016-09-22 05:58:45 -0400 | [diff] [blame] | 23 | addSubcommand(new BuildFlxCommand(verboseHelp: verboseHelp)); |
Devon Carew | f8374cd | 2016-03-16 14:37:46 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Hixie | 797e27e | 2016-03-14 13:31:43 -0700 | [diff] [blame] | 26 | @override |
Adam Barth | 12f7581 | 2015-10-13 10:00:06 -0700 | [diff] [blame] | 27 | final String name = 'build'; |
Hixie | 797e27e | 2016-03-14 13:31:43 -0700 | [diff] [blame] | 28 | |
| 29 | @override |
Devon Carew | f8374cd | 2016-03-16 14:37:46 -0700 | [diff] [blame] | 30 | final String description = 'Flutter build commands.'; |
Adam Barth | cf41a63 | 2015-09-17 13:37:53 -0700 | [diff] [blame] | 31 | |
Jason Simmons | 68e7114 | 2016-03-11 14:09:29 -0800 | [diff] [blame] | 32 | @override |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 33 | Future<Null> runCommand() async { } |
Devon Carew | f8374cd | 2016-03-16 14:37:46 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 36 | abstract class BuildSubCommand extends FlutterCommand { |
Todd Volkert | a08b5e0 | 2017-09-25 18:56:37 -0700 | [diff] [blame] | 37 | BuildSubCommand() { |
| 38 | requiresPubspecYaml(); |
Dan Rubel | 1821238 | 2016-09-16 09:13:35 -0400 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | @override |
| 42 | @mustCallSuper |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 43 | Future<Null> runCommand() async { |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 44 | if (isRunningOnBot) { |
Chris Bracken | 7a09316 | 2017-03-03 17:50:46 -0800 | [diff] [blame] | 45 | final File dotPackages = fs.file('.packages'); |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 46 | printStatus('Contents of .packages:'); |
| 47 | if (dotPackages.existsSync()) |
| 48 | printStatus(dotPackages.readAsStringSync()); |
| 49 | else |
| 50 | printError('File not found: ${dotPackages.absolute.path}'); |
| 51 | |
Chris Bracken | 7a09316 | 2017-03-03 17:50:46 -0800 | [diff] [blame] | 52 | final File pubspecLock = fs.file('pubspec.lock'); |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 53 | printStatus('Contents of pubspec.lock:'); |
| 54 | if (pubspecLock.existsSync()) |
| 55 | printStatus(pubspecLock.readAsStringSync()); |
| 56 | else |
| 57 | printError('File not found: ${pubspecLock.absolute.path}'); |
| 58 | } |
Yegor | 2f77a07 | 2016-07-21 13:27:49 -0700 | [diff] [blame] | 59 | } |
| 60 | } |