1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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';
import '../flx.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
import '../toolchain.dart';
class BuildCommand extends FlutterCommand {
final String name = 'build';
final String description = 'Package your Flutter app into an FLX.';
BuildCommand() {
argParser.addFlag('precompiled', negatable: false);
argParser.addOption('asset-base', defaultsTo: defaultMaterialAssetBasePath);
argParser.addOption('compiler');
argParser.addOption('target',
abbr: 't',
defaultsTo: defaultMainPath,
help: 'Target app path / main entry-point file.'
);
// TODO(devoncarew): Remove this once the xcode project is switched over.
argParser.addOption('main', hide: true);
argParser.addOption('manifest', defaultsTo: defaultManifestPath);
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
}
Future<int> runInProject() async {
String compilerPath = argResults['compiler'];
if (compilerPath == null)
await downloadToolchain();
else
toolchain = new Toolchain(compiler: new Compiler(compilerPath));
String outputPath = argResults['output-file'];
return await build(
toolchain,
materialAssetBasePath: argResults['asset-base'],
mainPath: argResults.wasParsed('main') ? argResults['main'] : argResults['target'],
manifestPath: argResults['manifest'],
outputPath: outputPath,
snapshotPath: argResults['snapshot'],
privateKeyPath: argResults['private-key'],
precompiledSnapshot: argResults['precompiled']
).then((int result) {
if (result == 0)
printStatus('Built $outputPath.');
else
printError('Error building $outputPath: $result.');
return result;
});
}
}