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

Unified Diff: pkg/analyzer_cli/lib/src/build_mode.dart

Issue 2836873005: Add support for unlinked summary inputs through --build-summary-unlinked-input (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/build_mode.dart
diff --git a/pkg/analyzer_cli/lib/src/build_mode.dart b/pkg/analyzer_cli/lib/src/build_mode.dart
index 985511db795d58c303585312c7a6a99c3d020c48..6cca2ef435529e89c1253f85e86dd178e2db0f38 100644
--- a/pkg/analyzer_cli/lib/src/build_mode.dart
+++ b/pkg/analyzer_cli/lib/src/build_mode.dart
@@ -132,6 +132,7 @@ class BuildMode {
InternalAnalysisContext context;
Map<Uri, File> uriToFileMap;
final List<Source> explicitSources = <Source>[];
+ final List<PackageBundle> unlinkedBundles = <PackageBundle>[];
PackageBundleAssembler assembler;
final Set<Source> processedSources = new Set<Source>();
@@ -212,7 +213,14 @@ class BuildMode {
_unlinkedUnitForUri('${src.uri}');
}
} else {
- _serializeAstBasedSummary(explicitSources);
+ Set<String> unlinkedUris =
+ explicitSources.map((Source s) => s.uri.toString()).toSet();
+ for (var bundle in unlinkedBundles) {
+ unlinkedUris.addAll(
+ bundle.unlinkedUnitUris.where((uri) => !uri.startsWith('dart:')));
Paul Berry 2017/04/26 15:28:31 Why is `!uri.startsWith('dart:')` necessary? It s
jakemac 2017/04/26 16:06:09 Oh I think this was just necessary for linked summ
+ }
+
+ _serializeAstBasedSummary(unlinkedUris);
assembler.recordDependencies(summaryDataStore);
}
// Write the whole package bundle.
@@ -256,9 +264,39 @@ class BuildMode {
void _createContext() {
// Read the summaries.
- summaryDataStore = new SummaryDataStore(options.buildSummaryInputs,
+ summaryDataStore = new SummaryDataStore(<String>[],
recordDependencyInfo: _shouldOutputSummary);
+ // Adds a bundle at `path` to `summaryDataStore`.
+ PackageBundle addBundle(String path) {
+ var bundle =
+ new PackageBundle.fromBuffer(new io.File(path).readAsBytesSync());
+ summaryDataStore.addBundle(path, bundle);
+ return bundle;
+ }
+
+ for (var path in options.buildSummaryInputs) {
+ var bundle = addBundle(path);
+ if (bundle.linkedLibraryUris.isEmpty &&
jakemac 2017/04/25 17:59:57 I am not sure if this is 100% sane, but it seems t
+ bundle.unlinkedUnitUris.isNotEmpty) {
+ throw new ArgumentError(
+ 'Got an unlinked summary for --build-summary-input at `$path`. '
+ 'Unlinked summaries should be provided with the '
+ '--build-summary-unlinked-input argument.');
+ }
+ }
+
+ for (var path in options.buildSummaryUnlinkedInputs) {
+ var bundle = addBundle(path);
+ unlinkedBundles.add(bundle);
+ if (bundle.linkedLibraryUris.isNotEmpty) {
+ throw new ArgumentError(
+ 'Got a linked summary for --build-summary-input-unlinked at `$path`'
+ '. Linked bundles should be provided with the '
+ '--build-summary-input argument.');
+ }
+ }
+
DartSdk sdk;
PackageBundle sdkBundle;
if (options.dartSdkSummaryPath != null) {
@@ -357,15 +395,12 @@ class BuildMode {
* Serialize the package with the given [sources] into [assembler] using only
* their ASTs and [LinkedUnit]s of input packages.
*/
- void _serializeAstBasedSummary(List<Source> sources) {
- Set<String> sourceUris =
- sources.map((Source s) => s.uri.toString()).toSet();
-
+ void _serializeAstBasedSummary(Set<String> unlinkedUris) {
LinkedLibrary _getDependency(String absoluteUri) =>
summaryDataStore.linkedMap[absoluteUri];
Map<String, LinkedLibraryBuilder> linkResult = link(
- sourceUris,
+ unlinkedUris,
_getDependency,
_unlinkedUnitForUri,
context.declaredVariables.get,
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698