Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: tools/patch_sdk.dart

Issue 3003743002: Move tools to tool folder. (Closed)
Patch Set: Fix two problems that show up elsewhere. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
20 import 'package:front_end/src/base/processed_options.dart'; 21 import 'package:front_end/src/base/processed_options.dart';
21 import 'package:front_end/src/kernel_generator_impl.dart'; 22 import 'package:front_end/src/kernel_generator_impl.dart';
22 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri; 23 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
23 24
24 import 'package:front_end/src/fasta/fasta.dart' as fasta show getDependencies; 25 import 'package:front_end/src/fasta/get_dependencies.dart' show getDependencies;
25 import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile; 26 import 'package:front_end/src/fasta/kernel/utils.dart' show writeProgramToFile;
26 27
27 import 'package:kernel/target/targets.dart'; 28 import 'package:kernel/target/targets.dart';
28 import 'package:kernel/target/vm_fasta.dart'; 29 import 'package:kernel/target/vm_fasta.dart';
29 import 'package:kernel/target/flutter_fasta.dart'; 30 import 'package:kernel/target/flutter_fasta.dart';
30 import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget; 31 import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget;
31 32
32 /// Set of input files that were read by this script to generate patched SDK. 33 /// 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. 34 /// We will dump it out into the depfile for ninja to use.
34 /// 35 ///
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // [platformForDeps] is always the VM-specific `platform.dill` file. 200 // [platformForDeps] is always the VM-specific `platform.dill` file.
200 var platformForDeps = platform; 201 var platformForDeps = platform;
201 var sdkDir = outDirUri; 202 var sdkDir = outDirUri;
202 if (forDart2js || forFlutter) { 203 if (forDart2js || forFlutter) {
203 // Note: this would fail if `../patched_sdk/platform.dill` doesn't exist. We 204 // 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 205 // 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. 206 // patched_flutter_sdk) depend on patched_sdk to ensure that it exists.
206 platformForDeps = outDirUri.resolve('../patched_sdk/platform.dill'); 207 platformForDeps = outDirUri.resolve('../patched_sdk/platform.dill');
207 sdkDir = outDirUri.resolve('../patched_sdk/'); 208 sdkDir = outDirUri.resolve('../patched_sdk/');
208 } 209 }
209 deps.addAll(await fasta.getDependencies(Platform.script, 210 deps.addAll(await getDependencies(Platform.script,
210 sdk: sdkDir, packages: packages, platform: platformForDeps)); 211 sdk: sdkDir, packages: packages, platform: platformForDeps));
211 await writeDepsFile(platformFinalLocation, 212 await writeDepsFile(platformFinalLocation,
212 Uri.base.resolveUri(new Uri.file("$outDir.d")), deps); 213 Uri.base.resolveUri(new Uri.file("$outDir.d")), deps);
213 await new File.fromUri(platform).rename(platformFinalLocation.toFilePath()); 214 await new File.fromUri(platform).rename(platformFinalLocation.toFilePath());
214 } 215 }
215 216
216 /// Generates an outline.dill and platform.dill file containing the result of 217 /// Generates an outline.dill and platform.dill file containing the result of
217 /// compiling a platform's SDK. 218 /// compiling a platform's SDK.
218 /// 219 ///
219 /// Returns a list of dependencies read by the compiler. This list can be used 220 /// 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
821 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); 822 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js);
822 parseCompilationUnit(contents).accept(libraryBuilder); 823 parseCompilationUnit(contents).accept(libraryBuilder);
823 return libraryBuilder.librariesMap.sdkLibraries; 824 return libraryBuilder.librariesMap.sdkLibraries;
824 } 825 }
825 826
826 void addLocation(Map<String, Map<String, String>> locations, String libraryName, 827 void addLocation(Map<String, Map<String, String>> locations, String libraryName,
827 String libraryPath) { 828 String libraryPath) {
828 assert(locations[libraryName] == null); 829 assert(locations[libraryName] == null);
829 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'}; 830 locations[libraryName] = {'uri': '${path.toUri(libraryPath)}'};
830 } 831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698