mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:01:20 +00:00
Implement --dump-info for batch mode.
BUG= R=jmesserly@google.com, vsm@google.com Review URL: https://codereview.chromium.org/1402713002 .
This commit is contained in:
parent
7d641d0743
commit
64af703b26
|
@ -25,7 +25,7 @@ void _showUsageAndExit() {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
main(List<String> args) async {
|
||||
main(List<String> args) {
|
||||
var options;
|
||||
|
||||
try {
|
||||
|
@ -46,7 +46,6 @@ main(List<String> args) async {
|
|||
if (options.serverMode) {
|
||||
new DevServer(options).start();
|
||||
} else {
|
||||
var success = compile(options);
|
||||
exit(success ? 0 : 1);
|
||||
exit(compile(options) ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ library dev_compiler.src.compiler;
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
import 'dart:convert' show JSON;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -60,12 +61,25 @@ CompilerOptions validateOptions(List<String> args, {bool forceOutDir: false}) {
|
|||
return options;
|
||||
}
|
||||
|
||||
/// Compile with the given options and return success or failure.
|
||||
bool compile(CompilerOptions options) {
|
||||
assert(!options.serverMode);
|
||||
|
||||
var context = createAnalysisContextWithSources(
|
||||
options.strongOptions, options.sourceOptions);
|
||||
var reporter = createErrorReporter(context, options);
|
||||
return new BatchCompiler(context, options, reporter: reporter).run();
|
||||
bool status = new BatchCompiler(context, options, reporter: reporter).run();
|
||||
|
||||
if (options.dumpInfo && reporter is SummaryReporter) {
|
||||
var result = (reporter as SummaryReporter).result;
|
||||
print(summaryToString(result));
|
||||
if (options.dumpInfoFile != null) {
|
||||
var file = new File(options.dumpInfoFile);
|
||||
file.writeAsStringSync(JSON.encode(result.toJsonMap()));
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// Callback on each individual compiled library
|
||||
|
|
Loading…
Reference in a new issue