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:
Devon Carew 2015-10-13 10:31:08 -07:00
parent 7d641d0743
commit 64af703b26
2 changed files with 17 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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