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

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

Issue 1538923003: A Dart script for building SDK summary. (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 | « 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
(Empty)
1 import 'dart:io';
2
3 import 'package:analyzer/dart/element/element.dart';
4 import 'package:analyzer/src/generated/engine.dart';
5 import 'package:analyzer/src/generated/java_io.dart';
6 import 'package:analyzer/src/generated/sdk.dart';
7 import 'package:analyzer/src/generated/sdk_io.dart';
8 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/summary/builder.dart';
10 import 'package:analyzer/src/summary/format.dart';
11 import 'package:analyzer/src/summary/summarize_elements.dart';
12
13 main(List<String> args) {
14 if (args.length < 1 || args.length > 2) {
15 _printUsage();
16 return;
17 }
18 //
19 // Prepare output file path.
20 //
21 String outputFilePath = args[0];
22 if (FileSystemEntity.isDirectorySync(outputFilePath)) {
23 print("'$outputFilePath' is a directory.");
24 _printUsage();
25 return;
26 }
27 //
28 // Prepare SDK path.
29 //
30 String sdkPath;
31 if (args.length == 2) {
32 sdkPath = args[1];
33 if (!FileSystemEntity.isDirectorySync('$sdkPath/lib')) {
34 print("'$sdkPath/lib' does not exist.");
35 _printUsage();
36 return;
37 }
38 } else {
39 sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath();
40 }
41 //
42 // Prepare SDK.
43 //
44 DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkPath));
45 AnalysisContext context = sdk.context;
46 //
47 // Serialize each SDK library.
48 //
49 BuilderContext builderContext = new BuilderContext();
50 List<SdkBundleLibraryBuilder> libraryBuilders = <SdkBundleLibraryBuilder>[];
51 for (SdkLibrary lib in sdk.sdkLibraries) {
52 print('Resolving and serializing: ${lib.shortName}');
53 Source librarySource = sdk.mapDartUri(lib.shortName);
54 LibraryElement libraryElement =
55 context.computeLibraryElement(librarySource);
56 LibrarySerializationResult libraryResult =
57 serializeLibrary(builderContext, libraryElement, context.typeProvider);
58 SdkBundleLibraryBuilder libraryBuilder = encodeSdkBundleLibrary(
59 builderContext,
60 uri: lib.shortName,
61 prelinked: libraryResult.prelinked,
62 unlinkedUnits: libraryResult.unlinkedUnits);
63 libraryBuilders.add(libraryBuilder);
64 }
65 //
66 // Write the whole SDK bundle.
67 //
68 SdkBundleBuilder sdkBundle =
69 encodeSdkBundle(builderContext, libraries: libraryBuilders);
70 File file = new File(outputFilePath);
71 file.writeAsBytesSync(sdkBundle.toBuffer(), mode: FileMode.WRITE_ONLY);
72 }
73
74 /**
75 * The name of the SDK summary builder application.
76 */
77 const BINARY_NAME = "build_sdk_summary";
78
79 /**
80 * Print information about how to use the SDK summary builder.
81 */
82 void _printUsage() {
83 print('Usage: $BINARY_NAME output_file_path [sdk_path]');
84 }
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