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

Unified Diff: pkg/analyzer/tool/summary/build_sdk_summaries.dart

Issue 1725913002: Add file hashes to SdkBundle; rename to PackageBundle. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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 bd8dec69041b556f04eabf5d1acbf6a31b74cbfd..176f7c654328a6a2e98f568657d1759c3337acfb 100644
--- a/pkg/analyzer/tool/summary/build_sdk_summaries.dart
+++ b/pkg/analyzer/tool/summary/build_sdk_summaries.dart
@@ -1,3 +1,4 @@
+import 'dart:convert';
import 'dart:io';
import 'package:analyzer/dart/element/element.dart';
@@ -8,6 +9,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:crypto/crypto.dart';
import 'package:path/path.dart';
main(List<String> args) {
@@ -73,6 +75,7 @@ class _Builder {
final List<LinkedLibraryBuilder> linkedLibraries = <LinkedLibraryBuilder>[];
final List<String> unlinkedUnitUris = <String>[];
final List<UnlinkedUnitBuilder> unlinkedUnits = <UnlinkedUnitBuilder>[];
+ final List<String> unlinkedUnitHashes = <String>[];
_Builder(this.sdkPath, this.outputDirectoryPath, this.strongMode);
@@ -94,9 +97,8 @@ class _Builder {
//
// Prepare 'dart:' URIs to serialize.
//
- Set<String> uriSet = sdk.sdkLibraries
- .map((SdkLibrary library) => library.shortName)
- .toSet();
+ Set<String> uriSet =
+ sdk.sdkLibraries.map((SdkLibrary library) => library.shortName).toSet();
uriSet.add('dart:html/nativewrappers.dart');
uriSet.add('dart:html_common/html_common_dart2js.dart');
//
@@ -109,11 +111,12 @@ class _Builder {
//
// Write the whole SDK bundle.
//
- SdkBundleBuilder sdkBundle = new SdkBundleBuilder(
+ PackageBundleBuilder sdkBundle = new PackageBundleBuilder(
linkedLibraryUris: linkedLibraryUris,
linkedLibraries: linkedLibraries,
unlinkedUnitUris: unlinkedUnitUris,
- unlinkedUnits: unlinkedUnits);
+ unlinkedUnits: unlinkedUnits,
+ unlinkedUnitHashes: unlinkedUnitHashes);
String outputFilePath =
join(outputDirectoryPath, strongMode ? 'strong.sum' : 'spec.sum');
File file = new File(outputFilePath);
@@ -125,6 +128,15 @@ class _Builder {
}
/**
+ * Compute a hash of the given file contents.
+ */
+ String _hash(String contents) {
+ MD5 md5 = new MD5();
+ md5.add(UTF8.encode(contents));
+ return CryptoUtils.bytesToHex(md5.close());
+ }
+
+ /**
* Serialize the library with the given [source] and all its direct or
* indirect imports and exports.
*/
@@ -149,5 +161,8 @@ class _Builder {
linkedLibraries.add(libraryResult.linked);
unlinkedUnitUris.addAll(libraryResult.unitUris);
unlinkedUnits.addAll(libraryResult.unlinkedUnits);
+ for (Source source in libraryResult.unitSources) {
+ unlinkedUnitHashes.add(_hash(source.contents.data));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698