forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler.dart
More file actions
62 lines (51 loc) · 1.5 KB
/
compiler.dart
File metadata and controls
62 lines (51 loc) · 1.5 KB
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
61
62
// Copyright 2013 The Flutter 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 'dart:io';
import 'package:args/args.dart';
import 'package:crypto/crypto.dart';
import 'package:vm/kernel_front_end.dart'
show createCompilerArgParser, runCompiler, successExitCode;
final ArgParser _argParser = createCompilerArgParser()
..addFlag('train',
help: 'Run through sample command line to produce snapshot',
negatable: false);
String _usage = '''
Usage: compiler [options] input.dart
Options:
${_argParser.usage}
''';
Future<void> main(List<String> args) async {
ArgResults options;
try {
options = _argParser.parse(args);
if (options['train']) {
final Directory temp =
Directory.systemTemp.createTempSync('train_kernel_compiler');
try {
options = _argParser.parse(<String>[
'--manifest=flutter',
'--data-dir=${temp.absolute}',
]);
await runCompiler(options, _usage);
return;
} finally {
temp.deleteSync(recursive: true);
}
}
if (!options.rest.isNotEmpty) {
throw Exception('Must specify input.dart');
}
} on Exception catch (error) {
print('ERROR: $error\n');
print(_usage);
exitCode = 1;
return;
}
final compilerExitCode = await runCompiler(options, _usage);
if (compilerExitCode != successExitCode) {
exitCode = compilerExitCode;
return;
}
}