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 EventSink, Future; | 7 import 'dart:async' show EventSink, 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 FormattingDiagnosticHandler diagnosticHandler; | 104 FormattingDiagnosticHandler diagnosticHandler; |
105 | 105 |
106 Future<api.CompilationResult> compile(List<String> argv) { | 106 Future<api.CompilationResult> compile(List<String> argv) { |
107 stackTraceFilePrefix = '$currentDirectory'; | 107 stackTraceFilePrefix = '$currentDirectory'; |
108 Uri libraryRoot = currentDirectory; | 108 Uri libraryRoot = currentDirectory; |
109 Uri out = currentDirectory.resolve('out.js'); | 109 Uri out = currentDirectory.resolve('out.js'); |
110 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); | 110 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
111 Uri resolutionInput; | 111 List<Uri> resolutionInputs; |
112 Uri packageConfig = null; | 112 Uri packageConfig = null; |
113 Uri packageRoot = null; | 113 Uri packageRoot = null; |
114 List<String> options = new List<String>(); | 114 List<String> options = new List<String>(); |
115 List<String> explicitOutputArguments = <String>[]; | 115 List<String> explicitOutputArguments = <String>[]; |
116 bool wantHelp = false; | 116 bool wantHelp = false; |
117 bool wantVersion = false; | 117 bool wantVersion = false; |
118 String outputLanguage = 'JavaScript'; | 118 String outputLanguage = 'JavaScript'; |
119 bool stripArgumentSet = false; | 119 bool stripArgumentSet = false; |
120 bool analyzeOnly = false; | 120 bool analyzeOnly = false; |
121 bool analyzeAll = false; | 121 bool analyzeAll = false; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 null, | 183 null, |
184 null, | 184 null, |
185 "--output-type=dart is deprecated. It will remain available " | 185 "--output-type=dart is deprecated. It will remain available " |
186 "in Dart 1.11, but will be removed in Dart 1.12.", | 186 "in Dart 1.11, but will be removed in Dart 1.12.", |
187 api.Diagnostic.WARNING); | 187 api.Diagnostic.WARNING); |
188 } | 188 } |
189 passThrough(argument); | 189 passThrough(argument); |
190 } | 190 } |
191 | 191 |
192 void setResolutionInput(String argument) { | 192 void setResolutionInput(String argument) { |
193 resolutionInput = | 193 resolutionInputs = <Uri>[]; |
194 currentDirectory.resolve(extractPath(argument, isDirectory: false)); | 194 String parts = extractParameter(argument); |
195 for (String part in parts.split(',')) { | |
196 resolutionInputs.add( | |
197 currentDirectory.resolve(nativeToUriPath(part))); | |
198 } | |
195 } | 199 } |
196 | 200 |
197 void setResolveOnly(String argument) { | 201 void setResolveOnly(String argument) { |
198 resolveOnly = true; | 202 resolveOnly = true; |
199 passThrough(argument); | 203 passThrough(argument); |
200 } | 204 } |
201 | 205 |
202 String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { | 206 String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { |
203 var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); | 207 var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); |
204 filenames.sort(); | 208 filenames.sort(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 return result; | 522 return result; |
519 } | 523 } |
520 | 524 |
521 Uri script = currentDirectory.resolve(arguments[0]); | 525 Uri script = currentDirectory.resolve(arguments[0]); |
522 CompilerOptions compilerOptions = new CompilerOptions.parse( | 526 CompilerOptions compilerOptions = new CompilerOptions.parse( |
523 entryPoint: script, | 527 entryPoint: script, |
524 libraryRoot: libraryRoot, | 528 libraryRoot: libraryRoot, |
525 packageRoot: packageRoot, | 529 packageRoot: packageRoot, |
526 packageConfig: packageConfig, | 530 packageConfig: packageConfig, |
527 packagesDiscoveryProvider: findPackages, | 531 packagesDiscoveryProvider: findPackages, |
528 resolutionInput: resolutionInput, | 532 resolutionInputs: resolutionInputs, |
529 resolutionOutput: resolutionOutput, | 533 resolutionOutput: resolutionOutput, |
530 options: options, | 534 options: options, |
531 environment: environment); | 535 environment: environment); |
532 return compileFunc( | 536 return compileFunc( |
533 compilerOptions, inputProvider, diagnosticHandler, outputProvider) | 537 compilerOptions, inputProvider, diagnosticHandler, outputProvider) |
534 .then(compilationDone); | 538 .then(compilationDone); |
535 } | 539 } |
536 | 540 |
537 class AbortLeg { | 541 class AbortLeg { |
538 final message; | 542 final message; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 } | 831 } |
828 stderr.writeln(">>> EOF STDERR"); | 832 stderr.writeln(">>> EOF STDERR"); |
829 subscription.resume(); | 833 subscription.resume(); |
830 }); | 834 }); |
831 }); | 835 }); |
832 } | 836 } |
833 | 837 |
834 final bool USE_SERIALIZED_DART_CORE = | 838 final bool USE_SERIALIZED_DART_CORE = |
835 Platform.environment['USE_SERIALIZED_DART_CORE'] == 'true'; | 839 Platform.environment['USE_SERIALIZED_DART_CORE'] == 'true'; |
836 | 840 |
841 final Uri _SERIALIZED_URI = Uri.parse('file:fake.data'); | |
Siggi Cherem (dart-lang)
2016/05/24 18:08:14
+dartdoc just to remember that this URI is a mock
Johnni Winther
2016/05/25 07:54:46
Done.
| |
842 | |
837 void _useSerializedDataForDartCore(CompileFunc oldCompileFunc) { | 843 void _useSerializedDataForDartCore(CompileFunc oldCompileFunc) { |
838 String serializedData; | 844 String serializedData; |
839 | 845 |
840 Future<api.CompilationResult> compileWithSerializedData( | 846 Future<api.CompilationResult> compileWithSerializedData( |
841 CompilerOptions compilerOptions, | 847 CompilerOptions compilerOptions, |
842 api.CompilerInput compilerInput, | 848 api.CompilerInput compilerInput, |
843 api.CompilerDiagnostics compilerDiagnostics, | 849 api.CompilerDiagnostics compilerDiagnostics, |
844 api.CompilerOutput compilerOutput) async { | 850 api.CompilerOutput compilerOutput) async { |
845 CompilerImpl compiler = new CompilerImpl( | 851 CompilerImpl compiler = new CompilerImpl( |
846 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions); | 852 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions); |
847 compiler.serialization.deserializeFromText(serializedData); | 853 compiler.serialization.deserializeFromText( |
854 _SERIALIZED_URI, serializedData); | |
848 return compiler.run(compilerOptions.entryPoint).then((bool success) { | 855 return compiler.run(compilerOptions.entryPoint).then((bool success) { |
849 return new api.CompilationResult(compiler, isSuccess: success); | 856 return new api.CompilationResult(compiler, isSuccess: success); |
850 }); | 857 }); |
851 } | 858 } |
852 | 859 |
853 Future<api.CompilationResult> generateSerializedDataForDartCore( | 860 Future<api.CompilationResult> generateSerializedDataForDartCore( |
854 CompilerOptions compilerOptions, | 861 CompilerOptions compilerOptions, |
855 api.CompilerInput compilerInput, | 862 api.CompilerInput compilerInput, |
856 api.CompilerDiagnostics compilerDiagnostics, | 863 api.CompilerDiagnostics compilerDiagnostics, |
857 api.CompilerOutput compilerOutput) async { | 864 api.CompilerOutput compilerOutput) async { |
858 _CompilerOutput output = new _CompilerOutput(); | 865 _CompilerOutput output = new _CompilerOutput(); |
859 api.CompilationResult result = await oldCompileFunc( | 866 api.CompilationResult result = await oldCompileFunc( |
860 new CompilerOptions.parse( | 867 new CompilerOptions.parse( |
861 entryPoint: Uris.dart_core, | 868 entryPoint: Uris.dart_core, |
862 libraryRoot: compilerOptions.libraryRoot, | 869 libraryRoot: compilerOptions.libraryRoot, |
863 packageRoot: compilerOptions.packageRoot, | 870 packageRoot: compilerOptions.packageRoot, |
864 packageConfig: compilerOptions.packageConfig, | 871 packageConfig: compilerOptions.packageConfig, |
865 packagesDiscoveryProvider: | 872 packagesDiscoveryProvider: |
866 compilerOptions.packagesDiscoveryProvider, | 873 compilerOptions.packagesDiscoveryProvider, |
867 environment: compilerOptions.environment, | 874 environment: compilerOptions.environment, |
868 resolutionOutput: Uri.parse('file:fake.data'), | 875 resolutionOutput: _SERIALIZED_URI, |
869 options: [Flags.resolveOnly]), | 876 options: [Flags.resolveOnly]), |
870 compilerInput, | 877 compilerInput, |
871 compilerDiagnostics, | 878 compilerDiagnostics, |
872 output); | 879 output); |
873 serializedData = output.serializedData; | 880 serializedData = output.serializedData; |
874 compileFunc = compileWithSerializedData; | 881 compileFunc = compileWithSerializedData; |
875 return compileWithSerializedData( | 882 return compileWithSerializedData( |
876 compilerOptions, compilerInput, compilerDiagnostics, compilerOutput); | 883 compilerOptions, compilerInput, compilerDiagnostics, compilerOutput); |
877 } | 884 } |
878 | 885 |
(...skipping 25 matching lines...) Expand all Loading... | |
904 @override | 911 @override |
905 void close() { | 912 void close() { |
906 // Do nothing. | 913 // Do nothing. |
907 } | 914 } |
908 | 915 |
909 @override | 916 @override |
910 void addError(errorEvent, [StackTrace stackTrace]) { | 917 void addError(errorEvent, [StackTrace stackTrace]) { |
911 // Ignore | 918 // Ignore |
912 } | 919 } |
913 } | 920 } |
OLD | NEW |