| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.cmdline; | 5 library dart2js.cmdline; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 import 'dart:convert' show UTF8, LineSplitter; | 8 import 'dart:convert' show UTF8, LineSplitter; |
| 9 import 'dart:io' show exit, File, FileMode, Platform, stdin, stderr; | 9 import 'dart:io' show exit, File, FileMode, Platform, stdin, stderr; |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 FormattingDiagnosticHandler diagnosticHandler; | 101 FormattingDiagnosticHandler diagnosticHandler; |
| 102 | 102 |
| 103 Future<api.CompilationResult> compile(List<String> argv) { | 103 Future<api.CompilationResult> compile(List<String> argv) { |
| 104 stackTraceFilePrefix = '$currentDirectory'; | 104 stackTraceFilePrefix = '$currentDirectory'; |
| 105 Uri libraryRoot = currentDirectory; | 105 Uri libraryRoot = currentDirectory; |
| 106 Uri out = currentDirectory.resolve('out.js'); | 106 Uri out = currentDirectory.resolve('out.js'); |
| 107 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); | 107 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
| 108 Uri resolutionInput; |
| 108 Uri packageConfig = null; | 109 Uri packageConfig = null; |
| 109 Uri packageRoot = null; | 110 Uri packageRoot = null; |
| 110 List<String> options = new List<String>(); | 111 List<String> options = new List<String>(); |
| 111 bool explicitOut = false; | 112 List<String> explicitOutputArguments = <String>[]; |
| 112 bool wantHelp = false; | 113 bool wantHelp = false; |
| 113 bool wantVersion = false; | 114 bool wantVersion = false; |
| 114 String outputLanguage = 'JavaScript'; | 115 String outputLanguage = 'JavaScript'; |
| 115 bool stripArgumentSet = false; | 116 bool stripArgumentSet = false; |
| 116 bool analyzeOnly = false; | 117 bool analyzeOnly = false; |
| 117 bool analyzeAll = false; | 118 bool analyzeAll = false; |
| 119 bool resolveOnly = false; |
| 120 Uri resolutionOutput = currentDirectory.resolve('out.data'); |
| 118 bool dumpInfo = false; | 121 bool dumpInfo = false; |
| 119 bool allowNativeExtensions = false; | 122 bool allowNativeExtensions = false; |
| 120 bool trustTypeAnnotations = false; | 123 bool trustTypeAnnotations = false; |
| 121 bool trustJSInteropTypeAnnotations = false; | 124 bool trustJSInteropTypeAnnotations = false; |
| 122 bool checkedMode = false; | 125 bool checkedMode = false; |
| 123 // List of provided options that imply that output is expected. | 126 // List of provided options that imply that output is expected. |
| 124 List<String> optionsImplyCompilation = <String>[]; | 127 List<String> optionsImplyCompilation = <String>[]; |
| 125 bool hasDisallowUnsafeEval = false; | 128 bool hasDisallowUnsafeEval = false; |
| 126 // TODO(johnniwinther): Measure time for reading files. | 129 // TODO(johnniwinther): Measure time for reading files. |
| 127 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); | 130 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
| 128 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); | 131 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
| 129 Map<String, dynamic> environment = new Map<String, dynamic>(); | 132 Map<String, dynamic> environment = new Map<String, dynamic>(); |
| 130 | 133 |
| 131 passThrough(String argument) => options.add(argument); | 134 void passThrough(String argument) => options.add(argument); |
| 132 | 135 |
| 133 if (BUILD_ID != null) { | 136 if (BUILD_ID != null) { |
| 134 passThrough("--build-id=$BUILD_ID"); | 137 passThrough("--build-id=$BUILD_ID"); |
| 135 } | 138 } |
| 136 | 139 |
| 137 setLibraryRoot(String argument) { | 140 void setLibraryRoot(String argument) { |
| 138 libraryRoot = currentDirectory.resolve(extractPath(argument)); | 141 libraryRoot = currentDirectory.resolve(extractPath(argument)); |
| 139 } | 142 } |
| 140 | 143 |
| 141 setPackageRoot(String argument) { | 144 void setPackageRoot(String argument) { |
| 142 packageRoot = currentDirectory.resolve(extractPath(argument)); | 145 packageRoot = currentDirectory.resolve(extractPath(argument)); |
| 143 } | 146 } |
| 144 | 147 |
| 145 setPackageConfig(String argument) { | 148 void setPackageConfig(String argument) { |
| 146 packageConfig = | 149 packageConfig = |
| 147 currentDirectory.resolve(extractPath(argument, isDirectory: false)); | 150 currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
| 148 } | 151 } |
| 149 | 152 |
| 150 setOutput(Iterator<String> arguments) { | 153 void setOutput(Iterator<String> arguments) { |
| 151 optionsImplyCompilation.add(arguments.current); | 154 explicitOutputArguments.add(arguments.current); |
| 152 String path; | 155 String path; |
| 153 if (arguments.current == '-o') { | 156 if (arguments.current == '-o') { |
| 154 if (!arguments.moveNext()) { | 157 if (!arguments.moveNext()) { |
| 155 helpAndFail('Error: Missing file after -o option.'); | 158 helpAndFail('Error: Missing file after -o option.'); |
| 156 } | 159 } |
| 160 explicitOutputArguments.add(arguments.current); |
| 157 path = arguments.current; | 161 path = arguments.current; |
| 158 } else { | 162 } else { |
| 159 path = extractParameter(arguments.current); | 163 path = extractParameter(arguments.current); |
| 160 } | 164 } |
| 161 explicitOut = true; | 165 resolutionOutput = out = currentDirectory.resolve(nativeToUriPath(path)); |
| 162 out = currentDirectory.resolve(nativeToUriPath(path)); | |
| 163 sourceMapOut = Uri.parse('$out.map'); | 166 sourceMapOut = Uri.parse('$out.map'); |
| 164 } | 167 } |
| 165 | 168 |
| 166 setOutputType(String argument) { | 169 void setOutputType(String argument) { |
| 167 optionsImplyCompilation.add(argument); | 170 optionsImplyCompilation.add(argument); |
| 168 if (argument == '--output-type=dart' || | 171 if (argument == '--output-type=dart' || |
| 169 argument == '--output-type=dart-multi') { | 172 argument == '--output-type=dart-multi') { |
| 170 outputLanguage = OUTPUT_LANGUAGE_DART; | 173 outputLanguage = OUTPUT_LANGUAGE_DART; |
| 171 if (!explicitOut) { | 174 if (explicitOutputArguments.isNotEmpty) { |
| 172 out = currentDirectory.resolve('out.dart'); | 175 out = currentDirectory.resolve('out.dart'); |
| 173 sourceMapOut = currentDirectory.resolve('out.dart.map'); | 176 sourceMapOut = currentDirectory.resolve('out.dart.map'); |
| 174 } | 177 } |
| 175 diagnosticHandler( | 178 diagnosticHandler( |
| 176 null, | 179 null, |
| 177 null, | 180 null, |
| 178 null, | 181 null, |
| 179 "--output-type=dart is deprecated. It will remain available " | 182 "--output-type=dart is deprecated. It will remain available " |
| 180 "in Dart 1.11, but will be removed in Dart 1.12.", | 183 "in Dart 1.11, but will be removed in Dart 1.12.", |
| 181 api.Diagnostic.WARNING); | 184 api.Diagnostic.WARNING); |
| 182 } | 185 } |
| 183 passThrough(argument); | 186 passThrough(argument); |
| 184 } | 187 } |
| 185 | 188 |
| 189 void setResolutionInput(String argument) { |
| 190 resolutionInput = |
| 191 currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
| 192 } |
| 193 |
| 194 void setResolveOnly(String argument) { |
| 195 resolveOnly = true; |
| 196 passThrough(argument); |
| 197 } |
| 198 |
| 186 String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { | 199 String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { |
| 187 var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); | 200 var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); |
| 188 filenames.sort(); | 201 filenames.sort(); |
| 189 return filenames.join("\n"); | 202 return filenames.join("\n"); |
| 190 } | 203 } |
| 191 | 204 |
| 192 setStrip(String argument) { | 205 void implyCompilation(String argument) { |
| 193 optionsImplyCompilation.add(argument); | 206 optionsImplyCompilation.add(argument); |
| 194 stripArgumentSet = true; | |
| 195 passThrough(argument); | 207 passThrough(argument); |
| 196 } | 208 } |
| 197 | 209 |
| 198 setAnalyzeOnly(String argument) { | 210 void setStrip(String argument) { |
| 211 stripArgumentSet = true; |
| 212 implyCompilation(argument); |
| 213 } |
| 214 |
| 215 void setAnalyzeOnly(String argument) { |
| 199 analyzeOnly = true; | 216 analyzeOnly = true; |
| 200 passThrough(argument); | 217 passThrough(argument); |
| 201 } | 218 } |
| 202 | 219 |
| 203 setAnalyzeAll(String argument) { | 220 void setAnalyzeAll(String argument) { |
| 204 analyzeAll = true; | 221 analyzeAll = true; |
| 205 passThrough(argument); | 222 passThrough(argument); |
| 206 } | 223 } |
| 207 | 224 |
| 208 setAllowNativeExtensions(String argument) { | 225 void setAllowNativeExtensions(String argument) { |
| 209 allowNativeExtensions = true; | 226 allowNativeExtensions = true; |
| 210 passThrough(argument); | 227 passThrough(argument); |
| 211 } | 228 } |
| 212 | 229 |
| 213 setVerbose(_) { | 230 void setVerbose(_) { |
| 214 diagnosticHandler.verbose = true; | 231 diagnosticHandler.verbose = true; |
| 215 passThrough('--verbose'); | 232 passThrough('--verbose'); |
| 216 } | 233 } |
| 217 | 234 |
| 218 implyCompilation(String argument) { | 235 void setDumpInfo(String argument) { |
| 219 optionsImplyCompilation.add(argument); | |
| 220 passThrough(argument); | |
| 221 } | |
| 222 | |
| 223 setDumpInfo(String argument) { | |
| 224 implyCompilation(argument); | 236 implyCompilation(argument); |
| 225 dumpInfo = true; | 237 dumpInfo = true; |
| 226 } | 238 } |
| 227 | 239 |
| 228 setTrustTypeAnnotations(String argument) { | 240 void setTrustTypeAnnotations(String argument) { |
| 229 trustTypeAnnotations = true; | 241 trustTypeAnnotations = true; |
| 230 implyCompilation(argument); | 242 implyCompilation(argument); |
| 231 } | 243 } |
| 232 | 244 |
| 233 setTrustJSInteropTypeAnnotations(String argument) { | 245 void setTrustJSInteropTypeAnnotations(String argument) { |
| 234 trustJSInteropTypeAnnotations = true; | 246 trustJSInteropTypeAnnotations = true; |
| 235 implyCompilation(argument); | 247 implyCompilation(argument); |
| 236 } | 248 } |
| 237 | 249 |
| 238 setTrustPrimitives(String argument) { | 250 void setTrustPrimitives(String argument) { |
| 239 implyCompilation(argument); | 251 implyCompilation(argument); |
| 240 } | 252 } |
| 241 | 253 |
| 242 setCheckedMode(String argument) { | 254 void setCheckedMode(String argument) { |
| 243 checkedMode = true; | 255 checkedMode = true; |
| 244 passThrough(argument); | 256 passThrough(argument); |
| 245 } | 257 } |
| 246 | 258 |
| 247 addInEnvironment(String argument) { | 259 void addInEnvironment(String argument) { |
| 248 int eqIndex = argument.indexOf('='); | 260 int eqIndex = argument.indexOf('='); |
| 249 String name = argument.substring(2, eqIndex); | 261 String name = argument.substring(2, eqIndex); |
| 250 String value = argument.substring(eqIndex + 1); | 262 String value = argument.substring(eqIndex + 1); |
| 251 environment[name] = value; | 263 environment[name] = value; |
| 252 } | 264 } |
| 253 | 265 |
| 254 setCategories(String argument) { | 266 void setCategories(String argument) { |
| 255 List<String> categories = extractParameter(argument).split(','); | 267 List<String> categories = extractParameter(argument).split(','); |
| 256 if (categories.contains('all')) { | 268 if (categories.contains('all')) { |
| 257 categories = ["Client", "Server"]; | 269 categories = ["Client", "Server"]; |
| 258 } else { | 270 } else { |
| 259 for (String category in categories) { | 271 for (String category in categories) { |
| 260 if (!["Client", "Server"].contains(category)) { | 272 if (!["Client", "Server"].contains(category)) { |
| 261 fail('Unsupported library category "$category", ' | 273 fail('Unsupported library category "$category", ' |
| 262 'supported categories are: Client, Server, all'); | 274 'supported categories are: Client, Server, all'); |
| 263 } | 275 } |
| 264 } | 276 } |
| 265 } | 277 } |
| 266 passThrough('--categories=${categories.join(",")}'); | 278 passThrough('--categories=${categories.join(",")}'); |
| 267 } | 279 } |
| 268 | 280 |
| 269 void handleThrowOnError(String argument) { | 281 void handleThrowOnError(String argument) { |
| 270 diagnosticHandler.throwOnError = true; | 282 diagnosticHandler.throwOnError = true; |
| 271 String parameter = extractParameter(argument, isOptionalArgument: true); | 283 String parameter = extractParameter(argument, isOptionalArgument: true); |
| 272 if (parameter != null) { | 284 if (parameter != null) { |
| 273 diagnosticHandler.throwOnErrorCount = int.parse(parameter); | 285 diagnosticHandler.throwOnErrorCount = int.parse(parameter); |
| 274 } | 286 } |
| 275 } | 287 } |
| 276 | 288 |
| 277 handleShortOptions(String argument) { | 289 void handleShortOptions(String argument) { |
| 278 var shortOptions = argument.substring(1).split(""); | 290 var shortOptions = argument.substring(1).split(""); |
| 279 for (var shortOption in shortOptions) { | 291 for (var shortOption in shortOptions) { |
| 280 switch (shortOption) { | 292 switch (shortOption) { |
| 281 case 'v': | 293 case 'v': |
| 282 setVerbose(null); | 294 setVerbose(null); |
| 283 break; | 295 break; |
| 284 case 'h': | 296 case 'h': |
| 285 case '?': | 297 case '?': |
| 286 wantHelp = true; | 298 wantHelp = true; |
| 287 break; | 299 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 new OptionHandler( | 348 new OptionHandler( |
| 337 Flags.trustJSInteropTypeAnnotations, | 349 Flags.trustJSInteropTypeAnnotations, |
| 338 (_) => setTrustJSInteropTypeAnnotations( | 350 (_) => setTrustJSInteropTypeAnnotations( |
| 339 Flags.trustJSInteropTypeAnnotations)), | 351 Flags.trustJSInteropTypeAnnotations)), |
| 340 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), | 352 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), |
| 341 new OptionHandler('--packages=.+', setPackageConfig), | 353 new OptionHandler('--packages=.+', setPackageConfig), |
| 342 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), | 354 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
| 343 new OptionHandler(Flags.analyzeAll, setAnalyzeAll), | 355 new OptionHandler(Flags.analyzeAll, setAnalyzeAll), |
| 344 new OptionHandler(Flags.analyzeOnly, setAnalyzeOnly), | 356 new OptionHandler(Flags.analyzeOnly, setAnalyzeOnly), |
| 345 new OptionHandler(Flags.noSourceMaps, passThrough), | 357 new OptionHandler(Flags.noSourceMaps, passThrough), |
| 358 new OptionHandler(Option.resolutionInput, setResolutionInput), |
| 359 new OptionHandler(Flags.resolveOnly, setResolveOnly), |
| 346 new OptionHandler(Flags.analyzeSignaturesOnly, setAnalyzeOnly), | 360 new OptionHandler(Flags.analyzeSignaturesOnly, setAnalyzeOnly), |
| 347 new OptionHandler(Flags.disableNativeLiveTypeAnalysis, passThrough), | 361 new OptionHandler(Flags.disableNativeLiveTypeAnalysis, passThrough), |
| 348 new OptionHandler('--categories=.*', setCategories), | 362 new OptionHandler('--categories=.*', setCategories), |
| 349 new OptionHandler(Flags.disableTypeInference, implyCompilation), | 363 new OptionHandler(Flags.disableTypeInference, implyCompilation), |
| 350 new OptionHandler(Flags.terse, passThrough), | 364 new OptionHandler(Flags.terse, passThrough), |
| 351 new OptionHandler('--deferred-map=.+', implyCompilation), | 365 new OptionHandler('--deferred-map=.+', implyCompilation), |
| 352 new OptionHandler(Flags.dumpInfo, setDumpInfo), | 366 new OptionHandler(Flags.dumpInfo, setDumpInfo), |
| 353 new OptionHandler( | 367 new OptionHandler( |
| 354 '--disallow-unsafe-eval', (_) => hasDisallowUnsafeEval = true), | 368 '--disallow-unsafe-eval', (_) => hasDisallowUnsafeEval = true), |
| 355 new OptionHandler(Option.showPackageWarnings, passThrough), | 369 new OptionHandler(Option.showPackageWarnings, passThrough), |
| 356 new OptionHandler(Flags.useContentSecurityPolicy, passThrough), | 370 new OptionHandler(Flags.useContentSecurityPolicy, passThrough), |
| 357 new OptionHandler(Flags.enableExperimentalMirrors, passThrough), | 371 new OptionHandler(Flags.enableExperimentalMirrors, passThrough), |
| 358 new OptionHandler(Flags.enableAssertMessage, passThrough), | 372 new OptionHandler(Flags.enableAssertMessage, passThrough), |
| 373 |
| 359 // TODO(floitsch): remove conditional directives flag. | 374 // TODO(floitsch): remove conditional directives flag. |
| 360 // We don't provide the info-message yet, since we haven't publicly | 375 // We don't provide the info-message yet, since we haven't publicly |
| 361 // launched the feature yet. | 376 // launched the feature yet. |
| 362 new OptionHandler(Flags.conditionalDirectives, (_) {}), | 377 new OptionHandler(Flags.conditionalDirectives, (_) {}), |
| 363 new OptionHandler('--enable-async', (_) { | 378 new OptionHandler('--enable-async', (_) { |
| 364 diagnosticHandler.info( | 379 diagnosticHandler.info( |
| 365 "Option '--enable-async' is no longer needed. " | 380 "Option '--enable-async' is no longer needed. " |
| 366 "Async-await is supported by default.", | 381 "Async-await is supported by default.", |
| 367 api.Diagnostic.HINT); | 382 api.Diagnostic.HINT); |
| 368 }), | 383 }), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 436 |
| 422 if (checkedMode && trustTypeAnnotations) { | 437 if (checkedMode && trustTypeAnnotations) { |
| 423 helpAndFail("Option '${Flags.trustTypeAnnotations}' may not be used in " | 438 helpAndFail("Option '${Flags.trustTypeAnnotations}' may not be used in " |
| 424 "checked mode."); | 439 "checked mode."); |
| 425 } | 440 } |
| 426 | 441 |
| 427 if (packageRoot != null && packageConfig != null) { | 442 if (packageRoot != null && packageConfig != null) { |
| 428 helpAndFail("Cannot specify both '--package-root' and '--packages."); | 443 helpAndFail("Cannot specify both '--package-root' and '--packages."); |
| 429 } | 444 } |
| 430 | 445 |
| 431 if ((analyzeOnly || analyzeAll) && !optionsImplyCompilation.isEmpty) { | 446 List<String> optionsImplyOutput = <String>[] |
| 432 if (!analyzeOnly) { | 447 ..addAll(optionsImplyCompilation) |
| 448 ..addAll(explicitOutputArguments); |
| 449 if (resolveOnly && !optionsImplyCompilation.isEmpty) { |
| 450 diagnosticHandler.info( |
| 451 "Options $optionsImplyCompilation indicate that compilation is " |
| 452 "expected, but compilation is turned off by the option " |
| 453 "'${Flags.resolveOnly}'.", |
| 454 api.Diagnostic.INFO); |
| 455 } else if ((analyzeOnly || analyzeAll) && !optionsImplyOutput.isEmpty) { |
| 456 if (analyzeAll && !analyzeOnly) { |
| 433 diagnosticHandler.info( | 457 diagnosticHandler.info( |
| 434 "Option '${Flags.analyzeAll}' implies '${Flags.analyzeOnly}'.", | 458 "Option '${Flags.analyzeAll}' implies '${Flags.analyzeOnly}'.", |
| 435 api.Diagnostic.INFO); | 459 api.Diagnostic.INFO); |
| 436 } | 460 } |
| 437 diagnosticHandler.info( | 461 diagnosticHandler.info( |
| 438 "Options $optionsImplyCompilation indicate that output is expected, " | 462 "Options $optionsImplyOutput indicate that output is expected, " |
| 439 "but compilation is turned off by the option '${Flags.analyzeOnly}'.", | 463 "but compilation is turned off by the option '${Flags.analyzeOnly}'.", |
| 440 api.Diagnostic.INFO); | 464 api.Diagnostic.INFO); |
| 441 } | 465 } |
| 442 if (analyzeAll) analyzeOnly = true; | 466 if (resolveOnly) { |
| 467 analyzeOnly = analyzeAll = true; |
| 468 } else if (analyzeAll) { |
| 469 analyzeOnly = true; |
| 470 } |
| 443 if (!analyzeOnly) { | 471 if (!analyzeOnly) { |
| 444 if (allowNativeExtensions) { | 472 if (allowNativeExtensions) { |
| 445 helpAndFail("Option '${Flags.allowNativeExtensions}' is only supported " | 473 helpAndFail("Option '${Flags.allowNativeExtensions}' is only supported " |
| 446 "in combination with the '${Flags.analyzeOnly}' option."); | 474 "in combination with the '${Flags.analyzeOnly}' option."); |
| 447 } | 475 } |
| 448 } | 476 } |
| 449 if (dumpInfo && outputLanguage == OUTPUT_LANGUAGE_DART) { | 477 if (dumpInfo && outputLanguage == OUTPUT_LANGUAGE_DART) { |
| 450 helpAndFail("Option '${Flags.dumpInfo}' is not supported in " | 478 helpAndFail("Option '${Flags.dumpInfo}' is not supported in " |
| 451 "combination with the '--output-type=dart' option."); | 479 "combination with the '--output-type=dart' option."); |
| 452 } | 480 } |
| 453 | 481 |
| 454 options.add('--out=$out'); | 482 options.add('--out=$out'); |
| 455 options.add('--source-map=$sourceMapOut'); | 483 options.add('--source-map=$sourceMapOut'); |
| 456 | 484 |
| 457 RandomAccessFileOutputProvider outputProvider = | 485 RandomAccessFileOutputProvider outputProvider = |
| 458 new RandomAccessFileOutputProvider(out, sourceMapOut, | 486 new RandomAccessFileOutputProvider(out, sourceMapOut, |
| 459 onInfo: diagnosticHandler.info, onFailure: fail); | 487 onInfo: diagnosticHandler.info, |
| 488 onFailure: fail, |
| 489 resolutionOutput: resolveOnly ? resolutionOutput : null); |
| 460 | 490 |
| 461 api.CompilationResult compilationDone(api.CompilationResult result) { | 491 api.CompilationResult compilationDone(api.CompilationResult result) { |
| 462 if (analyzeOnly) return result; | 492 if (analyzeOnly) return result; |
| 463 if (!result.isSuccess) { | 493 if (!result.isSuccess) { |
| 464 fail('Compilation failed.'); | 494 fail('Compilation failed.'); |
| 465 } | 495 } |
| 466 writeString( | 496 writeString( |
| 467 Uri.parse('$out.deps'), getDepsOutput(inputProvider.sourceFiles)); | 497 Uri.parse('$out.deps'), getDepsOutput(inputProvider.sourceFiles)); |
| 468 diagnosticHandler | 498 diagnosticHandler |
| 469 .info('Compiled ${inputProvider.dartCharactersRead} characters Dart ' | 499 .info('Compiled ${inputProvider.dartCharactersRead} characters Dart ' |
| 470 '-> ${outputProvider.totalCharactersWritten} characters ' | 500 '-> ${outputProvider.totalCharactersWritten} characters ' |
| 471 '$outputLanguage in ' | 501 '$outputLanguage in ' |
| 472 '${relativize(currentDirectory, out, Platform.isWindows)}'); | 502 '${relativize(currentDirectory, out, Platform.isWindows)}'); |
| 473 if (diagnosticHandler.verbose) { | 503 if (diagnosticHandler.verbose) { |
| 474 String input = uriPathToNative(arguments[0]); | 504 String input = uriPathToNative(arguments[0]); |
| 475 print('Dart file ($input) compiled to $outputLanguage.'); | 505 print('Dart file ($input) compiled to $outputLanguage.'); |
| 476 print('Wrote the following files:'); | 506 print('Wrote the following files:'); |
| 477 for (String filename in outputProvider.allOutputFiles) { | 507 for (String filename in outputProvider.allOutputFiles) { |
| 478 print(" $filename"); | 508 print(" $filename"); |
| 479 } | 509 } |
| 480 } else if (!explicitOut) { | 510 } else if (explicitOutputArguments.isNotEmpty) { |
| 481 String input = uriPathToNative(arguments[0]); | 511 String input = uriPathToNative(arguments[0]); |
| 482 String output = relativize(currentDirectory, out, Platform.isWindows); | 512 String output = relativize(currentDirectory, out, Platform.isWindows); |
| 483 print('Dart file ($input) compiled to $outputLanguage: $output'); | 513 print('Dart file ($input) compiled to $outputLanguage: $output'); |
| 484 } | 514 } |
| 485 return result; | 515 return result; |
| 486 } | 516 } |
| 487 | 517 |
| 488 Uri script = currentDirectory.resolve(arguments[0]); | 518 Uri script = currentDirectory.resolve(arguments[0]); |
| 489 CompilerOptions compilerOptions = new CompilerOptions.parse( | 519 CompilerOptions compilerOptions = new CompilerOptions.parse( |
| 490 entryPoint: script, | 520 entryPoint: script, |
| 491 libraryRoot: libraryRoot, | 521 libraryRoot: libraryRoot, |
| 492 packageRoot: packageRoot, | 522 packageRoot: packageRoot, |
| 493 packageConfig: packageConfig, | 523 packageConfig: packageConfig, |
| 494 packagesDiscoveryProvider: findPackages, | 524 packagesDiscoveryProvider: findPackages, |
| 525 resolutionInput: resolutionInput, |
| 526 resolutionOutput: resolutionOutput, |
| 495 options: options, | 527 options: options, |
| 496 environment: environment); | 528 environment: environment); |
| 497 return compileFunc(compilerOptions, inputProvider, | 529 return compileFunc( |
| 498 diagnosticHandler, outputProvider) | 530 compilerOptions, inputProvider, diagnosticHandler, outputProvider) |
| 499 .then(compilationDone); | 531 .then(compilationDone); |
| 500 } | 532 } |
| 501 | 533 |
| 502 class AbortLeg { | 534 class AbortLeg { |
| 503 final message; | 535 final message; |
| 504 AbortLeg(this.message); | 536 AbortLeg(this.message); |
| 505 toString() => 'Aborted due to --throw-on-error: $message'; | 537 toString() => 'Aborted due to --throw-on-error: $message'; |
| 506 } | 538 } |
| 507 | 539 |
| 508 void writeString(Uri uri, String text) { | 540 void writeString(Uri uri, String text) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 } else if (exitCode == 253) { | 816 } else if (exitCode == 253) { |
| 785 print(">>> TEST CRASH"); | 817 print(">>> TEST CRASH"); |
| 786 } else { | 818 } else { |
| 787 print(">>> TEST FAIL"); | 819 print(">>> TEST FAIL"); |
| 788 } | 820 } |
| 789 stderr.writeln(">>> EOF STDERR"); | 821 stderr.writeln(">>> EOF STDERR"); |
| 790 subscription.resume(); | 822 subscription.resume(); |
| 791 }); | 823 }); |
| 792 }); | 824 }); |
| 793 } | 825 } |
| OLD | NEW |