import 'dart:ffi'; import 'dart:io'; import "package:ffi/ffi.dart"; import "package:path/path.dart" show dirname, join; import 'dart:io' show Platform; import 'archimedes_mobile_lib_bindings_generated.dart'; const String _libName = 'archimedes_mobile_lib'; final HERE = File(String.fromEnvironment("CURRENT_EXEC_DIR", defaultValue: (File(Platform.script.path).parent.absolute.path))); final BUILD_DIR = File(join(HERE.path, "build")); DynamicLibrary getArchimedesCLib() { if (Platform.isMacOS || Platform.isIOS) { return DynamicLibrary.open( join(BUILD_DIR.path, '$_libName.framework', _libName)); } if (Platform.isAndroid || Platform.isLinux) { return DynamicLibrary.open(join(BUILD_DIR.path, 'lib$_libName.so')); } if (Platform.isWindows) { return DynamicLibrary.open(join(BUILD_DIR.path, '$_libName.dll')); } throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}'); }