build_apk.dart 1.51 KB
Newer Older
1 2 3 4 5 6
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

7
import '../android/apk.dart';
8
import 'build.dart';
9

10
class BuildApkCommand extends BuildSubCommand {
11
  BuildApkCommand({bool verboseHelp: false}) {
12
    usesTargetOption();
13
    addBuildModeFlags();
14
    usesFlavorOption();
15
    usesPubOption();
16 17
    usesBuildNumberOption();
    usesBuildNameOption();
18 19

    argParser
20 21 22 23 24
      ..addFlag('preview-dart-2',
        defaultsTo: true,
        hide: !verboseHelp,
        help: 'Preview Dart 2.0 functionality.',
      )
25
      ..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp)
26 27 28 29
      ..addFlag('prefer-shared-library',
        negatable: false,
        help: 'Whether to prefer compiling to a *.so file (android only).',
      )
30 31 32
      ..addOption('target-platform',
        defaultsTo: 'android-arm',
        allowed: <String>['android-arm', 'android-arm64']);
33 34
  }

35 36 37 38
  @override
  final String name = 'apk';

  @override
39
  final String description = 'Build an Android APK file from your app.\n\n'
40 41
    'This command can build debug and release versions of your application. \'debug\' builds support\n'
    'debugging and a quick development cycle. \'release\' builds don\'t support debugging and are\n'
42
    'suitable for deploying to app stores.';
43

44
  @override
45
  Future<Null> runCommand() async {
46
    await super.runCommand();
47
    await buildApk(buildInfo: getBuildInfo(), target: targetFile);
48
  }
49
}