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' | 7 import 'dart:async' |
8 show Future, EventSink; | 8 show Future, EventSink; |
9 import 'dart:convert' show UTF8, LineSplitter; | 9 import 'dart:convert' show UTF8, LineSplitter; |
10 import 'dart:io' | 10 import 'dart:io' |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 Uri packageRoot = null; | 108 Uri packageRoot = null; |
109 List<String> options = new List<String>(); | 109 List<String> options = new List<String>(); |
110 bool explicitOut = false; | 110 bool explicitOut = false; |
111 bool wantHelp = false; | 111 bool wantHelp = false; |
112 bool wantVersion = false; | 112 bool wantVersion = false; |
113 String outputLanguage = 'JavaScript'; | 113 String outputLanguage = 'JavaScript'; |
114 bool stripArgumentSet = false; | 114 bool stripArgumentSet = false; |
115 bool analyzeOnly = false; | 115 bool analyzeOnly = false; |
116 bool analyzeAll = false; | 116 bool analyzeAll = false; |
117 bool enableAsyncAwait = false; | 117 bool enableAsyncAwait = false; |
| 118 bool allowNativeExtensions = false; |
118 bool trustTypeAnnotations = false; | 119 bool trustTypeAnnotations = false; |
119 bool checkedMode = false; | 120 bool checkedMode = false; |
120 // List of provided options that imply that output is expected. | 121 // List of provided options that imply that output is expected. |
121 List<String> optionsImplyCompilation = <String>[]; | 122 List<String> optionsImplyCompilation = <String>[]; |
122 bool hasDisallowUnsafeEval = false; | 123 bool hasDisallowUnsafeEval = false; |
123 // TODO(johnniwinther): Measure time for reading files. | 124 // TODO(johnniwinther): Measure time for reading files. |
124 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); | 125 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
125 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); | 126 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
126 Map<String, dynamic> environment = new Map<String, dynamic>(); | 127 Map<String, dynamic> environment = new Map<String, dynamic>(); |
127 | 128 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 setAnalyzeAll(String argument) { | 189 setAnalyzeAll(String argument) { |
189 analyzeAll = true; | 190 analyzeAll = true; |
190 passThrough(argument); | 191 passThrough(argument); |
191 } | 192 } |
192 | 193 |
193 setEnableAsync(String argument) { | 194 setEnableAsync(String argument) { |
194 enableAsyncAwait = true; | 195 enableAsyncAwait = true; |
195 passThrough(argument); | 196 passThrough(argument); |
196 } | 197 } |
197 | 198 |
| 199 setAllowNativeExtensions(String argument) { |
| 200 allowNativeExtensions = true; |
| 201 passThrough(argument); |
| 202 } |
| 203 |
198 setVerbose(_) { | 204 setVerbose(_) { |
199 diagnosticHandler.verbose = true; | 205 diagnosticHandler.verbose = true; |
200 passThrough('--verbose'); | 206 passThrough('--verbose'); |
201 } | 207 } |
202 | 208 |
203 implyCompilation(String argument) { | 209 implyCompilation(String argument) { |
204 optionsImplyCompilation.add(argument); | 210 optionsImplyCompilation.add(argument); |
205 passThrough(argument); | 211 passThrough(argument); |
206 } | 212 } |
207 | 213 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 new OptionHandler('--disable-native-live-type-analysis', passThrough), | 323 new OptionHandler('--disable-native-live-type-analysis', passThrough), |
318 new OptionHandler('--categories=.*', setCategories), | 324 new OptionHandler('--categories=.*', setCategories), |
319 new OptionHandler('--disable-type-inference', implyCompilation), | 325 new OptionHandler('--disable-type-inference', implyCompilation), |
320 new OptionHandler('--terse', passThrough), | 326 new OptionHandler('--terse', passThrough), |
321 new OptionHandler('--dump-info', implyCompilation), | 327 new OptionHandler('--dump-info', implyCompilation), |
322 new OptionHandler('--disallow-unsafe-eval', | 328 new OptionHandler('--disallow-unsafe-eval', |
323 (_) => hasDisallowUnsafeEval = true), | 329 (_) => hasDisallowUnsafeEval = true), |
324 new OptionHandler('--show-package-warnings', passThrough), | 330 new OptionHandler('--show-package-warnings', passThrough), |
325 new OptionHandler('--csp', passThrough), | 331 new OptionHandler('--csp', passThrough), |
326 new OptionHandler('--enable-async', setEnableAsync), | 332 new OptionHandler('--enable-async', setEnableAsync), |
| 333 new OptionHandler('--allow-native-extensions', setAllowNativeExtensions), |
327 new OptionHandler('-D.+=.*', addInEnvironment), | 334 new OptionHandler('-D.+=.*', addInEnvironment), |
328 | 335 |
329 // The following two options must come last. | 336 // The following two options must come last. |
330 new OptionHandler('-.*', (String argument) { | 337 new OptionHandler('-.*', (String argument) { |
331 helpAndFail("Unknown option '$argument'."); | 338 helpAndFail("Unknown option '$argument'."); |
332 }), | 339 }), |
333 new OptionHandler('.*', (String argument) { | 340 new OptionHandler('.*', (String argument) { |
334 arguments.add(nativeToUriPath(argument)); | 341 arguments.add(nativeToUriPath(argument)); |
335 }) | 342 }) |
336 ]; | 343 ]; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 diagnosticHandler.info( | 384 diagnosticHandler.info( |
378 "Option '--analyze-all' implies '--analyze-only'.", | 385 "Option '--analyze-all' implies '--analyze-only'.", |
379 api.Diagnostic.INFO); | 386 api.Diagnostic.INFO); |
380 } | 387 } |
381 diagnosticHandler.info( | 388 diagnosticHandler.info( |
382 "Options $optionsImplyCompilation indicate that output is expected, " | 389 "Options $optionsImplyCompilation indicate that output is expected, " |
383 "but compilation is turned off by the option '--analyze-only'.", | 390 "but compilation is turned off by the option '--analyze-only'.", |
384 api.Diagnostic.INFO); | 391 api.Diagnostic.INFO); |
385 } | 392 } |
386 if (analyzeAll) analyzeOnly = true; | 393 if (analyzeAll) analyzeOnly = true; |
387 if (enableAsyncAwait && !analyzeOnly) { | 394 if (!analyzeOnly) { |
388 helpAndFail("Option '--enable-async' is currently only supported in " | 395 if (enableAsyncAwait) { |
389 "combination with the '--analyze-only' option."); | 396 helpAndFail("Option '--enable-async' is currently only supported in " |
| 397 "combination with the '--analyze-only' option."); |
| 398 } |
| 399 if (allowNativeExtensions) { |
| 400 helpAndFail("Option '--allow-native-extensions' is only supported in " |
| 401 "combination with the '--analyze-only' option."); |
| 402 } |
390 } | 403 } |
391 | 404 |
392 diagnosticHandler.info('Package root is $packageRoot'); | 405 diagnosticHandler.info('Package root is $packageRoot'); |
393 | 406 |
394 options.add('--out=$out'); | 407 options.add('--out=$out'); |
395 options.add('--source-map=$sourceMapOut'); | 408 options.add('--source-map=$sourceMapOut'); |
396 | 409 |
397 RandomAccessFileOutputProvider outputProvider = | 410 RandomAccessFileOutputProvider outputProvider = |
398 new RandomAccessFileOutputProvider( | 411 new RandomAccessFileOutputProvider( |
399 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); | 412 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } else if (exitCode == 253) { | 692 } else if (exitCode == 253) { |
680 print(">>> TEST CRASH"); | 693 print(">>> TEST CRASH"); |
681 } else { | 694 } else { |
682 print(">>> TEST FAIL"); | 695 print(">>> TEST FAIL"); |
683 } | 696 } |
684 stderr.writeln(">>> EOF STDERR"); | 697 stderr.writeln(">>> EOF STDERR"); |
685 subscription.resume(); | 698 subscription.resume(); |
686 }); | 699 }); |
687 }); | 700 }); |
688 } | 701 } |
OLD | NEW |