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

Side by Side 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 unified diff | Download patch
« lib/src/executable.dart ('K') | « lib/src/executable.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.package_graph; 5 library pub.package_graph;
6 6
7 import 'barback/transformer_cache.dart'; 7 import 'barback/transformer_cache.dart';
8 import 'entrypoint.dart'; 8 import 'entrypoint.dart';
9 import 'lock_file.dart'; 9 import 'lock_file.dart';
10 import 'package.dart'; 10 import 'package.dart';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (_transitiveDependencies == null) { 65 if (_transitiveDependencies == null) {
66 var closure = transitiveClosure(mapMap(packages, 66 var closure = transitiveClosure(mapMap(packages,
67 value: (_, package) => package.dependencies.map((dep) => dep.name))); 67 value: (_, package) => package.dependencies.map((dep) => dep.name)));
68 _transitiveDependencies = mapMap(closure, 68 _transitiveDependencies = mapMap(closure,
69 value: (_, names) => names.map((name) => packages[name]).toSet()); 69 value: (_, names) => names.map((name) => packages[name]).toSet());
70 } 70 }
71 71
72 return _transitiveDependencies[package]; 72 return _transitiveDependencies[package];
73 } 73 }
74 74
75 /// Returns whether [package], or any of its transitive dependencies, have
76 /// transformers that run on any of their public assets.
77 ///
78 /// This is pessimistic; if any package can't be determined to be transformed,
79 /// this returns `true`.
80 bool isPackageTransformed(String packageName) {
81 if (_isIndividualPackageTransformed(packages[packageName])) return true;
82
83 return transitiveDependencies(packageName)
84 .any(_isIndividualPackageTransformed);
85 }
86
87 /// Returns whether [package] itself has transformers that run on any of its
88 /// public assets.
89 bool _isIndividualPackageTransformed(Package package) {
90 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.
91
92 if (package.name == entrypoint.root.name) {
93 return package.pubspec.transformers.isNotEmpty;
94 }
95
96 return package.pubspec.transformers.any((phase) {
97 return phase.any((config) => config.canTransformPublicFiles);
98 });
99 }
100
75 /// Returns whether [package] is mutable. 101 /// Returns whether [package] is mutable.
76 /// 102 ///
77 /// A package is considered to be mutable if it or any of its dependencies 103 /// A package is considered to be mutable if it or any of its dependencies
78 /// don't come from a cached source, since the user can change its contents 104 /// don't come from a cached source, since the user can change its contents
79 /// without modifying the pub cache. Information generated from mutable 105 /// without modifying the pub cache. Information generated from mutable
80 /// packages is generally not safe to cache, since it may change frequently. 106 /// packages is generally not safe to cache, since it may change frequently.
81 bool isPackageMutable(String package) { 107 bool isPackageMutable(String package) {
82 var id = lockFile.packages[package]; 108 var id = lockFile.packages[package];
83 if (id == null) return true; 109 if (id == null) return true;
84 110
(...skipping 22 matching lines...) Expand all
107 bool isPackageStatic(String package) { 133 bool isPackageStatic(String package) {
108 var id = lockFile.packages[package]; 134 var id = lockFile.packages[package];
109 if (id == null) return false; 135 if (id == null) return false;
110 136
111 var source = entrypoint.cache.sources[id.source]; 137 var source = entrypoint.cache.sources[id.source];
112 if (source is! CachedSource) return false; 138 if (source is! CachedSource) return false;
113 139
114 return packages[package].pubspec.transformers.isEmpty; 140 return packages[package].pubspec.transformers.isEmpty;
115 } 141 }
116 } 142 }
OLDNEW
« 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