build_flx.dart 2.24 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 '../build_info.dart';
8
import '../flx.dart';
9
import 'build.dart';
10

11
class BuildFlxCommand extends BuildSubCommand {
12
  BuildFlxCommand({bool verboseHelp: false}) {
13 14 15 16
    usesTargetOption();
    argParser.addFlag('precompiled', negatable: false);
    // This option is still referenced by the iOS build scripts. We should
    // remove it once we've updated those build scripts.
17
    argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp);
18 19 20 21 22
    argParser.addOption('manifest', defaultsTo: defaultManifestPath);
    argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
    argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
    argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
    argParser.addOption('depfile', defaultsTo: defaultDepfilePath);
23
    argParser.addFlag('preview-dart-2', negatable: false);
24
    argParser.addOption('working-dir', defaultsTo: getAssetBuildDirectory());
25
    argParser.addFlag('report-licensed-packages', help: 'Whether to report the names of all the packages that are included in the application\'s LICENSE file.', defaultsTo: false);
26 27 28 29 30 31 32 33 34 35 36 37 38 39
    usesPubOption();
  }

  @override
  final String name = 'flx';

  @override
  final String description = 'Build a Flutter FLX file from your app.';

  @override
  final String usageFooter = 'FLX files are archives of your application code and resources; '
    'they are used by some Flutter Android and iOS runtimes.';

  @override
40
  Future<Null> runCommand() async {
41
    await super.runCommand();
42
    final String outputPath = argResults['output-file'];
43

44
    await build(
45
      mainPath: targetFile,
46 47 48 49 50 51
      manifestPath: argResults['manifest'],
      outputPath: outputPath,
      snapshotPath: argResults['snapshot'],
      depfilePath: argResults['depfile'],
      privateKeyPath: argResults['private-key'],
      workingDirPath: argResults['working-dir'],
52
      previewDart2: argResults['preview-dart-2'],
53
      precompiledSnapshot: argResults['precompiled'],
54
      reportLicensedPackages: argResults['report-licensed-packages']
55
    );
56 57
  }
}