Skip to content

Commit 0ffdccc

Browse files
lindeerlindeer
and
lindeer
authored
[ffigen] Search dylib in conda env path (#869)
Co-authored-by: lindeer <[email protected]>
1 parent 793c4f5 commit 0ffdccc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkgs/ffigen/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ must be passed to change this behaviour.
77
- __Breaking change__: Stop generating setters for global variables marked `const` in C.
88
- Fix objc_msgSend being used on arm64 platforms where it's not available.
99
- Fix missing comma with `ffi-native` functions marked `leaf`.
10+
- Add support for finding libclang in Conda environment.
1011

1112
## 10.0.0
1213

pkgs/ffigen/lib/src/config_provider/spec_utils.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,27 @@ Headers headersExtractor(
305305
);
306306
}
307307

308+
String? _findLibInConda() {
309+
final condaEnvPath = Platform.environment['CONDA_PREFIX'] ?? '';
310+
if (condaEnvPath.isNotEmpty) {
311+
final locations = [
312+
p.join(condaEnvPath, 'lib'),
313+
p.join(p.dirname(p.dirname(condaEnvPath)), 'lib'),
314+
];
315+
for (final l in locations) {
316+
final k = findLibclangDylib(l);
317+
if (k != null) return k;
318+
}
319+
}
320+
return null;
321+
}
322+
308323
/// Returns location of dynamic library by searching default locations. Logs
309324
/// error and throws an Exception if not found.
310325
String findDylibAtDefaultLocations() {
311-
String? k;
326+
// Assume clang in conda has a higher priority.
327+
var k = _findLibInConda();
328+
if (k != null) return k;
312329
if (Platform.isLinux) {
313330
for (final l in strings.linuxDylibLocations) {
314331
k = findLibclangDylib(l);

0 commit comments

Comments
 (0)