| 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 | 7 |
| 8 // TODO(ahe): Should be dart:mirrors. | 8 // TODO(ahe): Should be dart:mirrors. |
| 9 import '../../implementation/mirrors/mirrors.dart'; | 9 import '../../implementation/mirrors/mirrors.dart'; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 const SDK_ROOT = '../../../../../'; | 24 const SDK_ROOT = '../../../../../'; |
| 25 | 25 |
| 26 bool isPublicDart2jsLibrary(String name) { | 26 bool isPublicDart2jsLibrary(String name) { |
| 27 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary; | 27 return !name.startsWith('_') && LIBRARIES[name].isDart2jsLibrary; |
| 28 } | 28 } |
| 29 | 29 |
| 30 var handler; | 30 var handler; |
| 31 RandomAccessFile output; | 31 RandomAccessFile output; |
| 32 Uri outputUri; | 32 Uri outputUri; |
| 33 Uri sdkRoot; | 33 Uri sdkRoot; |
| 34 const bool outputJson = |
| 35 const bool.fromEnvironment('outputJson', defaultValue: false); |
| 34 | 36 |
| 35 main(List<String> arguments) { | 37 main(List<String> arguments) { |
| 36 handler = new FormattingDiagnosticHandler() | 38 handler = new FormattingDiagnosticHandler() |
| 37 ..throwOnError = true; | 39 ..throwOnError = true; |
| 38 | 40 |
| 39 outputUri = | 41 outputUri = |
| 40 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); | 42 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); |
| 41 output = new File(arguments.first).openSync(mode: FileMode.WRITE); | 43 output = new File(arguments.first).openSync(mode: FileMode.WRITE); |
| 42 | 44 |
| 43 Uri myLocation = | 45 Uri myLocation = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 LIBRARIES.forEach((name, info) { | 72 LIBRARIES.forEach((name, info) { |
| 71 var patch = info.dart2jsPatchPath; | 73 var patch = info.dart2jsPatchPath; |
| 72 if (patch != null) { | 74 if (patch != null) { |
| 73 Uri uri = sdkRoot.resolve('sdk/lib/$patch'); | 75 Uri uri = sdkRoot.resolve('sdk/lib/$patch'); |
| 74 String filename = relativize(sdkRoot, uri, false); | 76 String filename = relativize(sdkRoot, uri, false); |
| 75 SourceFile file = handler.provider.sourceFiles['$uri']; | 77 SourceFile file = handler.provider.sourceFiles['$uri']; |
| 76 map['sdk:/$filename'] = file.slowText(); | 78 map['sdk:/$filename'] = file.slowText(); |
| 77 } | 79 } |
| 78 }); | 80 }); |
| 79 | 81 |
| 80 output.writeStringSync(''' | 82 if (outputJson) { |
| 83 output.writeStringSync(JSON.encode(map)); |
| 84 } else { |
| 85 output.writeStringSync(''' |
| 81 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 86 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 82 // for details. All rights reserved. Use of this source code is governed by a | 87 // for details. All rights reserved. Use of this source code is governed by a |
| 83 // BSD-style license that can be found in the LICENSE file. | 88 // BSD-style license that can be found in the LICENSE file. |
| 84 | 89 |
| 85 // DO NOT EDIT. | 90 // DO NOT EDIT. |
| 86 // This file is generated by jsonify.dart. | 91 // This file is generated by jsonify.dart. |
| 87 | 92 |
| 88 library dart.sdk_sources; | 93 library dart.sdk_sources; |
| 89 | 94 |
| 90 const Map<String, String> SDK_SOURCES = const <String, String>'''); | 95 const Map<String, String> SDK_SOURCES = const <String, String>'''); |
| 91 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); | 96 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); |
| 92 output.writeStringSync(';\n'); | 97 output.writeStringSync(';\n'); |
| 98 } |
| 93 output.closeSync(); | 99 output.closeSync(); |
| 94 } | 100 } |
| OLD | NEW |