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

Side by Side Diff: pkg/analyzer/tool/summary/build_sdk_summary.dart

Issue 1539103002: Change SdkBundle to better fit its usage by SummaryResynthesizer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'dart:io'; 1 import 'dart:io';
2 2
3 import 'package:analyzer/dart/element/element.dart'; 3 import 'package:analyzer/dart/element/element.dart';
4 import 'package:analyzer/src/generated/engine.dart'; 4 import 'package:analyzer/src/generated/engine.dart';
5 import 'package:analyzer/src/generated/java_io.dart'; 5 import 'package:analyzer/src/generated/java_io.dart';
6 import 'package:analyzer/src/generated/sdk.dart'; 6 import 'package:analyzer/src/generated/sdk.dart';
7 import 'package:analyzer/src/generated/sdk_io.dart'; 7 import 'package:analyzer/src/generated/sdk_io.dart';
8 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/summary/builder.dart'; 9 import 'package:analyzer/src/summary/builder.dart';
10 import 'package:analyzer/src/summary/format.dart'; 10 import 'package:analyzer/src/summary/format.dart';
(...skipping 28 matching lines...) Expand all
39 sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath(); 39 sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath();
40 } 40 }
41 // 41 //
42 // Prepare SDK. 42 // Prepare SDK.
43 // 43 //
44 DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkPath)); 44 DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkPath));
45 AnalysisContext context = sdk.context; 45 AnalysisContext context = sdk.context;
46 // 46 //
47 // Serialize each SDK library. 47 // Serialize each SDK library.
48 // 48 //
49 List<String> prelinkedLibraryUris = <String>[];
50 List<PrelinkedLibraryBuilder> prelinkedLibraries =
51 <PrelinkedLibraryBuilder>[];
52 List<String> unlinkedUnitUris = <String>[];
53 List<UnlinkedUnitBuilder> unlinkedUnits = <UnlinkedUnitBuilder>[];
49 BuilderContext builderContext = new BuilderContext(); 54 BuilderContext builderContext = new BuilderContext();
50 List<SdkBundleLibraryBuilder> libraryBuilders = <SdkBundleLibraryBuilder>[];
51 for (SdkLibrary lib in sdk.sdkLibraries) { 55 for (SdkLibrary lib in sdk.sdkLibraries) {
52 print('Resolving and serializing: ${lib.shortName}'); 56 print('Resolving and serializing: ${lib.shortName}');
53 Source librarySource = sdk.mapDartUri(lib.shortName); 57 Source librarySource = sdk.mapDartUri(lib.shortName);
54 LibraryElement libraryElement = 58 LibraryElement libraryElement =
55 context.computeLibraryElement(librarySource); 59 context.computeLibraryElement(librarySource);
56 LibrarySerializationResult libraryResult = 60 LibrarySerializationResult libraryResult =
57 serializeLibrary(builderContext, libraryElement, context.typeProvider); 61 serializeLibrary(builderContext, libraryElement, context.typeProvider);
58 SdkBundleLibraryBuilder libraryBuilder = encodeSdkBundleLibrary( 62 prelinkedLibraryUris.add(lib.shortName);
59 builderContext, 63 prelinkedLibraries.add(libraryResult.prelinked);
60 uri: lib.shortName, 64 unlinkedUnitUris.addAll(libraryResult.unitUris);
61 prelinked: libraryResult.prelinked, 65 unlinkedUnits.addAll(libraryResult.unlinkedUnits);
62 unlinkedUnits: libraryResult.unlinkedUnits);
63 libraryBuilders.add(libraryBuilder);
64 } 66 }
65 // 67 //
66 // Write the whole SDK bundle. 68 // Write the whole SDK bundle.
67 // 69 //
68 SdkBundleBuilder sdkBundle = 70 SdkBundleBuilder sdkBundle = encodeSdkBundle(builderContext,
69 encodeSdkBundle(builderContext, libraries: libraryBuilders); 71 prelinkedLibraryUris: prelinkedLibraryUris,
72 prelinkedLibraries: prelinkedLibraries,
73 unlinkedUnitUris: unlinkedUnitUris,
74 unlinkedUnits: unlinkedUnits);
70 File file = new File(outputFilePath); 75 File file = new File(outputFilePath);
71 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: FileMode.WRITE_ONLY); 76 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: FileMode.WRITE_ONLY);
72 } 77 }
73 78
74 /** 79 /**
75 * The name of the SDK summary builder application. 80 * The name of the SDK summary builder application.
76 */ 81 */
77 const BINARY_NAME = "build_sdk_summary"; 82 const BINARY_NAME = "build_sdk_summary";
78 83
79 /** 84 /**
80 * Print information about how to use the SDK summary builder. 85 * Print information about how to use the SDK summary builder.
81 */ 86 */
82 void _printUsage() { 87 void _printUsage() {
83 print('Usage: $BINARY_NAME output_file_path [sdk_path]'); 88 print('Usage: $BINARY_NAME output_file_path [sdk_path]');
84 } 89 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698