| 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:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 for (SdkLibrary library in sdkLibraries) { | 103 for (SdkLibrary library in sdkLibraries) { |
| 104 // TODO(jmesserly): analyzer does not handle the default case of | 104 // TODO(jmesserly): analyzer does not handle the default case of |
| 105 // "both platforms" correctly, and treats it as being supported on neither. | 105 // "both platforms" correctly, and treats it as being supported on neither. |
| 106 // So instead we skip explicitly marked as either VM or dart2js libs. | 106 // So instead we skip explicitly marked as either VM or dart2js libs. |
| 107 if (mode == 'ddc' ? libary.isVmLibrary : library.isDart2JsLibrary) { | 107 if (mode == 'ddc' ? libary.isVmLibrary : library.isDart2JsLibrary) { |
| 108 continue; | 108 continue; |
| 109 } | 109 } |
| 110 | 110 |
| 111 var libraryOut = path.join(sdkLibIn, library.path); | 111 var libraryOut = path.join(sdkLibIn, library.path); |
| 112 var libraryIn; | 112 var libraryIn; |
| 113 if (mode == 'ddc' && library.path.contains(INTERNAL_PATH)) { | 113 if (mode == 'vm' && library.path.contains('typed_data.dart')) { |
| 114 // dart:typed_data is unlike the other libraries in the SDK. The VM does |
| 115 // not apply a patch to the base SDK implementation of the library. |
| 116 // Instead, the VM provides a replacement implementation and ignores the |
| 117 // sources in the SDK. |
| 118 libraryIn = |
| 119 path.join(dartDir, 'runtime', 'lib', 'typed_data.dart'); |
| 120 } else if (mode == 'ddc' && library.path.contains(INTERNAL_PATH)) { |
| 114 libraryIn = | 121 libraryIn = |
| 115 path.join(privateIn, library.path.replaceAll(INTERNAL_PATH, '')); | 122 path.join(privateIn, library.path.replaceAll(INTERNAL_PATH, '')); |
| 116 } else { | 123 } else { |
| 117 libraryIn = libraryOut; | 124 libraryIn = libraryOut; |
| 118 } | 125 } |
| 119 | 126 |
| 120 var libraryFile = new File(libraryIn); | 127 var libraryFile = new File(libraryIn); |
| 121 if (libraryFile.existsSync()) { | 128 if (libraryFile.existsSync()) { |
| 122 var outPaths = <String>[libraryOut]; | 129 var outPaths = <String>[libraryOut]; |
| 123 var libraryContents = libraryFile.readAsStringSync(); | 130 var libraryContents = libraryFile.readAsStringSync(); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 if (diff != 0) return diff; | 527 if (diff != 0) return diff; |
| 521 return end - other.end; | 528 return end - other.end; |
| 522 } | 529 } |
| 523 } | 530 } |
| 524 | 531 |
| 525 List<SdkLibrary> _getSdkLibraries(String contents) { | 532 List<SdkLibrary> _getSdkLibraries(String contents) { |
| 526 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); | 533 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); |
| 527 parseCompilationUnit(contents).accept(libraryBuilder); | 534 parseCompilationUnit(contents).accept(libraryBuilder); |
| 528 return libraryBuilder.librariesMap.sdkLibraries; | 535 return libraryBuilder.librariesMap.sdkLibraries; |
| 529 } | 536 } |
| OLD | NEW |