| 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:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| 11 import 'package:sdk_library_metadata/libraries.dart' | 11 import 'package:sdk_library_metadata/libraries.dart' |
| 12 show libraries, LibraryInfo; | 12 show libraries, LibraryInfo; |
| 13 | 13 |
| 14 import '../../lib/src/mirrors/analyze.dart' | 14 import '../../lib/src/mirrors/analyze.dart' show analyze; |
| 15 show analyze; | 15 import '../../lib/src/mirrors/dart2js_mirrors.dart' show BackDoor; |
| 16 import '../../lib/src/mirrors/dart2js_mirrors.dart' | |
| 17 show BackDoor; | |
| 18 | 16 |
| 19 import '../../lib/src/filenames.dart'; | 17 import '../../lib/src/filenames.dart'; |
| 20 import '../../lib/src/source_file_provider.dart'; | 18 import '../../lib/src/source_file_provider.dart'; |
| 21 import '../../lib/src/util/uri_extras.dart'; | 19 import '../../lib/src/util/uri_extras.dart'; |
| 22 | 20 |
| 23 const DART2JS = '../../lib/src/dart2js.dart'; | 21 const DART2JS = '../../lib/src/dart2js.dart'; |
| 24 const DART2JS_MIRROR = '../../lib/src/mirrors/dart2js_mirror.dart'; | 22 const DART2JS_MIRROR = '../../lib/src/mirrors/dart2js_mirror.dart'; |
| 25 const SDK_ROOT = '../../../../sdk/'; | 23 const SDK_ROOT = '../../../../sdk/'; |
| 26 | 24 |
| 27 bool isPublicDart2jsLibrary(String name) { | 25 bool isPublicDart2jsLibrary(String name) { |
| 28 return !name.startsWith('_') && libraries[name].isDart2jsLibrary; | 26 return !name.startsWith('_') && libraries[name].isDart2jsLibrary; |
| 29 } | 27 } |
| 30 | 28 |
| 31 var handler; | 29 var handler; |
| 32 RandomAccessFile output; | 30 RandomAccessFile output; |
| 33 Uri outputUri; | 31 Uri outputUri; |
| 34 Uri sdkRoot; | 32 Uri sdkRoot; |
| 35 const bool outputJson = | 33 const bool outputJson = |
| 36 const bool.fromEnvironment('outputJson', defaultValue: false); | 34 const bool.fromEnvironment('outputJson', defaultValue: false); |
| 37 | 35 |
| 38 main(List<String> arguments) { | 36 main(List<String> arguments) { |
| 39 handler = new FormattingDiagnosticHandler() | 37 handler = new FormattingDiagnosticHandler()..throwOnError = true; |
| 40 ..throwOnError = true; | |
| 41 | 38 |
| 42 outputUri = | 39 outputUri = handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); |
| 43 handler.provider.cwd.resolve(nativeToUriPath(arguments.first)); | |
| 44 output = new File(arguments.first).openSync(mode: FileMode.WRITE); | 40 output = new File(arguments.first).openSync(mode: FileMode.WRITE); |
| 45 | 41 |
| 46 Uri myLocation = | 42 Uri myLocation = handler.provider.cwd.resolveUri(Platform.script); |
| 47 handler.provider.cwd.resolveUri(Platform.script); | |
| 48 | 43 |
| 49 Uri packageRoot = | 44 Uri packageRoot = handler.provider.cwd.resolve(Platform.packageRoot); |
| 50 handler.provider.cwd.resolve(Platform.packageRoot); | |
| 51 | 45 |
| 52 Uri libraryRoot = myLocation.resolve(SDK_ROOT); | 46 Uri libraryRoot = myLocation.resolve(SDK_ROOT); |
| 53 | 47 |
| 54 sdkRoot = libraryRoot.resolve('../'); | 48 sdkRoot = libraryRoot.resolve('../'); |
| 55 | 49 |
| 56 // Get the names of public dart2js libraries. | 50 // Get the names of public dart2js libraries. |
| 57 Iterable<String> names = libraries.keys.where(isPublicDart2jsLibrary); | 51 Iterable<String> names = libraries.keys.where(isPublicDart2jsLibrary); |
| 58 | 52 |
| 59 // Turn the names into uris by prepending dart: to them. | 53 // Turn the names into uris by prepending dart: to them. |
| 60 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList(); | 54 List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 80 }); | 74 }); |
| 81 }); | 75 }); |
| 82 | 76 |
| 83 libraries.forEach((name, info) { | 77 libraries.forEach((name, info) { |
| 84 var patch = info.dart2jsPatchPath; | 78 var patch = info.dart2jsPatchPath; |
| 85 if (patch != null) { | 79 if (patch != null) { |
| 86 futures.add(mapUri(sdkRoot.resolve('sdk/lib/$patch'))); | 80 futures.add(mapUri(sdkRoot.resolve('sdk/lib/$patch'))); |
| 87 } | 81 } |
| 88 }); | 82 }); |
| 89 | 83 |
| 90 for (String filename in ["dart_client.platform", | 84 for (String filename in [ |
| 91 "dart_server.platform", | 85 "dart_client.platform", |
| 92 "dart_shared.platform"]) { | 86 "dart_server.platform", |
| 87 "dart_shared.platform" |
| 88 ]) { |
| 93 futures.add(mapUri(sdkRoot.resolve('sdk/lib/$filename'))); | 89 futures.add(mapUri(sdkRoot.resolve('sdk/lib/$filename'))); |
| 94 } | 90 } |
| 95 | 91 |
| 96 Future.wait(futures).then((_) { | 92 Future.wait(futures).then((_) { |
| 97 if (outputJson) { | 93 if (outputJson) { |
| 98 output.writeStringSync(JSON.encode(map)); | 94 output.writeStringSync(JSON.encode(map)); |
| 99 } else { | 95 } else { |
| 100 output.writeStringSync(''' | 96 output.writeStringSync(''' |
| 101 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 97 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 102 // for details. All rights reserved. Use of this source code is governed by a | 98 // for details. All rights reserved. Use of this source code is governed by a |
| 103 // BSD-style license that can be found in the LICENSE file. | 99 // BSD-style license that can be found in the LICENSE file. |
| 104 | 100 |
| 105 // DO NOT EDIT. | 101 // DO NOT EDIT. |
| 106 // This file is generated by jsonify.dart. | 102 // This file is generated by jsonify.dart. |
| 107 | 103 |
| 108 library dart.sdk_sources; | 104 library dart.sdk_sources; |
| 109 | 105 |
| 110 const Map<String, String> SDK_SOURCES = const <String, String>'''); | 106 const Map<String, String> SDK_SOURCES = const <String, String>'''); |
| 111 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); | 107 output.writeStringSync(JSON.encode(map).replaceAll(r'$', r'\$')); |
| 112 output.writeStringSync(';\n'); | 108 output.writeStringSync(';\n'); |
| 113 } | 109 } |
| 114 output.closeSync(); | 110 output.closeSync(); |
| 115 }); | 111 }); |
| 116 } | 112 } |
| OLD | NEW |