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

Unified Diff: lib/src/package_graph.dart

Issue 1166343002: Don't load barback for "pub run" unless necessary. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 6 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
« lib/src/executable.dart ('K') | « lib/src/executable.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/package_graph.dart
diff --git a/lib/src/package_graph.dart b/lib/src/package_graph.dart
index 02ba973bd1b4deeb6f51b06b6ce44b139c07b8bb..abc1dc75b9e9064696ba7c82f14556696554c271 100644
--- a/lib/src/package_graph.dart
+++ b/lib/src/package_graph.dart
@@ -72,6 +72,32 @@ class PackageGraph {
return _transitiveDependencies[package];
}
+ /// Returns whether [package], or any of its transitive dependencies, have
+ /// transformers that run on any of their public assets.
+ ///
+ /// This is pessimistic; if any package can't be determined to be transformed,
+ /// this returns `true`.
+ bool isPackageTransformed(String packageName) {
+ if (_isIndividualPackageTransformed(packages[packageName])) return true;
+
+ return transitiveDependencies(packageName)
+ .any(_isIndividualPackageTransformed);
+ }
+
+ /// Returns whether [package] itself has transformers that run on any of its
+ /// public assets.
+ bool _isIndividualPackageTransformed(Package package) {
+ if (package == null) return true;
Bob Nystrom 2015/06/09 00:15:33 Document when this case comes into play.
nweiz 2015/06/09 00:37:34 Done.
+
+ if (package.name == entrypoint.root.name) {
+ return package.pubspec.transformers.isNotEmpty;
+ }
+
+ return package.pubspec.transformers.any((phase) {
+ return phase.any((config) => config.canTransformPublicFiles);
+ });
+ }
+
/// Returns whether [package] is mutable.
///
/// A package is considered to be mutable if it or any of its dependencies
« lib/src/executable.dart ('K') | « lib/src/executable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698