From 58ed8b839ef2a6748069f631fd744d90f3bf1da6 Mon Sep 17 00:00:00 2001 From: lindeer Date: Sun, 31 Dec 2023 23:18:22 +0800 Subject: [PATCH] review fix --- .../lib/src/config_provider/spec_utils.dart | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart index 17cd37ce7..31326ace9 100644 --- a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart +++ b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart @@ -305,21 +305,27 @@ Headers headersExtractor( ); } -/// Returns location of dynamic library by searching default locations. Logs -/// error and throws an Exception if not found. -String findDylibAtDefaultLocations() { - String? k; +String? _findLibInConda() { final condaEnvPath = Platform.environment['CONDA_PREFIX'] ?? ''; if (condaEnvPath.isNotEmpty) { - final localtions = [ + final locations = [ p.join(condaEnvPath, 'lib'), p.join(p.dirname(p.dirname(condaEnvPath)), 'lib'), ]; - for (final l in localtions) { - k = findLibclangDylib(l); + for (final l in locations) { + final k = findLibclangDylib(l); if (k != null) return k; } } + return null; +} + +/// Returns location of dynamic library by searching default locations. Logs +/// error and throws an Exception if not found. +String findDylibAtDefaultLocations() { + // Assume clang in conda has a higher priority. + var k = _findLibInConda(); + if (k != null) return k; if (Platform.isLinux) { for (final l in strings.linuxDylibLocations) { k = findLibclangDylib(l);