| Index: pkg/analyzer/tool/summary/build_sdk_summaries.dart
|
| diff --git a/pkg/analyzer/tool/summary/build_sdk_summaries.dart b/pkg/analyzer/tool/summary/build_sdk_summaries.dart
|
| index 1bbd4da6967a97c46b676907b383912f620c88fa..fc7ec0e271476c78fe6b67842845b8c451831b02 100644
|
| --- a/pkg/analyzer/tool/summary/build_sdk_summaries.dart
|
| +++ b/pkg/analyzer/tool/summary/build_sdk_summaries.dart
|
| @@ -1,16 +1,8 @@
|
| import 'dart:io';
|
|
|
| -import 'package:analyzer/dart/ast/ast.dart';
|
| -import 'package:analyzer/dart/element/element.dart';
|
| -import 'package:analyzer/src/generated/engine.dart';
|
| -import 'package:analyzer/src/generated/java_io.dart';
|
| -import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:analyzer/src/generated/sdk_io.dart';
|
| -import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/summary/flat_buffers.dart' as fb;
|
| -import 'package:analyzer/src/summary/index_unit.dart';
|
| -import 'package:analyzer/src/summary/summarize_elements.dart';
|
| -import 'package:path/path.dart';
|
| +import 'package:analyzer/src/summary/summary_file_builder.dart';
|
|
|
| main(List<String> args) {
|
| if (args.length < 1) {
|
| @@ -124,15 +116,24 @@ _Output _buildMultipleOutputs(String sdkPath, bool includeSpec) {
|
| } else {
|
| sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath();
|
| }
|
| +
|
| //
|
| // Build spec and strong outputs.
|
| //
|
| - _BuilderOutput spec =
|
| - includeSpec ? new _Builder(sdkPath, false).build() : null;
|
| - _BuilderOutput strong = new _Builder(sdkPath, true).build();
|
| + BuilderOutput spec = includeSpec ? _buildOutput(sdkPath, false) : null;
|
| + BuilderOutput strong = _buildOutput(sdkPath, true);
|
| return new _Output(spec, strong);
|
| }
|
|
|
| +BuilderOutput _buildOutput(String sdkPath, bool strongMode) {
|
| + String modeName = strongMode ? 'strong' : 'spec';
|
| + print('Generating $modeName mode summary and index.');
|
| + Stopwatch sw = new Stopwatch()..start();
|
| + BuilderOutput output = new SummaryBuilder.forSdk(sdkPath, strongMode).build();
|
| + print('\tDone in ${sw.elapsedMilliseconds} ms.');
|
| + return output;
|
| +}
|
| +
|
| /**
|
| * Open the flat buffer in [inputPath] and extract the byte array in the [field]
|
| * into the [outputPath] file.
|
| @@ -169,105 +170,9 @@ void _printUsage() {
|
| print(' Extract the strong-mode index file.');
|
| }
|
|
|
| -class _Builder {
|
| - final String sdkPath;
|
| - final bool strongMode;
|
| -
|
| - AnalysisContext context;
|
| - final Set<Source> processedSources = new Set<Source>();
|
| -
|
| - final PackageBundleAssembler bundleAssembler = new PackageBundleAssembler();
|
| - final PackageIndexAssembler indexAssembler = new PackageIndexAssembler();
|
| -
|
| - _Builder(this.sdkPath, this.strongMode);
|
| -
|
| - /**
|
| - * Build a strong or spec mode summary for the Dart SDK at [sdkPath].
|
| - */
|
| - _BuilderOutput build() {
|
| - String modeName = strongMode ? 'strong' : 'spec';
|
| - print('Generating $modeName mode summary and index.');
|
| - Stopwatch sw = new Stopwatch()..start();
|
| - //
|
| - // Prepare SDK.
|
| - //
|
| - DirectoryBasedDartSdk sdk =
|
| - new DirectoryBasedDartSdk(new JavaFile(sdkPath), strongMode);
|
| - sdk.useSummary = false;
|
| - sdk.analysisOptions = new AnalysisOptionsImpl()..strongMode = strongMode;
|
| - context = sdk.context;
|
| - //
|
| - // Prepare 'dart:' URIs to serialize.
|
| - //
|
| - Set<String> uriSet =
|
| - sdk.sdkLibraries.map((SdkLibrary library) => library.shortName).toSet();
|
| - if (!strongMode) {
|
| - uriSet.add('dart:html/nativewrappers.dart');
|
| - }
|
| - uriSet.add('dart:html_common/html_common_dart2js.dart');
|
| - //
|
| - // Serialize each SDK library.
|
| - //
|
| - for (String uri in uriSet) {
|
| - Source libSource = sdk.mapDartUri(uri);
|
| - _serializeLibrary(libSource);
|
| - }
|
| - //
|
| - // Assemble the output.
|
| - //
|
| - List<int> sumBytes = bundleAssembler.assemble().toBuffer();
|
| - List<int> indexBytes = indexAssembler.assemble().toBuffer();
|
| - print('\tDone in ${sw.elapsedMilliseconds} ms.');
|
| - return new _BuilderOutput(sumBytes, indexBytes);
|
| - }
|
| -
|
| - /**
|
| - * Serialize the library with the given [source] and all its direct or
|
| - * indirect imports and exports.
|
| - */
|
| - void _serializeLibrary(Source source) {
|
| - if (!processedSources.add(source)) {
|
| - return;
|
| - }
|
| - LibraryElement element = context.computeLibraryElement(source);
|
| - bundleAssembler.serializeLibraryElement(element);
|
| - element.importedLibraries.forEach((e) => _serializeLibrary(e.source));
|
| - element.exportedLibraries.forEach((e) => _serializeLibrary(e.source));
|
| - // Index every unit of the library.
|
| - for (CompilationUnitElement unitElement in element.units) {
|
| - Source unitSource = unitElement.source;
|
| - CompilationUnit unit =
|
| - context.resolveCompilationUnit2(unitSource, source);
|
| - indexAssembler.indexUnit(unit);
|
| - }
|
| - }
|
| -}
|
| -
|
| -class _BuilderOutput {
|
| - final List<int> sum;
|
| - final List<int> index;
|
| -
|
| - _BuilderOutput(this.sum, this.index);
|
| -
|
| - void writeMultiple(String outputDirectoryPath, String modeName) {
|
| - // Write summary.
|
| - {
|
| - String outputPath = join(outputDirectoryPath, '$modeName.sum');
|
| - File file = new File(outputPath);
|
| - file.writeAsBytesSync(sum, mode: FileMode.WRITE_ONLY);
|
| - }
|
| - // Write index.
|
| - {
|
| - String outputPath = join(outputDirectoryPath, '$modeName.index');
|
| - File file = new File(outputPath);
|
| - file.writeAsBytesSync(index, mode: FileMode.WRITE_ONLY);
|
| - }
|
| - }
|
| -}
|
| -
|
| class _Output {
|
| - final _BuilderOutput spec;
|
| - final _BuilderOutput strong;
|
| + final BuilderOutput spec;
|
| + final BuilderOutput strong;
|
|
|
| _Output(this.spec, this.strong);
|
| }
|
|
|