| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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'); | 5 #library('dart2js'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('dart:uri'); | 8 #import('dart:uri'); |
| 9 #import('dart:utf'); | 9 #import('dart:utf'); |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 verbose = true; | 33 verbose = true; |
| 34 } else if (argument.startsWith('--library-root=')) { | 34 } else if (argument.startsWith('--library-root=')) { |
| 35 String path = | 35 String path = |
| 36 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); | 36 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); |
| 37 if (!path.endsWith("/")) path = "$path/"; | 37 if (!path.endsWith("/")) path = "$path/"; |
| 38 libraryRoot = cwd.resolve(path); | 38 libraryRoot = cwd.resolve(path); |
| 39 } else if (argument.startsWith('--out=')) { | 39 } else if (argument.startsWith('--out=')) { |
| 40 String path = | 40 String path = |
| 41 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); | 41 nativeToUriPath(argument.substring(argument.indexOf('=') + 1)); |
| 42 out = cwd.resolve(path); | 42 out = cwd.resolve(path); |
| 43 } else if (argument == '--allow-mock-compilation') { | 43 } else if ('--allow-mock-compilation' == argument) { |
| 44 options.add(argument); | 44 options.add(argument); |
| 45 } else if (argument.startsWith('-')) { | 45 } else if (argument.startsWith('-')) { |
| 46 fail('Unknown option $argument.'); | 46 fail('Unknown option $argument.'); |
| 47 } else { | 47 } else { |
| 48 arguments.add(nativeToUriPath(argument)); | 48 arguments.add(nativeToUriPath(argument)); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 if (arguments.isEmpty()) { | 51 if (arguments.isEmpty()) { |
| 52 fail('No files to compile.'); | 52 fail('No file to compile.'); |
| 53 } | 53 } |
| 54 if (arguments.length > 1) { | 54 if (arguments.length > 1) { |
| 55 var extra = arguments.getRange(1, arguments.length - 1); | 55 var extra = arguments.getRange(1, arguments.length - 1); |
| 56 fail('Extra arguments: $extra.'); | 56 fail('Extra arguments: $extra.'); |
| 57 } | 57 } |
| 58 | 58 |
| 59 Map<String, SourceFile> sourceFiles = <SourceFile>{}; | 59 Map<String, SourceFile> sourceFiles = <SourceFile>{}; |
| 60 int dartBytesRead = 0; | 60 int dartBytesRead = 0; |
| 61 | 61 |
| 62 Future<String> provider(Uri uri) { | 62 Future<String> provider(Uri uri) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 var buffer = new List<int>(length); | 127 var buffer = new List<int>(length); |
| 128 var bytes = file.readListSync(buffer, 0, length); | 128 var bytes = file.readListSync(buffer, 0, length); |
| 129 file.closeSync(); | 129 file.closeSync(); |
| 130 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); | 130 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void fail(String message) { | 133 void fail(String message) { |
| 134 print(message); | 134 print(message); |
| 135 exit(1); | 135 exit(1); |
| 136 } | 136 } |
| OLD | NEW |