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

Side by Side Diff: tools/patch_sdk.dart

Issue 2938903003: Add a vmservice_sdk directory in runtime/bin. (Closed)
Patch Set: Compile dart:vmservice_io only if forVm Created 3 years, 6 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
« no previous file with comments | « runtime/bin/vmservice_sdk/lib/libraries.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 Uri platform = outDirUri.resolve('platform.dill.tmp'); 114 Uri platform = outDirUri.resolve('platform.dill.tmp');
115 Uri outline = outDirUri.resolve('outline.dill'); 115 Uri outline = outDirUri.resolve('outline.dill');
116 Uri librariesJson = outDirUri.resolve("lib/libraries.json"); 116 Uri librariesJson = outDirUri.resolve("lib/libraries.json");
117 Uri packages = Uri.base.resolveUri(new Uri.file(packagesFile)); 117 Uri packages = Uri.base.resolveUri(new Uri.file(packagesFile));
118 118
119 await _writeSync( 119 await _writeSync(
120 librariesJson.toFilePath(), JSON.encode({"libraries": locations})); 120 librariesJson.toFilePath(), JSON.encode({"libraries": locations}));
121 121
122 if (forVm || forFlutter) { 122 if (forVm || forFlutter) {
123 var vmserviceName = forVm ? 'vmservice_io' : 'vmservice_sky';
124 var targetName = forVm ? 'vm_fasta' : 'flutter_fasta';
125 Uri vmserviceUri = outDirUri.resolve('$vmserviceName.dill');
126 await fasta.compilePlatform(outDirUri, platform, 123 await fasta.compilePlatform(outDirUri, platform,
127 packages: packages, 124 packages: packages,
128 outlineOutput: outline, 125 outlineOutput: outline,
129 backendTarget: forVm ? 'vm_fasta' : 'flutter_fasta'); 126 backendTarget: forVm ? 'vm_fasta' : 'flutter_fasta');
127 } else {
128 await dart2js.compilePlatform(outDirUri, platform,
129 packages: packages, outlineOutput: outline);
130 }
131
132 if (forVm) {
133 var base = path.fromUri(Platform.script);
134 Uri repositoryDir =
135 new Uri.directory(path.dirname(path.dirname(path.absolute(base))));
136 var vmserviceName = 'vmservice_io';
137 Uri vmserviceSdk = repositoryDir.resolve('runtime/bin/vmservice_sdk/');
138 Uri vmserviceUri = outDirUri.resolve('$vmserviceName.dill');
139 // TODO(sigmundch): Specify libraries.json directly instead of "--sdk"
140 // after #29882 is fixed.
130 await fasta.compile([ 141 await fasta.compile([
131 "--sdk=$outDirUri", 142 "--sdk=$vmserviceSdk",
132 "--platform=$outline", 143 "--platform=$outline",
133 "--target=$targetName", 144 "--target=vm_fasta",
134 "--packages=$packages", 145 "--packages=$packages",
135 "dart:$vmserviceName", 146 "dart:$vmserviceName",
136 "-o", 147 "-o",
137 "$vmserviceUri", 148 "$vmserviceUri",
138 ]); 149 ]);
139 } else {
140 await dart2js.compilePlatform(outDirUri, platform,
141 packages: packages, outlineOutput: outline);
142 } 150 }
143 151
144 Uri platformFinalLocation = outDirUri.resolve('platform.dill'); 152 Uri platformFinalLocation = outDirUri.resolve('platform.dill');
145 153
146 // We generate a dependency file for GN to properly regenerate the patched sdk 154 // We generate a dependency file for GN to properly regenerate the patched sdk
147 // folder, outline.dill and platform.dill files when necessary: either when 155 // folder, outline.dill and platform.dill files when necessary: either when
148 // the sdk sources change or when this script is updated. In particular: 156 // the sdk sources change or when this script is updated. In particular:
149 // 157 //
150 // - sdk changes: we track the actual sources we are compiling. If we are 158 // - sdk changes: we track the actual sources we are compiling. If we are
151 // building the dart2js sdk, this includes the dart2js-specific patch 159 // building the dart2js sdk, this includes the dart2js-specific patch
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 _copyExtraLibraries(String sdkOut, Map<String, String> locations) { 244 _copyExtraLibraries(String sdkOut, Map<String, String> locations) {
237 if (forDart2js) return; 245 if (forDart2js) return;
238 var base = path.fromUri(Platform.script); 246 var base = path.fromUri(Platform.script);
239 var dartDir = path.dirname(path.dirname(path.absolute(base))); 247 var dartDir = path.dirname(path.dirname(path.absolute(base)));
240 248
241 var builtinLibraryIn = path.join(dartDir, 'runtime', 'bin', 'builtin.dart'); 249 var builtinLibraryIn = path.join(dartDir, 'runtime', 'bin', 'builtin.dart');
242 var builtinLibraryOut = path.join(sdkOut, '_builtin', '_builtin.dart'); 250 var builtinLibraryOut = path.join(sdkOut, '_builtin', '_builtin.dart');
243 _writeSync(builtinLibraryOut, readInputFile(builtinLibraryIn)); 251 _writeSync(builtinLibraryOut, readInputFile(builtinLibraryIn));
244 locations['_builtin'] = path.join('_builtin', '_builtin.dart'); 252 locations['_builtin'] = path.join('_builtin', '_builtin.dart');
245 253
246 for (var file in ['loader.dart', 'server.dart', 'vmservice_io.dart']) {
247 var libraryIn = path.join(dartDir, 'runtime', 'bin', 'vmservice', file);
248 var libraryOut = path.join(sdkOut, 'vmservice_io', file);
249 _writeSync(libraryOut, readInputFile(libraryIn));
250 }
251
252 locations[forVm ? "vmservice_io" : "vmservice_sky"] =
253 path.join('vmservice_io', 'vmservice_io.dart');
254 locations["_vmservice"] = path.join('vmservice', 'vmservice.dart');
255
256 if (forFlutter) { 254 if (forFlutter) {
257 // Flutter repo has this layout: 255 // Flutter repo has this layout:
258 // engine/src/ 256 // engine/src/
259 // dart/ 257 // dart/
260 // flutter/ 258 // flutter/
261 var srcDir = path.dirname(path.dirname(path.dirname(path.absolute(base)))); 259 var srcDir = path.dirname(path.dirname(path.dirname(path.absolute(base))));
262 var uiLibraryInDir = path.join(srcDir, 'flutter', 'lib', 'ui'); 260 var uiLibraryInDir = path.join(srcDir, 'flutter', 'lib', 'ui');
263 for (var file in new Directory(uiLibraryInDir).listSync()) { 261 for (var file in new Directory(uiLibraryInDir).listSync()) {
264 if (!file.path.endsWith('.dart')) continue; 262 if (!file.path.endsWith('.dart')) continue;
265 var name = path.basename(file.path); 263 var name = path.basename(file.path);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 if (diff != 0) return diff; 674 if (diff != 0) return diff;
677 return end - other.end; 675 return end - other.end;
678 } 676 }
679 } 677 }
680 678
681 List<SdkLibrary> _getSdkLibraries(String contents) { 679 List<SdkLibrary> _getSdkLibraries(String contents) {
682 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); 680 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js);
683 parseCompilationUnit(contents).accept(libraryBuilder); 681 parseCompilationUnit(contents).accept(libraryBuilder);
684 return libraryBuilder.librariesMap.sdkLibraries; 682 return libraryBuilder.librariesMap.sdkLibraries;
685 } 683 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice_sdk/lib/libraries.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698