Skip to content

Commit

Permalink
fix #8, add binary_version, make Mat impl ffi.Finalizable directly
Browse files Browse the repository at this point in the history
  • Loading branch information
rainyl committed Mar 20, 2024
1 parent 4ae19b7 commit 3936130
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ffigen_contrib.yaml
ffigen_cuda.yaml
replace.py
generate.py
demo.c
demo.*
coverage/
pkgs/
__pycache__
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ target_compile_definitions(${library_name} PUBLIC DART_SHARED_LIB)
if(WITH_OPENCV_DART_DEMO)
add_executable(
demo
"demo.c"
"src/demo.cxx"
)
target_link_libraries(
demo
Expand Down
17 changes: 6 additions & 11 deletions bin/setup_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,17 @@ abstract class BaseSetupCommand extends Command {
final opencvRoot = packageConfigFile.uri.resolve(pkg['rootUri'] ?? '');
print('Using package:$setupPkgName from ${opencvRoot.toFilePath()}');

final doc = loadYaml(
File("${opencvRoot.toFilePath()}/pubspec.yaml").readAsStringSync());
final _version = doc["version"] as String;
final doc = loadYaml(File("${opencvRoot.toFilePath()}/pubspec.yaml").readAsStringSync());
final _version = doc["binary_version"] as String;
final libTarName = "libopencv_dart-$os-$arch.tar.gz";
final version = _version.replaceAll(RegExp(r"\-dev.*"), "");

print('Downloading prebuilt binary...');
String url =
"https://github.com/rainyl/opencv_dart/releases/download/v$version/$libTarName";
String url = "https://github.com/rainyl/opencv_dart/releases/download/v$version/$libTarName";

final cacheTarPath = p.join(opencvRoot.toFilePath(), ".cache", libTarName);
final saveFile = File(cacheTarPath);
if (!saveFile.parent.existsSync())
saveFile.parent.createSync(recursive: true);
if (!saveFile.parent.existsSync()) saveFile.parent.createSync(recursive: true);

print("Downloading $url");
final request = await HttpClient().getUrl(Uri.parse(url));
Expand All @@ -94,8 +91,7 @@ abstract class BaseSetupCommand extends Command {
extractPath = p.join(opencvRoot.toFilePath(), "linux");
break;
case OS.android:
extractPath = p.join(
opencvRoot.toFilePath(), "android", "src", "main", "jniLibs", arch);
extractPath = p.join(opencvRoot.toFilePath(), "android", "src", "main", "jniLibs", arch);
case OS.macos:
extractPath = p.join(opencvRoot.toFilePath(), "macos");
case OS.ios:
Expand All @@ -109,8 +105,7 @@ abstract class BaseSetupCommand extends Command {
}
final tarBytes = GZipDecoder().decodeBytes(saveFile.readAsBytesSync());
final archive = TarDecoder().decodeBytes(tarBytes);
extractArchiveToDisk(archive, extractPath,
bufferSize: 1024 * 1024 * 10); // 10MB
extractArchiveToDisk(archive, extractPath, bufferSize: 1024 * 1024 * 10); // 10MB
}

@override
Expand Down
Loading

0 comments on commit 3936130

Please sign in to comment.