| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 /// Command line tool to merge the SDK libraries and our patch files. | 6 /// Command line tool to merge the SDK libraries and our patch files. |
| 7 /// This is currently designed as an offline tool, but we could automate it. | 7 /// This is currently designed as an offline tool, but we could automate it. |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:isolate' show RawReceivePort; | 10 import 'dart:isolate' show RawReceivePort; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 var patchIn = argv[2]; | 87 var patchIn = argv[2]; |
| 88 var outDir = argv[3]; | 88 var outDir = argv[3]; |
| 89 var outDirUri = Uri.base.resolveUri(new Uri.directory(outDir)); | 89 var outDirUri = Uri.base.resolveUri(new Uri.directory(outDir)); |
| 90 var sdkOut = path.join(outDir, 'lib'); | 90 var sdkOut = path.join(outDir, 'lib'); |
| 91 var packagesFile = argv[4]; | 91 var packagesFile = argv[4]; |
| 92 | 92 |
| 93 // Parse libraries.dart | 93 // Parse libraries.dart |
| 94 var libContents = readInputFile(path.join( | 94 var libContents = readInputFile(path.join( |
| 95 sdkLibIn, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart')); | 95 sdkLibIn, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart')); |
| 96 if (forVm) libContents = _updateLibraryMetadata(sdkOut, libContents); | 96 if (forVm) libContents = _updateLibraryMetadata(sdkOut, libContents); |
| 97 var sdkLibraries = _getSdkLibraries(libContents); | 97 var sdkLibraries = _getSdkLibraries(libContents, forDart2js); |
| 98 | 98 |
| 99 Map<String, String> locations = <String, String>{}; | 99 Map<String, String> locations = <String, String>{}; |
| 100 | 100 |
| 101 // Enumerate core libraries and apply patches | 101 // Enumerate core libraries and apply patches |
| 102 for (SdkLibrary library in sdkLibraries) { | 102 for (SdkLibrary library in sdkLibraries) { |
| 103 if (forDart2js && library.isVmLibrary) continue; | 103 if (forDart2js && library.isVmLibrary) continue; |
| 104 if (forVm && library.isDart2JsLibrary) continue; | 104 if (forVm && library.isDart2JsLibrary) continue; |
| 105 _applyPatch(library, sdkLibIn, patchIn, sdkOut, locations); | 105 _applyPatch(library, sdkLibIn, patchIn, sdkOut, locations); |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 617 |
| 618 String toString() => '(Edit @ $begin,$end: "$replace")'; | 618 String toString() => '(Edit @ $begin,$end: "$replace")'; |
| 619 | 619 |
| 620 int compareTo(_StringEdit other) { | 620 int compareTo(_StringEdit other) { |
| 621 int diff = begin - other.begin; | 621 int diff = begin - other.begin; |
| 622 if (diff != 0) return diff; | 622 if (diff != 0) return diff; |
| 623 return end - other.end; | 623 return end - other.end; |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 | 626 |
| 627 List<SdkLibrary> _getSdkLibraries(String contents) { | 627 List<SdkLibrary> _getSdkLibraries(String contents, bool useDart2js) { |
| 628 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); | 628 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(useDart2js); |
| 629 parseCompilationUnit(contents).accept(libraryBuilder); | 629 parseCompilationUnit(contents).accept(libraryBuilder); |
| 630 return libraryBuilder.librariesMap.sdkLibraries; | 630 return libraryBuilder.librariesMap.sdkLibraries; |
| 631 } | 631 } |
| OLD | NEW |