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

Unified Diff: tools/patch_sdk.dart

Issue 2895983002: Read SDK and patches from a JSON file. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: tools/patch_sdk.dart
diff --git a/tools/patch_sdk.dart b/tools/patch_sdk.dart
index 633d76290e6e4c65e6ac5331b3c51a589dab567e..2feead9f779ea63bdc04ae6720afeaa0545de0ef 100644
--- a/tools/patch_sdk.dart
+++ b/tools/patch_sdk.dart
@@ -10,6 +10,7 @@ import 'dart:io';
import 'dart:isolate' show RawReceivePort;
import 'dart:async';
import 'dart:math' as math;
+import 'dart:convert' show JSON;
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/sdk.dart';
@@ -95,18 +96,25 @@ Future _main(List<String> argv) async {
if (forVm) libContents = _updateLibraryMetadata(sdkOut, libContents);
var sdkLibraries = _getSdkLibraries(libContents);
+ Map<String, String> locations = <String, String>{};
+
// Enumerate core libraries and apply patches
for (SdkLibrary library in sdkLibraries) {
if (forDart2js && library.isVmLibrary) continue;
if (forVm && library.isDart2JsLibrary) continue;
- _applyPatch(library, sdkLibIn, patchIn, sdkOut);
+ _applyPatch(library, sdkLibIn, patchIn, sdkOut, locations);
}
- if (forVm) _copyExtraVmLibraries(sdkOut);
+ if (forVm) _copyExtraVmLibraries(sdkOut, locations);
Uri platform = outDirUri.resolve('platform.dill.tmp');
Uri outline = outDirUri.resolve('outline.dill');
+ Uri librariesJson = outDirUri.resolve("lib/libraries.json");
Uri packages = Uri.base.resolveUri(new Uri.file(packagesFile));
+
+ await _writeSync(
+ librariesJson.toFilePath(), JSON.encode({"libraries": locations}));
+
if (forVm) {
await fasta.compilePlatform(outDirUri, platform,
packages: packages, outlineOutput: outline);
@@ -131,11 +139,11 @@ Future _main(List<String> argv) async {
// patched_dart2js_sdk to patched_sdk to ensure that file already exists.
await fasta.writeDepsFile(Platform.script,
Uri.base.resolveUri(new Uri.file("$outDir.d")), platformFinalLocation,
+ sdk: outDirUri,
packages: packages,
platform:
forVm ? platform : outDirUri.resolve('../patched_sdk/platform.dill'),
- extraDependencies: deps,
- verbose: false);
+ extraDependencies: deps);
await new File.fromUri(platform).rename(platformFinalLocation.toFilePath());
}
@@ -183,7 +191,7 @@ String _updateLibraryMetadata(String sdkOut, String libContents) {
/// Copy internal libraries that are developed under 'runtime/bin/' to the
/// patched_sdk folder.
-_copyExtraVmLibraries(String sdkOut) {
+_copyExtraVmLibraries(String sdkOut, Map<String, String> locations) {
var base = path.fromUri(Platform.script);
var dartDir = path.dirname(path.dirname(path.absolute(base)));
@@ -197,6 +205,7 @@ _copyExtraVmLibraries(String sdkOut) {
var builtinLibraryIn = path.join(dartDir, 'runtime', 'bin', dartFile);
var builtinLibraryOut = path.join(sdkOut, vmLibrary, '${vmLibrary}.dart');
_writeSync(builtinLibraryOut, readInputFile(builtinLibraryIn));
+ locations[vmLibrary] = path.join(vmLibrary, '${vmLibrary}.dart');
}
for (var file in ['loader.dart', 'server.dart', 'vmservice_io.dart']) {
@@ -204,15 +213,18 @@ _copyExtraVmLibraries(String sdkOut) {
var libraryOut = path.join(sdkOut, 'vmservice_io', file);
_writeSync(libraryOut, readInputFile(libraryIn));
}
+ locations["vmservice_io"] = "vmservice_io/vmservice_io.dart";
}
-_applyPatch(
- SdkLibrary library, String sdkLibIn, String patchIn, String sdkOut) {
+_applyPatch(SdkLibrary library, String sdkLibIn, String patchIn, String sdkOut,
+ Map<String, String> locations) {
var libraryOut = path.join(sdkLibIn, library.path);
var libraryIn = libraryOut;
var libraryFile = getInputFile(libraryIn, canBeMissing: true);
if (libraryFile != null) {
+ locations[Uri.parse(library.shortName).path] =
+ path.relative(libraryOut, from: sdkLibIn);
var outPaths = <String>[libraryOut];
var libraryContents = libraryFile.readAsStringSync();

Powered by Google App Engine
This is Rietveld 408576698