Chromium Code Reviews| Index: pkg/analyzer/tool/summary/build_sdk_summaries.dart |
| diff --git a/pkg/analyzer/tool/summary/build_sdk_summary.dart b/pkg/analyzer/tool/summary/build_sdk_summaries.dart |
| similarity index 66% |
| rename from pkg/analyzer/tool/summary/build_sdk_summary.dart |
| rename to pkg/analyzer/tool/summary/build_sdk_summaries.dart |
| index 624db692893b2ed01977e64442985195e2c3be92..ff2aac2474f63894a2048d72d9b6b64a307f47b3 100644 |
| --- a/pkg/analyzer/tool/summary/build_sdk_summary.dart |
| +++ b/pkg/analyzer/tool/summary/build_sdk_summaries.dart |
| @@ -8,6 +8,7 @@ import 'package:analyzer/src/generated/sdk_io.dart'; |
| import 'package:analyzer/src/generated/source.dart'; |
| import 'package:analyzer/src/summary/format.dart'; |
| import 'package:analyzer/src/summary/summarize_elements.dart'; |
| +import 'package:path/path.dart'; |
| main(List<String> args) { |
| if (args.length < 1 || args.length > 2) { |
| @@ -18,9 +19,9 @@ main(List<String> args) { |
| // |
| // Prepare output file path. |
| // |
| - String outputFilePath = args[0]; |
| - if (FileSystemEntity.isDirectorySync(outputFilePath)) { |
| - print("'$outputFilePath' is a directory."); |
| + String outputDirectoryPath = args[0]; |
| + if (!FileSystemEntity.isDirectorySync(outputDirectoryPath)) { |
| + print("'$outputDirectoryPath' is not a directory."); |
| _printUsage(); |
| exitCode = 1; |
| return; |
| @@ -41,10 +42,30 @@ main(List<String> args) { |
| sdkPath = DirectoryBasedDartSdk.defaultSdkDirectory.getAbsolutePath(); |
| } |
| // |
| + // Generate spec and strong summaries. |
| + // |
| + _generateSummary(sdkPath, outputDirectoryPath, false); |
| + _generateSummary(sdkPath, outputDirectoryPath, true); |
| +} |
| + |
| +/** |
| + * The name of the SDK summaries builder application. |
| + */ |
| +const BINARY_NAME = "build_sdk_summaries"; |
| + |
| +/** |
| + * Generate a strong or spec mode summary for the Dart SDK at [sdkPath]. |
| + */ |
| +void _generateSummary( |
| + String sdkPath, String outputDirectoryPath, bool strongMode) { |
| + print('Generating ${strongMode ? 'strong' : 'spec'} mode summary.'); |
|
Paul Berry
2016/02/05 16:53:26
The other day Vijay was referring to spec mode as
|
| + Stopwatch sw = new Stopwatch()..start(); |
| + // |
| // Prepare SDK. |
| // |
| DirectoryBasedDartSdk sdk = new DirectoryBasedDartSdk(new JavaFile(sdkPath)); |
| AnalysisContext context = sdk.context; |
| + context.analysisOptions = new AnalysisOptionsImpl()..strongMode = strongMode; |
| // |
| // Serialize each SDK library. |
| // |
| @@ -53,13 +74,11 @@ main(List<String> args) { |
| List<String> unlinkedUnitUris = <String>[]; |
| List<UnlinkedUnitBuilder> unlinkedUnits = <UnlinkedUnitBuilder>[]; |
| for (SdkLibrary lib in sdk.sdkLibraries) { |
| - print('Resolving and serializing: ${lib.shortName}'); |
| Source librarySource = sdk.mapDartUri(lib.shortName); |
| LibraryElement libraryElement = |
| context.computeLibraryElement(librarySource); |
| - // TODO(paulberry): also build a summary of the SDK in strong mode. |
| LibrarySerializationResult libraryResult = |
| - serializeLibrary(libraryElement, context.typeProvider, false); |
| + serializeLibrary(libraryElement, context.typeProvider, strongMode); |
| linkedLibraryUris.add(lib.shortName); |
| linkedLibraries.add(libraryResult.linked); |
| unlinkedUnitUris.addAll(libraryResult.unitUris); |
| @@ -73,18 +92,20 @@ main(List<String> args) { |
| linkedLibraries: linkedLibraries, |
| unlinkedUnitUris: unlinkedUnitUris, |
| unlinkedUnits: unlinkedUnits); |
| + String outputFilePath = |
| + join(outputDirectoryPath, strongMode ? 'strong.sum' : 'spec.sum'); |
| File file = new File(outputFilePath); |
| file.writeAsBytesSync(sdkBundle.toBuffer(), mode: FileMode.WRITE_ONLY); |
| + // |
| + // Done. |
| + // |
| + print('\tDone in ${sw.elapsedMilliseconds} ms.'); |
| } |
| /** |
| - * The name of the SDK summary builder application. |
| - */ |
| -const BINARY_NAME = "build_sdk_summary"; |
| - |
| -/** |
| * Print information about how to use the SDK summary builder. |
| */ |
| void _printUsage() { |
| - print('Usage: $BINARY_NAME output_file_path [sdk_path]'); |
| + print('Usage: $BINARY_NAME output_directory_path [sdk_path]'); |
| + print('Generate files spec.sum and strong.sum in the output directory.'); |
| } |