build.dart 2.74 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8 9
import 'package:meta/meta.dart';

import '../build_info.dart';
10 11 12
import '../commands/build_linux.dart';
import '../commands/build_macos.dart';
import '../commands/build_windows.dart';
13
import '../globals_null_migrated.dart' as globals;
14
import '../runner/flutter_command.dart';
15
import 'build_aar.dart';
16
import 'build_apk.dart';
17
import 'build_appbundle.dart';
18
import 'build_bundle.dart';
19
import 'build_fuchsia.dart';
20
import 'build_ios.dart';
xster's avatar
xster committed
21
import 'build_ios_framework.dart';
22
import 'build_web.dart';
23
import 'build_winuwp.dart';
24

25
class BuildCommand extends FlutterCommand {
26
  BuildCommand({ bool verboseHelp = false }) {
27
    addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
28
    addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
29
    addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
30
    addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
31
    addSubcommand(BuildIOSFrameworkCommand(
32
      buildSystem: globals.buildSystem,
33
      verboseHelp: verboseHelp,
34
    ));
35
    addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
36
    addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
37 38
    addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
    addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
39 40 41 42
    addSubcommand(BuildLinuxCommand(
      operatingSystemUtils: globals.os,
      verboseHelp: verboseHelp
    ));
43
    addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
44
    addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
45
    addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
46 47
  }

48
  @override
49
  final String name = 'build';
50 51

  @override
52
  final String description = 'Build an executable app or install bundle.';
53

54
  @override
55
  Future<FlutterCommandResult> runCommand() async => null;
56
}
57

58
abstract class BuildSubCommand extends FlutterCommand {
59 60
  BuildSubCommand() {
    requiresPubspecYaml();
61
  }
62 63 64

  @override
  bool get reportNullSafety => true;
65 66 67 68 69 70 71 72 73 74 75 76

  /// Display a message describing the current null safety runtime mode
  /// that was selected.
  ///
  /// This is similar to the run message in run_hot.dart
  @protected
  void displayNullSafetyMode(BuildInfo buildInfo) {
    globals.printStatus('');
    if (buildInfo.nullSafetyMode ==  NullSafetyMode.sound) {
      globals.printStatus('💪 Building with sound null safety 💪', emphasis: true);
    } else {
      globals.printStatus(
77
        'Building without sound null safety',
78 79 80 81 82 83 84 85
        emphasis: true,
      );
      globals.printStatus(
        'For more information see https://dart.dev/null-safety/unsound-null-safety',
      );
    }
    globals.printStatus('');
  }
86
}