| Index: tools/patch_sdk.dart
|
| diff --git a/tools/patch_sdk.dart b/tools/patch_sdk.dart
|
| index 5aa3c53332c443174a69ec481633535b39a5a52d..1f64d6366c39473b448b33820cc244678c46b033 100644
|
| --- a/tools/patch_sdk.dart
|
| +++ b/tools/patch_sdk.dart
|
| @@ -7,22 +7,16 @@
|
| /// This is currently designed as an offline tool, but we could automate it.
|
|
|
| import 'dart:io';
|
| +import 'dart:isolate' show RawReceivePort;
|
| import 'dart:async';
|
| import 'dart:math' as math;
|
|
|
| import 'package:analyzer/analyzer.dart';
|
| import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:path/path.dart' as path;
|
| -import 'package:front_end/src/fasta/compile_platform.dart' as compile_platform;
|
|
|
| -import 'package:front_end/src/fasta/fasta.dart' show CompileTask;
|
| -
|
| -import 'package:front_end/src/fasta/compiler_command_line.dart'
|
| - show CompilerCommandLine;
|
| -
|
| -import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
|
| -
|
| -import 'package:front_end/src/fasta/ticker.dart' show Ticker;
|
| +import 'package:front_end/src/fasta/fasta.dart'
|
| + show compilePlatform, writeDepsFile;
|
|
|
| /// Set of input files that were read by this script to generate patched SDK.
|
| /// We will dump it out into the depfile for ninja to use.
|
| @@ -31,7 +25,7 @@ import 'package:front_end/src/fasta/ticker.dart' show Ticker;
|
| /// https://chromium.googlesource.com/chromium/src/+/56807c6cb383140af0c03da8f6731d77785d7160/tools/gn/docs/reference.md#depfile_string_File-name-for-input-dependencies-for-actions
|
| /// https://ninja-build.org/manual.html#_depfile
|
| ///
|
| -final deps = new Set<String>();
|
| +final deps = new Set<Uri>();
|
|
|
| /// Create [File] object from the given path and register it as a dependency.
|
| File getInputFile(String path, {canBeMissing: false}) {
|
| @@ -40,7 +34,7 @@ File getInputFile(String path, {canBeMissing: false}) {
|
| if (!canBeMissing) throw "patch_sdk.dart expects all inputs to exist";
|
| return null;
|
| }
|
| - deps.add(file.absolute.path);
|
| + deps.add(Uri.base.resolveUri(file.uri));
|
| return file;
|
| }
|
|
|
| @@ -50,6 +44,15 @@ String readInputFile(String path, {canBeMissing: false}) =>
|
| getInputFile(path, canBeMissing: canBeMissing)?.readAsStringSync();
|
|
|
| Future main(List<String> argv) async {
|
| + var port = new RawReceivePort();
|
| + try {
|
| + await _main(argv);
|
| + } finally {
|
| + port.close();
|
| + }
|
| +}
|
| +
|
| +Future _main(List<String> argv) async {
|
| var base = path.fromUri(Platform.script);
|
| var dartDir = path.dirname(path.dirname(path.absolute(base)));
|
|
|
| @@ -208,64 +211,24 @@ Future main(List<String> argv) async {
|
| _writeSync(libraryOut, readInputFile(libraryIn));
|
| }
|
|
|
| - final platform = path.join(outDir, 'platform.dill');
|
| + Uri platform = Uri.base
|
| + .resolveUri(new Uri.directory(outDir).resolve('platform.dill.tmp'));
|
| + Uri packages = Uri.base.resolveUri(new Uri.file(packagesFile));
|
| + await compilePlatform(
|
| + Uri.base.resolveUri(new Uri.directory(outDir)), platform,
|
| + packages: packages, verbose: false);
|
|
|
| - await compile_platform.mainEntryPoint(<String>[
|
| - '--packages',
|
| - new Uri.file(packagesFile).toString(),
|
| - new Uri.directory(outDir).toString(),
|
| - platform,
|
| - ]);
|
| + Uri platformFinalLocation =
|
| + Uri.base.resolveUri(new Uri.directory(outDir).resolve('platform.dill'));
|
|
|
| - // TODO(kustermann): We suppress compiler hints/warnings/errors temporarily
|
| - // because everyone building the `runtime` target will get these now.
|
| - // We should remove the suppression again once the underlying issues have
|
| - // been fixed (either in fasta or the dart files in the patched_sdk).
|
| - final capturedLines = <String>[];
|
| - try {
|
| - await runZoned(() async {
|
| - // platform.dill was generated, now generate platform.dill.d depfile
|
| - // that captures all dependencies that participated in the generation.
|
| - // There are two types of dependencies:
|
| - // (1) all Dart sources that constitute this tool itself
|
| - // (2) Dart SDK and patch sources.
|
| - // We already collected all inputs from the second category in the deps
|
| - // set. To collect inputs from the first category we actually use Fasta:
|
| - // we ask Fasta to outline patch_sdk.dart and generate a depfile which
|
| - // would list all the sources.
|
| - final depfile = "${outDir}.d";
|
| - await CompilerCommandLine.withGlobalOptions("outline", [
|
| - '--packages',
|
| - new Uri.file(packagesFile).toString(),
|
| - '--platform',
|
| - new Uri.file(platform).toString(), // platform.dill
|
| - Platform.script.toString() // patch_sdk.dart
|
| - ], (CompilerContext c) async {
|
| - CompileTask task =
|
| - new CompileTask(c, new Ticker(isVerbose: c.options.verbose));
|
| - final kernelTarget = await task.buildOutline(null);
|
| - await kernelTarget.writeDepsFile(
|
| - new Uri.file(platform), new Uri.file(depfile));
|
| - });
|
| -
|
| - // Read depfile generated by Fasta and append deps that we have collected
|
| - // during generation of patched_sdk to it.
|
| - // Note: we are splitting by ': ' because Windows paths can start with
|
| - // drive letter followed by a colon.
|
| - final list = new File(depfile).readAsStringSync().split(': ');
|
| - assert(list.length == 2);
|
| - deps.addAll(list[1].split(' ').where((str) => str.isNotEmpty));
|
| - assert(list[0] == path.join('patched_sdk', 'platform.dill'));
|
| - new File(depfile).writeAsStringSync("${list[0]}: ${deps.join(' ')}\n");
|
| - }, zoneSpecification: new ZoneSpecification(print: (_, _2, _3, line) {
|
| - capturedLines.add(line);
|
| - }));
|
| - } catch (_) {
|
| - for (final line in capturedLines) {
|
| - print(line);
|
| - }
|
| - rethrow;
|
| - }
|
| + await writeDepsFile(Platform.script,
|
| + Uri.base.resolveUri(new Uri.file("$outDir.d")), platformFinalLocation,
|
| + packages: packages,
|
| + platform: platform,
|
| + extraDependencies: deps,
|
| + verbose: false);
|
| +
|
| + await new File.fromUri(platform).rename(platformFinalLocation.toFilePath());
|
| }
|
|
|
| /// Writes a file, creating the directory if needed.
|
|
|