Helpers for discovering dynamic dependencies of dylibs
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
When dealing with:
* https://github.com/dart-lang/native/issues/190
We'd like users to not have to manually make the transitive closure of dependencies. We should provide some helper code to do this.
Rough sketch:
```dart
Set transitiveDeps(String dylib) {
final all = {};
final worklist = [dylib];
while (worklist.isNotEmpty) {
final current = worklist.removeLast();
for (final path in depsOfDylib(current)) {
if (all.add(path)) {
worklist.add(path);
}
}
}
return all;
}
Set depsOfDylib(String dylib) {
final result = Process.runSync('otool', ['-L', dylib]);
return regexp
.allMatches(result.stdout)
.map((match) => match.namedGroup('path')!)
.toSet();
}
final regexp = RegExp(r'^\s+(?[^\s]*)\s+', multiLine: true);
final homebrewDir = '${Platform.environment['HOME']}/.homebrew';
```
We'd need something for all OSes.
Thanks @mkustermann for reporting and the sketch!
Contributor guide
Assessment
This issue has not been assessed yet.