diff --git a/pkg/dev_compiler/bin/dartdevc.dart b/pkg/dev_compiler/bin/dartdevc.dart index 61e306aad18..df365eb467a 100755 --- a/pkg/dev_compiler/bin/dartdevc.dart +++ b/pkg/dev_compiler/bin/dartdevc.dart @@ -25,7 +25,7 @@ void _showUsageAndExit() { exit(1); } -main(List args) async { +main(List args) { var options; try { @@ -46,7 +46,6 @@ main(List args) async { if (options.serverMode) { new DevServer(options).start(); } else { - var success = compile(options); - exit(success ? 0 : 1); + exit(compile(options) ? 0 : 1); } } diff --git a/pkg/dev_compiler/lib/src/compiler.dart b/pkg/dev_compiler/lib/src/compiler.dart index 819451840f3..eb84ce9451c 100644 --- a/pkg/dev_compiler/lib/src/compiler.dart +++ b/pkg/dev_compiler/lib/src/compiler.dart @@ -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 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