| 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 // Usage: Add the following to your .gclient file (found in the parent | 5 // Usage: Add the following to your .gclient file (found in the parent |
| 6 // of the "dart" in a gclient checkout of the Dart repositor). | 6 // of the "dart" in a gclient checkout of the Dart repositor). |
| 7 // | 7 // |
| 8 // hooks = [ | 8 // hooks = [ |
| 9 // { | 9 // { |
| 10 // "pattern": ".", | 10 // "pattern": ".", |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const SDK_ROOT = '../../../../../'; | 44 const SDK_ROOT = '../../../../../'; |
| 45 | 45 |
| 46 bool isPublicDart2jsLibrary(String name) { | 46 bool isPublicDart2jsLibrary(String name) { |
| 47 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary; | 47 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary; |
| 48 } | 48 } |
| 49 | 49 |
| 50 var handler; | 50 var handler; |
| 51 RandomAccessFile output; | 51 RandomAccessFile output; |
| 52 Uri outputUri; | 52 Uri outputUri; |
| 53 | 53 |
| 54 main() { | 54 main(List<String> arguments) { |
| 55 mainWithOptions(new Options()); | |
| 56 } | |
| 57 | |
| 58 mainWithOptions(Options options) { | |
| 59 handler = new FormattingDiagnosticHandler() | 55 handler = new FormattingDiagnosticHandler() |
| 60 ..throwOnError = true; | 56 ..throwOnError = true; |
| 61 | 57 |
| 62 outputUri = | 58 outputUri = |
| 63 handler.provider.cwd.resolve(nativeToUriPath(options.arguments.first)); | 59 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); |
| 64 output = new File(options.arguments.first).openSync(mode: FileMode.WRITE); | 60 output = new File(arguments.first).openSync(mode: FileMode.WRITE); |
| 65 | 61 |
| 66 Uri myLocation = | 62 Uri myLocation = |
| 67 handler.provider.cwd.resolve(nativeToUriPath(options.script)); | 63 handler.provider.cwd.resolve(nativeToUriPath(Platform.script)); |
| 68 | 64 |
| 69 // Get the names of public dart2js libraries. | 65 // Get the names of public dart2js libraries. |
| 70 Iterable<String> names = LIBRARIES.keys.where(isPublicDart2jsLibrary); | 66 Iterable<String> names = LIBRARIES.keys.where(isPublicDart2jsLibrary); |
| 71 | 67 |
| 72 // Prepend "dart:" to the names. | 68 // Prepend "dart:" to the names. |
| 73 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList(); | 69 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList(); |
| 74 | 70 |
| 75 // Append dart2js itself. | 71 // Append dart2js itself. |
| 76 uris.add(myLocation.resolve(DART2JS)); | 72 uris.add(myLocation.resolve(DART2JS)); |
| 77 uris.add(myLocation.resolve(DART2JS_MIRROR)); | 73 uris.add(myLocation.resolve(DART2JS_MIRROR)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 123 |
| 128 var tag_definition_data = '$buffer'; | 124 var tag_definition_data = '$buffer'; |
| 129 var src_file = relativize(outputUri, uri, false); | 125 var src_file = relativize(outputUri, uri, false); |
| 130 var size_of_tag_definition_data_in_bytes = tag_definition_data.length; | 126 var size_of_tag_definition_data_in_bytes = tag_definition_data.length; |
| 131 | 127 |
| 132 // The header. | 128 // The header. |
| 133 output.writeStringSync( | 129 output.writeStringSync( |
| 134 '\x0c\n${src_file},${size_of_tag_definition_data_in_bytes}\n'); | 130 '\x0c\n${src_file},${size_of_tag_definition_data_in_bytes}\n'); |
| 135 output.writeStringSync(tag_definition_data); | 131 output.writeStringSync(tag_definition_data); |
| 136 } | 132 } |
| OLD | NEW |