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 25 matching lines...) Expand all Loading... |
36 /// For more information see GN and Ninja references: | 36 /// For more information see GN and Ninja references: |
37 /// https://chromium.googlesource.com/chromium/src/+/56807c6cb383140af0c03da8
f6731d77785d7160/tools/gn/docs/reference.md#depfile_string_File-name-for-input-d
ependencies-for-actions | 37 /// https://chromium.googlesource.com/chromium/src/+/56807c6cb383140af0c03da8
f6731d77785d7160/tools/gn/docs/reference.md#depfile_string_File-name-for-input-d
ependencies-for-actions |
38 /// https://ninja-build.org/manual.html#_depfile | 38 /// https://ninja-build.org/manual.html#_depfile |
39 /// | 39 /// |
40 final deps = new Set<Uri>(); | 40 final deps = new Set<Uri>(); |
41 | 41 |
42 /// Create [File] object from the given path and register it as a dependency. | 42 /// Create [File] object from the given path and register it as a dependency. |
43 File getInputFile(String path, {canBeMissing: false}) { | 43 File getInputFile(String path, {canBeMissing: false}) { |
44 final file = new File(path); | 44 final file = new File(path); |
45 if (!file.existsSync()) { | 45 if (!file.existsSync()) { |
46 if (!canBeMissing) | 46 if (!canBeMissing) throw "patch_sdk.dart expects all inputs to exist"; |
47 throw "patch_sdk.dart expects all inputs to exist, missing: $path"; | |
48 return null; | 47 return null; |
49 } | 48 } |
50 deps.add(Uri.base.resolveUri(file.uri)); | 49 deps.add(Uri.base.resolveUri(file.uri)); |
51 return file; | 50 return file; |
52 } | 51 } |
53 | 52 |
54 /// Read the given file synchronously as a string and register this path as | 53 /// Read the given file synchronously as a string and register this path as |
55 /// a dependency. | 54 /// a dependency. |
56 String readInputFile(String path, {canBeMissing: false}) => | 55 String readInputFile(String path, {canBeMissing: false}) => |
57 getInputFile(path, canBeMissing: canBeMissing)?.readAsStringSync(); | 56 getInputFile(path, canBeMissing: canBeMissing)?.readAsStringSync(); |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); | 822 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); |
824 parseCompilationUnit(contents).accept(libraryBuilder); | 823 parseCompilationUnit(contents).accept(libraryBuilder); |
825 return libraryBuilder.librariesMap.sdkLibraries; | 824 return libraryBuilder.librariesMap.sdkLibraries; |
826 } | 825 } |
827 | 826 |
828 void addLocation(Map<String, Map<String, String>> locations, String libraryName, | 827 void addLocation(Map<String, Map<String, String>> locations, String libraryName, |
829 String libraryPath) { | 828 String libraryPath) { |
830 assert(locations[libraryName] == null); | 829 assert(locations[libraryName] == null); |
831 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'}; | 830 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'}; |
832 } | 831 } |
OLD | NEW |