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

Side by Side Diff: tools/patch_sdk.dart

Issue 2972323002: Add 'flutter_release' patch_sdk mode to patch_sdk (Closed)
Patch Set: Added TODO Created 3 years, 5 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 | « no previous file | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 path.join(repositoryDir, 'out', 'DebugX64', 'obj', 'gen', 'patch')); 74 path.join(repositoryDir, 'out', 'DebugX64', 'obj', 'gen', 'patch'));
75 final outExample = path.relative( 75 final outExample = path.relative(
76 path.join(repositoryDir, 'out', 'DebugX64', 'obj', 'gen', 'patched_sdk')); 76 path.join(repositoryDir, 'out', 'DebugX64', 'obj', 'gen', 'patched_sdk'));
77 final packagesExample = path.relative(path.join(repositoryDir, '.packages')); 77 final packagesExample = path.relative(path.join(repositoryDir, '.packages'));
78 print('For example:'); 78 print('For example:');
79 print('\$ $self vm $sdkExample $patchExample $outExample $packagesExample'); 79 print('\$ $self vm $sdkExample $patchExample $outExample $packagesExample');
80 80
81 exit(1); 81 exit(1);
82 } 82 }
83 83
84 const validModes = const ['vm', 'dart2js', 'flutter']; 84 const validModes = const ['vm', 'dart2js', 'flutter', 'flutter_release'];
85 String mode; 85 String mode;
86 bool get forVm => mode == 'vm'; 86 bool get forVm => mode == 'vm';
87 bool get forFlutter => mode == 'flutter'; 87 bool get forFlutter => mode == 'flutter' || mode == 'flutter_release';
88 bool get forFlutterRelease => mode == 'flutter_release';
88 bool get forDart2js => mode == 'dart2js'; 89 bool get forDart2js => mode == 'dart2js';
89 90
90 Future _main(List<String> argv) async { 91 Future _main(List<String> argv) async {
91 if (argv.isEmpty) usage('[${validModes.join('|')}]'); 92 if (argv.isEmpty) usage('[${validModes.join('|')}]');
92 mode = argv.first; 93 mode = argv.first;
93 if (!validModes.contains(mode)) usage('[${validModes.join('|')}]'); 94 if (!validModes.contains(mode)) usage('[${validModes.join('|')}]');
94 if (argv.length != 5) usage(mode); 95 if (argv.length != 5) usage(mode);
95 96
96 var input = argv[1]; 97 var input = argv[1];
97 var sdkLibIn = path.join(input, 'lib'); 98 var sdkLibIn = path.join(input, 'lib');
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Future<List<Uri>> compilePlatform(Uri patchedSdk, Target target, Uri packages, 205 Future<List<Uri>> compilePlatform(Uri patchedSdk, Target target, Uri packages,
205 Uri fullOutput, Uri outlineOutput) async { 206 Uri fullOutput, Uri outlineOutput) async {
206 var options = new CompilerOptions() 207 var options = new CompilerOptions()
207 ..strongMode = false 208 ..strongMode = false
208 ..compileSdk = true 209 ..compileSdk = true
209 ..sdkRoot = patchedSdk 210 ..sdkRoot = patchedSdk
210 ..packagesFileUri = packages 211 ..packagesFileUri = packages
211 ..chaseDependencies = true 212 ..chaseDependencies = true
212 ..target = target; 213 ..target = target;
213 214
215 var inputs = [Uri.parse('dart:core')];
216 if (forFlutter && !forFlutterRelease) {
217 inputs.add(Uri.parse('dart:vmservice_sky'));
218 }
214 var result = await generateKernel( 219 var result = await generateKernel(
215 new ProcessedOptions( 220 new ProcessedOptions(
216 options, 221 options,
217 // TODO(sigmund): pass all sdk libraries needed here, and make this 222 // TODO(sigmund): pass all sdk libraries needed here, and make this
218 // hermetic. 223 // hermetic.
219 false, 224 false,
220 [Uri.parse('dart:core')]), 225 inputs),
221 buildSummary: true, 226 buildSummary: true,
222 buildProgram: true); 227 buildProgram: true);
223 new File.fromUri(outlineOutput).writeAsBytesSync(result.summary); 228 new File.fromUri(outlineOutput).writeAsBytesSync(result.summary);
224 await writeProgramToFile(result.program, fullOutput); 229 await writeProgramToFile(result.program, fullOutput);
225 return result.deps; 230 return result.deps;
226 } 231 }
227 232
228 Future writeDepsFile( 233 Future writeDepsFile(
229 Uri output, Uri depsFile, Iterable<Uri> allDependencies) async { 234 Uri output, Uri depsFile, Iterable<Uri> allDependencies) async {
230 if (allDependencies.isEmpty) return; 235 if (allDependencies.isEmpty) return;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 290
286 if (forFlutter) { 291 if (forFlutter) {
287 extraLibraries.write(''' 292 extraLibraries.write('''
288 "ui": const LibraryInfo( 293 "ui": const LibraryInfo(
289 "ui/ui.dart", 294 "ui/ui.dart",
290 categories: "Client,Server", 295 categories: "Client,Server",
291 implementation: true, 296 implementation: true,
292 documented: false, 297 documented: false,
293 platforms: VM_PLATFORM), 298 platforms: VM_PLATFORM),
294 '''); 299 ''');
300
301 if (!forFlutterRelease) {
302 // vmservice should be present unless we build release flavor of Flutter.
303 extraLibraries.write('''
304 "_vmservice": const LibraryInfo(
305 "vmservice/vmservice.dart",
306 categories: "Client,Server",
307 implementation: true,
308 documented: false,
309 platforms: VM_PLATFORM),
310
311 "vmservice_sky": const LibraryInfo(
312 "vmservice_sky/vmservice_io.dart",
313 categories: "Client,Server",
314 implementation: true,
315 documented: false,
316 platforms: VM_PLATFORM),
317
318 ''');
319 }
295 } 320 }
296 321
297 libContents = libContents.replaceAll( 322 libContents = libContents.replaceAll(
298 ' libraries = const {', ' libraries = const { $extraLibraries'); 323 ' libraries = const {', ' libraries = const { $extraLibraries');
299 _writeSync( 324 _writeSync(
300 path.join( 325 path.join(
301 sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'), 326 sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'),
302 libContents); 327 libContents);
303 return libContents; 328 return libContents;
304 } 329 }
(...skipping 18 matching lines...) Expand all
323 // flutter/ 348 // flutter/
324 var srcDir = path.dirname(path.dirname(path.dirname(path.absolute(base)))); 349 var srcDir = path.dirname(path.dirname(path.dirname(path.absolute(base))));
325 var uiLibraryInDir = path.join(srcDir, 'flutter', 'lib', 'ui'); 350 var uiLibraryInDir = path.join(srcDir, 'flutter', 'lib', 'ui');
326 for (var file in new Directory(uiLibraryInDir).listSync()) { 351 for (var file in new Directory(uiLibraryInDir).listSync()) {
327 if (!file.path.endsWith('.dart')) continue; 352 if (!file.path.endsWith('.dart')) continue;
328 var name = path.basename(file.path); 353 var name = path.basename(file.path);
329 var uiLibraryOut = path.join(sdkOut, 'ui', name); 354 var uiLibraryOut = path.join(sdkOut, 'ui', name);
330 _writeSync(uiLibraryOut, readInputFile(file.path)); 355 _writeSync(uiLibraryOut, readInputFile(file.path));
331 } 356 }
332 locations['ui'] = 'ui/ui.dart'; 357 locations['ui'] = 'ui/ui.dart';
358
359 if (!forFlutterRelease) {
360 // vmservice should be present unless we build release flavor of Flutter.
361 //
362 // TODO(dartbug.com/30158): Consider producing separate Flutter
363 // vmservice.dill with these vmservice libraries.
364 for (var file in ['loader.dart', 'server.dart', 'vmservice_io.dart']) {
365 var libraryIn = path.join(dartDir, 'runtime', 'bin', 'vmservice', file);
366 var libraryOut = path.join(sdkOut, 'vmservice_io', file);
367 _writeSync(libraryOut, readInputFile(libraryIn));
368 }
369 locations['vmservice_sky'] =
370 path.join('vmservice_io', 'vmservice_io.dart');
371 locations['_vmservice'] = path.join('vmservice', 'vmservice.dart');
372 }
333 } 373 }
334 } 374 }
335 375
336 _applyPatch(SdkLibrary library, String sdkLibIn, String patchIn, String sdkOut, 376 _applyPatch(SdkLibrary library, String sdkLibIn, String patchIn, String sdkOut,
337 Map<String, String> locations) { 377 Map<String, String> locations) {
338 var libraryOut = path.join(sdkLibIn, library.path); 378 var libraryOut = path.join(sdkLibIn, library.path);
339 var libraryIn = libraryOut; 379 var libraryIn = libraryOut;
340 380
341 var libraryFile = getInputFile(libraryIn, canBeMissing: true); 381 var libraryFile = getInputFile(libraryIn, canBeMissing: true);
342 if (libraryFile != null) { 382 if (libraryFile != null) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if (diff != 0) return diff; 779 if (diff != 0) return diff;
740 return end - other.end; 780 return end - other.end;
741 } 781 }
742 } 782 }
743 783
744 List<SdkLibrary> _getSdkLibraries(String contents) { 784 List<SdkLibrary> _getSdkLibraries(String contents) {
745 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js); 785 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(forDart2js);
746 parseCompilationUnit(contents).accept(libraryBuilder); 786 parseCompilationUnit(contents).accept(libraryBuilder);
747 return libraryBuilder.librariesMap.sdkLibraries; 787 return libraryBuilder.librariesMap.sdkLibraries;
748 } 788 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698