2024-03-11 18:42:48 +01:00
|
|
|
import 'dart:ffi';
|
|
|
|
import 'dart:io';
|
|
|
|
import "package:ffi/ffi.dart";
|
|
|
|
import "package:path/path.dart" show dirname, join;
|
|
|
|
import 'dart:io' show Platform;
|
|
|
|
|
2024-03-12 19:53:16 +01:00
|
|
|
const String _libName = 'libdart_openmvg';
|
2024-03-11 18:42:48 +01:00
|
|
|
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}');
|
|
|
|
}
|