build.dart 2.9 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 28 29 30 31
    _addSubcommand(BuildAarCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildApkCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildAppBundleCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildIOSCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildIOSFrameworkCommand(
32
      buildSystem: globals.buildSystem,
33
      verboseHelp: verboseHelp,
34
    ));
35 36 37 38 39
    _addSubcommand(BuildIOSArchiveCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildWebCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildMacosCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildLinuxCommand(
40 41 42
      operatingSystemUtils: globals.os,
      verboseHelp: verboseHelp
    ));
43 44 45 46 47 48 49 50 51
    _addSubcommand(BuildWindowsCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildWindowsUwpCommand(verboseHelp: verboseHelp));
    _addSubcommand(BuildFuchsiaCommand(verboseHelp: verboseHelp));
  }

  void _addSubcommand(BuildSubCommand command) {
    if (command.supported) {
      addSubcommand(command);
    }
52 53
  }

54
  @override
55
  final String name = 'build';
56 57

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

60
  @override
61
  Future<FlutterCommandResult> runCommand() async => null;
62
}
63

64
abstract class BuildSubCommand extends FlutterCommand {
65 66
  BuildSubCommand() {
    requiresPubspecYaml();
67
  }
68 69 70

  @override
  bool get reportNullSafety => true;
71

72 73
  bool get supported => true;

74 75 76 77 78 79 80 81 82 83 84
  /// 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(
85
        'Building without sound null safety',
86 87 88 89 90 91 92 93
        emphasis: true,
      );
      globals.printStatus(
        'For more information see https://dart.dev/null-safety/unsound-null-safety',
      );
    }
    globals.printStatus('');
  }
94
}