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; |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 import 'dart:math' as math; | 12 import 'dart:math' as math; |
13 import 'dart:convert' show JSON; | 13 import 'dart:convert' show JSON; |
14 | 14 |
15 import 'package:analyzer/analyzer.dart'; | 15 import 'package:analyzer/analyzer.dart'; |
16 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.dart'; |
17 import 'package:path/path.dart' as path; | 17 import 'package:path/path.dart' as path; |
18 | 18 |
19 import 'package:front_end/front_end.dart'; | 19 import 'package:front_end/front_end.dart'; |
| 20 |
| 21 import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
| 22 |
20 import 'package:front_end/src/base/processed_options.dart'; | 23 import 'package:front_end/src/base/processed_options.dart'; |
21 import 'package:front_end/src/kernel_generator_impl.dart'; | 24 import 'package:front_end/src/kernel_generator_impl.dart'; |
22 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri; | 25 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri; |
23 | 26 |
24 import 'package:front_end/src/fasta/fasta.dart' as fasta show getDependencies; | 27 import 'package:front_end/src/fasta/get_dependencies.dart' show getDependencies; |
25 import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile; | 28 import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile; |
26 | 29 |
27 import 'package:kernel/target/targets.dart'; | 30 import 'package:kernel/target/targets.dart'; |
28 import 'package:kernel/target/vm_fasta.dart'; | 31 import 'package:kernel/target/vm_fasta.dart'; |
29 import 'package:kernel/target/flutter_fasta.dart'; | 32 import 'package:kernel/target/flutter_fasta.dart'; |
30 import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget; | 33 import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget; |
31 | 34 |
32 /// Set of input files that were read by this script to generate patched SDK. | 35 /// Set of input files that were read by this script to generate patched SDK. |
33 /// We will dump it out into the depfile for ninja to use. | 36 /// We will dump it out into the depfile for ninja to use. |
34 /// | 37 /// |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // [platformForDeps] is always the VM-specific `platform.dill` file. | 202 // [platformForDeps] is always the VM-specific `platform.dill` file. |
200 var platformForDeps = platform; | 203 var platformForDeps = platform; |
201 var sdkDir = outDirUri; | 204 var sdkDir = outDirUri; |
202 if (forDart2js || forFlutter) { | 205 if (forDart2js || forFlutter) { |
203 // Note: this would fail if `../patched_sdk/platform.dill` doesn't exist. We | 206 // Note: this would fail if `../patched_sdk/platform.dill` doesn't exist. We |
204 // added an explicit dependency in the .GN rules so patched_dart2js_sdk (and | 207 // added an explicit dependency in the .GN rules so patched_dart2js_sdk (and |
205 // patched_flutter_sdk) depend on patched_sdk to ensure that it exists. | 208 // patched_flutter_sdk) depend on patched_sdk to ensure that it exists. |
206 platformForDeps = outDirUri.resolve('../patched_sdk/platform.dill'); | 209 platformForDeps = outDirUri.resolve('../patched_sdk/platform.dill'); |
207 sdkDir = outDirUri.resolve('../patched_sdk/'); | 210 sdkDir = outDirUri.resolve('../patched_sdk/'); |
208 } | 211 } |
209 deps.addAll(await fasta.getDependencies(Platform.script, | 212 deps.addAll(await getDependencies( |
| 213 Platform.script, PhysicalFileSystem.instance, |
210 sdk: sdkDir, packages: packages, platform: platformForDeps)); | 214 sdk: sdkDir, packages: packages, platform: platformForDeps)); |
211 await writeDepsFile(platformFinalLocation, | 215 await writeDepsFile(platformFinalLocation, |
212 Uri.base.resolveUri(new Uri.file("$outDir.d")), deps); | 216 Uri.base.resolveUri(new Uri.file("$outDir.d")), deps); |
213 await new File.fromUri(platform).rename(platformFinalLocation.toFilePath()); | 217 await new File.fromUri(platform).rename(platformFinalLocation.toFilePath()); |
214 } | 218 } |
215 | 219 |
216 /// Generates an outline.dill and platform.dill file containing the result of | 220 /// Generates an outline.dill and platform.dill file containing the result of |
217 /// compiling a platform's SDK. | 221 /// compiling a platform's SDK. |
218 /// | 222 /// |
219 /// Returns a list of dependencies read by the compiler. This list can be used | 223 /// Returns a list of dependencies read by the compiler. This list can be used |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); | 825 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); |
822 parseCompilationUnit(contents).accept(libraryBuilder); | 826 parseCompilationUnit(contents).accept(libraryBuilder); |
823 return libraryBuilder.librariesMap.sdkLibraries; | 827 return libraryBuilder.librariesMap.sdkLibraries; |
824 } | 828 } |
825 | 829 |
826 void addLocation(Map<String, Map<String, String>> locations, String libraryName, | 830 void addLocation(Map<String, Map<String, String>> locations, String libraryName, |
827 String libraryPath) { | 831 String libraryPath) { |
828 assert(locations[libraryName] == null); | 832 assert(locations[libraryName] == null); |
829 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'}; | 833 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'}; |
830 } | 834 } |
OLD | NEW |