dylib top-level property

DynamicLibrary dylib
final

Implementation

final DynamicLibrary dylib = () {
  // Continuous integration
  if (Platform.environment.containsKey('FHEL_C_LIB_PREFIX')) {
    return DynamicLibrary.open("${Platform.environment['FHEL_C_LIB_PREFIX']}/$libfhel");
  }
  // Development environment
  if (Platform.environment.containsKey('FHEL_C_LIB_PATH')) {
    return DynamicLibrary.open(Platform.environment['FHEL_C_LIB_PATH']!);
  }
  // Android: packaged at runtime, see dart/android/build.gradle
  if (Platform.isAndroid) {
    return DynamicLibrary.open(libfhel);
  }
  // Production environment: .pub-cache
  try {
    return DynamicLibrary.open(
        '$desktopPubCachePath/$_libraryName-$version/${Platform.operatingSystem}/$libfhel');
  } catch (e) {
    throw StateError('$e. Have you run `dart run fhel:setup --${Platform.operatingSystem}`?');
  }
}();