| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 import 'package:analyzer/src/command_line/arguments.dart' | 6 import 'package:analyzer/src/command_line/arguments.dart' |
| 7 show | 7 show |
| 8 defineAnalysisArguments, | 8 defineAnalysisArguments, |
| 9 filterUnknownArguments, | 9 filterUnknownArguments, |
| 10 ignoreUnrecognizedFlagsFlag; | 10 ignoreUnrecognizedFlagsFlag; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 moduleRoot = path.dirname(firstOutPath); | 179 moduleRoot = path.dirname(firstOutPath); |
| 180 modulePath = path.basenameWithoutExtension(firstOutPath); | 180 modulePath = path.basenameWithoutExtension(firstOutPath); |
| 181 } | 181 } |
| 182 | 182 |
| 183 var unit = new BuildUnit(modulePath, libraryRoot, argResults.rest, | 183 var unit = new BuildUnit(modulePath, libraryRoot, argResults.rest, |
| 184 (source) => _moduleForLibrary(moduleRoot, source, compilerOpts)); | 184 (source) => _moduleForLibrary(moduleRoot, source, compilerOpts)); |
| 185 | 185 |
| 186 var module = compiler.compile(unit, compilerOpts); | 186 var module = compiler.compile(unit, compilerOpts); |
| 187 module.errors.forEach(printFn); | 187 module.errors.forEach(printFn); |
| 188 | 188 |
| 189 if (!module.isValid) throw new CompileErrorException(); | 189 if (!module.isValid) { |
| 190 throw compilerOpts.unsafeForceCompile |
| 191 ? new ForceCompileErrorException() |
| 192 : new CompileErrorException(); |
| 193 } |
| 190 | 194 |
| 191 // Write JS file, as well as source map and summary (if requested). | 195 // Write JS file, as well as source map and summary (if requested). |
| 192 for (var i = 0; i < outPaths.length; i++) { | 196 for (var i = 0; i < outPaths.length; i++) { |
| 193 module.writeCodeSync(moduleFormats[i], outPaths[i], | 197 module.writeCodeSync(moduleFormats[i], outPaths[i], |
| 194 singleOutFile: singleOutFile); | 198 singleOutFile: singleOutFile); |
| 195 } | 199 } |
| 196 if (module.summaryBytes != null) { | 200 if (module.summaryBytes != null) { |
| 197 var summaryPaths = compilerOpts.summaryOutPath != null | 201 var summaryPaths = compilerOpts.summaryOutPath != null |
| 198 ? [compilerOpts.summaryOutPath] | 202 ? [compilerOpts.summaryOutPath] |
| 199 : outPaths.map((p) => | 203 : outPaths.map((p) => |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 259 } |
| 256 | 260 |
| 257 void _usageException(String message) { | 261 void _usageException(String message) { |
| 258 throw new UsageException(message, _usageMessage); | 262 throw new UsageException(message, _usageMessage); |
| 259 } | 263 } |
| 260 | 264 |
| 261 /// Thrown when the input source code has errors. | 265 /// Thrown when the input source code has errors. |
| 262 class CompileErrorException implements Exception { | 266 class CompileErrorException implements Exception { |
| 263 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; | 267 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; |
| 264 } | 268 } |
| 269 |
| 270 /// Thrown when force compilation failed (probably due to static errors). |
| 271 class ForceCompileErrorException extends CompileErrorException { |
| 272 toString() => |
| 273 '\nForce-compilation not successful. Please check static errors.'; |
| 274 } |
| OLD | NEW |