blob: 884d26f864a4d5e8ca7f837f651c7405732b4ecb [file] [log] [blame]
Jonah Williams86c938b2019-04-17 12:16:55 -07001// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'dart:async';
6
7import '../base/common.dart';
Jonah Williams86c938b2019-04-17 12:16:55 -07008import '../base/platform.dart';
Jonah Williams86c938b2019-04-17 12:16:55 -07009import '../build_info.dart';
10import '../cache.dart';
Jonah Williams86c938b2019-04-17 12:16:55 -070011import '../project.dart';
12import '../runner/flutter_command.dart' show FlutterCommandResult;
Jonah Williamsac36e442019-04-18 18:05:04 -070013import '../windows/build_windows.dart';
Jonah Williams86c938b2019-04-17 12:16:55 -070014import 'build.dart';
15
16/// A command to build a windows desktop target through a build shell script.
17class BuildWindowsCommand extends BuildSubCommand {
18 BuildWindowsCommand() {
stuartmorgand6bd1c02019-07-01 14:49:34 -070019 usesTargetOption();
Jonah Williams86c938b2019-04-17 12:16:55 -070020 argParser.addFlag('debug',
21 negatable: false,
22 help: 'Build a debug version of your app.',
23 );
24 argParser.addFlag('profile',
25 negatable: false,
26 help: 'Build a version of your app specialized for performance profiling.'
27 );
28 argParser.addFlag('release',
29 negatable: false,
30 help: 'Build a version of your app specialized for performance profiling.',
31 );
32 }
33
34 @override
35 final String name = 'windows';
36
37 @override
Jonah Williams8eae2df2019-07-21 21:47:43 -070038 bool isExperimental = true;
39
40 @override
Jonah Williams86c938b2019-04-17 12:16:55 -070041 bool hidden = true;
42
43 @override
44 Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
45 DevelopmentArtifact.windows,
46 DevelopmentArtifact.universal,
47 };
48
49 @override
Jonah Williams8eae2df2019-07-21 21:47:43 -070050 String get description => 'build the desktop Windows target (Experimental).';
Jonah Williams86c938b2019-04-17 12:16:55 -070051
52 @override
53 Future<FlutterCommandResult> runCommand() async {
54 Cache.releaseLockEarly();
Jonah Williams4ff46712019-04-29 08:21:32 -070055 final FlutterProject flutterProject = FlutterProject.current();
Jonah Williams86c938b2019-04-17 12:16:55 -070056 final BuildInfo buildInfo = getBuildInfo();
Jonah Williams86c938b2019-04-17 12:16:55 -070057 if (!platform.isWindows) {
58 throwToolExit('"build windows" only supported on Windows hosts.');
59 }
60 if (!flutterProject.windows.existsSync()) {
61 throwToolExit('No Windows desktop project configured.');
62 }
stuartmorgand6bd1c02019-07-01 14:49:34 -070063 await buildWindows(flutterProject.windows, buildInfo, target: targetFile);
Jonah Williams86c938b2019-04-17 12:16:55 -070064 return null;
65 }
66}