dart-lang / dart-lang/native

Helpers for discovering dynamic dependencies of dylibs

Open
#191 0 comments 0 reactions 0 assignees View on GitHub
P3 package:hooks package:native_toolchain_c
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.