@@ -12,6 +12,7 @@ import 'package:yaml/yaml.dart';
12
12
13
13
import '../constants.dart' ;
14
14
import '../io/asset_path_provider.dart' ;
15
+ import '../logging/build_log.dart' ;
15
16
16
17
/// The SDK package, we filter this to the core libs and dev compiler
17
18
/// resources.
@@ -93,6 +94,7 @@ class PackageGraph implements AssetPathProvider {
93
94
// where a package config was found. It doesn't seem possible to obtain this
94
95
// directly with package:package_config.
95
96
while (true ) {
97
+ //buildLog.debug('!!!! $rootDir');
96
98
packageConfig = await findPackageConfig (
97
99
Directory (rootDir),
98
100
recurse: false ,
@@ -113,6 +115,10 @@ class PackageGraph implements AssetPathProvider {
113
115
'Unable to find package config for package at $packagePath .' ,
114
116
);
115
117
}
118
+ /*buildLog.debug(
119
+ 'loading dependency types from $rootDir, vs ''
120
+ ${packageConfig.packages.map((p) => p.name).toList()..sort()}',
121
+ );*/
116
122
final dependencyTypes = _parseDependencyTypes (rootDir);
117
123
118
124
final nodes = < String , PackageNode > {};
@@ -157,14 +163,37 @@ class PackageGraph implements AssetPathProvider {
157
163
final packageDependencies = _parsePackageDependencies (
158
164
packageConfig.packages.where ((p) => p.name != rootPackageName),
159
165
);
166
+ // print('packageDependencies: $packageDependencies');s
160
167
for (final packageName in packageDependencies.keys) {
161
168
packageNode (packageName).dependencies.addAll (
162
169
packageDependencies[packageName]! .map (
163
170
(n) => packageNode (n, parent: packageName),
164
171
),
165
172
);
166
173
}
167
- return PackageGraph ._(rootNode, nodes);
174
+
175
+ final actuallyUsedNodes = {rootNode};
176
+ var changed = true ;
177
+ while (changed) {
178
+ changed = false ;
179
+ for (final node in actuallyUsedNodes.toList ()) {
180
+ for (final dep in node.dependencies) {
181
+ if (! actuallyUsedNodes.contains (dep)) {
182
+ actuallyUsedNodes.add (dep);
183
+ changed = true ;
184
+ }
185
+ }
186
+ }
187
+ }
188
+
189
+ // print('Now we have ${actuallyUsedNodes.map((n) => n.name).toList()}');
190
+
191
+ return PackageGraph ._(
192
+ rootNode,
193
+ Map .fromEntries (
194
+ nodes.entries.where ((e) => actuallyUsedNodes.contains (e.value)),
195
+ ),
196
+ );
168
197
}
169
198
170
199
/// Creates a [PackageGraph] for the package in which you are currently
0 commit comments