Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 import 'dart:async'; | 4 import 'dart:async'; |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:args/args.dart'; | 7 import 'package:args/args.dart'; |
| 8 import 'package:bazel_worker/bazel_worker.dart'; | 8 import 'package:bazel_worker/bazel_worker.dart'; |
| 9 import 'package:front_end/front_end.dart' hide FileSystemException; | 9 import 'package:front_end/front_end.dart' hide FileSystemException; |
| 10 import 'package:front_end/src/fasta/command_line_reporting.dart'; | 10 import 'package:front_end/src/fasta/command_line_reporting.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 } | 25 } |
| 26 | 26 |
| 27 /// A bazel worker loop that can compute summaries. | 27 /// A bazel worker loop that can compute summaries. |
| 28 class SummaryWorker extends AsyncWorkerLoop { | 28 class SummaryWorker extends AsyncWorkerLoop { |
| 29 Future<WorkResponse> performRequest(WorkRequest request) async { | 29 Future<WorkResponse> performRequest(WorkRequest request) async { |
| 30 var outputBuffer = new StringBuffer(); | 30 var outputBuffer = new StringBuffer(); |
| 31 var response = new WorkResponse()..exitCode = 0; | 31 var response = new WorkResponse()..exitCode = 0; |
| 32 try { | 32 try { |
| 33 await computeSummary(request.arguments, | 33 await computeSummary(request.arguments, |
| 34 isWorker: true, outputBuffer: outputBuffer); | 34 isWorker: true, outputBuffer: outputBuffer); |
| 35 } catch (_, s) { | 35 } catch (e, s) { |
| 36 outputBuffer.writeln(e); | |
| 36 outputBuffer.writeln(s); | 37 outputBuffer.writeln(s); |
| 37 response.exitCode = 15; | 38 response.exitCode = 15; |
| 38 } | 39 } |
| 39 response.output = outputBuffer.toString(); | 40 response.output = outputBuffer.toString(); |
| 40 return response; | 41 return response; |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 /// If the last arg starts with `@`, this reads the file it points to and treats | 45 /// If the last arg starts with `@`, this reads the file it points to and treats |
| 45 /// each line as an additional arg. | 46 /// each line as an additional arg. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 Future computeSummary(List<String> args, | 83 Future computeSummary(List<String> args, |
| 83 {bool isWorker: false, StringBuffer outputBuffer}) async { | 84 {bool isWorker: false, StringBuffer outputBuffer}) async { |
| 84 var parsedArgs = summaryArgsParser.parse(args); | 85 var parsedArgs = summaryArgsParser.parse(args); |
| 85 var options = new CompilerOptions() | 86 var options = new CompilerOptions() |
| 86 ..packagesFileUri = Uri.parse(parsedArgs['packages-file']) | 87 ..packagesFileUri = Uri.parse(parsedArgs['packages-file']) |
| 87 ..inputSummaries = parsedArgs['input-summary'].map(Uri.parse).toList() | 88 ..inputSummaries = parsedArgs['input-summary'].map(Uri.parse).toList() |
| 88 ..sdkSummary = Uri.parse(parsedArgs['dart-sdk-summary']) | 89 ..sdkSummary = Uri.parse(parsedArgs['dart-sdk-summary']) |
| 89 ..multiRoots = parsedArgs['multi-root'].map(Uri.parse).toList() | 90 ..multiRoots = parsedArgs['multi-root'].map(Uri.parse).toList() |
| 90 ..target = new NoneTarget(new TargetFlags()); | 91 ..target = new NoneTarget(new TargetFlags()); |
| 91 | 92 |
| 92 if (outputBuffer != null) { | 93 options.onError = (CompilationMessage error) { |
| 93 options.onError = (CompilationMessage error) { | 94 var severityString = severityName(error.severity, capitalized: true); |
| 94 var severityString = severityName(error.severity, capitalized: true); | 95 if (outputBuffer != null) { |
| 95 outputBuffer.writeln('$severityString: ${error.message}'); | 96 outputBuffer.writeln('$severityString: ${error.message}'); |
| 96 if (error.severity != Severity.nit) { | 97 } else { |
| 97 throw error; | 98 print('$severityString: ${error.message}'); |
| 98 } | 99 } |
| 99 }; | 100 if (error.severity != Severity.nit) { |
| 100 } else { | 101 throw error; |
|
Siggi Cherem (dart-lang)
2017/09/01 17:19:08
Instead of throwing here, consider setting a boole
| |
| 101 options.throwOnWarningsForDebugging = true; | 102 } |
| 102 } | 103 }; |
| 103 | 104 |
| 104 var sources = parsedArgs['source'].map(Uri.parse).toList(); | 105 var sources = parsedArgs['source'].map(Uri.parse).toList(); |
| 105 var program = await summaryFor(sources, options); | 106 var program = await summaryFor(sources, options); |
| 106 | 107 |
| 107 var outputFile = new File(parsedArgs['output']); | 108 var outputFile = new File(parsedArgs['output']); |
| 108 outputFile.createSync(recursive: true); | 109 outputFile.createSync(recursive: true); |
| 109 outputFile.writeAsBytesSync(program); | 110 outputFile.writeAsBytesSync(program); |
| 110 } | 111 } |
| OLD | NEW |