Skip to content

Commit

Permalink
Merge branch 'main' into async
Browse files Browse the repository at this point in the history
  • Loading branch information
rainyl committed Jun 22, 2024
2 parents c5b7ee5 + b16eb1b commit 85a2290
Show file tree
Hide file tree
Showing 57 changed files with 7,661 additions and 6,868 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build_test_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ jobs:
submodules: true
- name: setup
run: |
brew install --force --overwrite ninja ccache ffmpeg@6 nasm conan
brew install --force --overwrite ninja ccache ffmpeg@6 nasm [email protected]
brew link --overwrite ffmpeg@6
brew link --overwrite [email protected]
brew install --force --overwrite conan
conan profile detect -f
cd ${{github.workspace}}
- name: build
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.10+1

- Fix: setup commands error on linux

## 1.0.10

- Fix: memory leak caused by cvstatus

## 1.0.9

- Fix: free smart pointer
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
OUTPUT_NAME ${LIBRARY_NAME}
CXX_VISIBILITY_PRESET default
C_VISIBILITY_PRESET default
LINK_FLAGS_RELEASE -s
)

if(IOS)
Expand All @@ -98,6 +97,10 @@ endif(WIN32)

target_compile_definitions(${LIBRARY_NAME} PUBLIC DART_SHARED_LIB)

if(CVD_ENABLE_TEST)
set_target_properties(${LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "CVD_ENABLE_TEST")
endif()

### install
install(TARGETS ${LIBRARY_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX})
Expand Down
10 changes: 4 additions & 6 deletions bin/setup_commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:archive/archive_io.dart';
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as p;
import 'package:stack_trace/stack_trace.dart';
import 'package:yaml/yaml.dart';

const setupPkgName = "opencv_dart";
const baseUrl = "https://github.com/rainyl/opencv_dart/releases/download";

abstract class BaseSetupCommand extends Command {
@override
Expand All @@ -31,14 +31,12 @@ abstract class BaseSetupCommand extends Command {
final opencvRoot = pkgRoot;
print(asInfo('Using package:$setupPkgName from $opencvRoot'));

final doc = loadYaml(File(p.join(opencvRoot, "pubspec.yaml")).readAsStringSync());
// ignore: avoid_dynamic_calls
final String version = doc["binary_version"] as String;
final String version = File(p.join(opencvRoot, "binary.version")).readAsStringSync();
final libTarName = "libopencv_dart-$os-$downArch.tar.gz";

extractPath ??= switch (os) {
OS.windows => p.join(opencvRoot, "windows"),
OS.linux => p.join(opencvRoot, "windows"),
OS.linux => p.join(opencvRoot, "linux"),
OS.android => p.join(opencvRoot, "android", "src", "main", "jniLibs", downArch),
OS.macos => p.join(opencvRoot, "macos"),
OS.ios => p.join(opencvRoot, "ios"),
Expand All @@ -55,7 +53,7 @@ abstract class BaseSetupCommand extends Command {
if (force || !saveFile.existsSync()) {
if (!saveFile.parent.existsSync()) saveFile.parent.createSync(recursive: true);

final String url = "https://github.com/rainyl/opencv_dart/releases/download/v$version/$libTarName";
final String url = "$baseUrl/v$version/$libTarName";
print(asInfo("Downloading $url"));
try {
final request = await HttpClient().getUrl(Uri.parse(url));
Expand Down
2 changes: 1 addition & 1 deletion binary.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.9
1.0.10
9 changes: 4 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import conan.tools.files as cfiles
import tarfile
from pathlib import Path
import yaml

OPENCV_VERSION = "4.10.0+2"
OPENCV_FILES_URL = (
Expand Down Expand Up @@ -61,10 +60,10 @@ class OcvDartDesktop(ConanFile):

def __init__(self, display_name=""):
super().__init__(display_name)
pubspec = Path(str(self.options.get_safe("package_root", "."))) / "pubspec.yaml"
with open(pubspec, "r") as f:
doc = yaml.safe_load(f)
self.version = doc["binary_version"]
version_file = Path(str(self.options.get_safe("package_root", "."))) / "binary.version"
with open(version_file, "r") as f:
binary_version = f.read()
self.version = binary_version

def requirements(self):
out_dir = os.path.abspath(str(self.options.get_safe("output_dir")))
Expand Down
21 changes: 11 additions & 10 deletions lib/src/core/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ abstract class CvStruct<T extends ffi.Struct> extends ICvStruct<T> with Equatabl
CvStruct.fromPointer(super.ptr) : super.fromPointer();
}

void cvRun(CvStatus Function() func) {
final status = func();
if (status.code != 0) {
throw CvException(
status.code,
msg: status.msg.cast<Utf8>().toDartString(),
file: status.file.cast<Utf8>().toDartString(),
func: status.func.cast<Utf8>().toDartString(),
line: status.line,
);
void cvRun(ffi.Pointer<CvStatus> Function() func) {
final s = func();
final code = s.ref.code;
// String err = s.ref.err.cast<Utf8>().toDartString();
final msg = s.ref.msg.cast<Utf8>().toDartString();
final file = s.ref.file.cast<Utf8>().toDartString();
final funcName = s.ref.func.cast<Utf8>().toDartString();
final line = s.ref.line;
CFFI.CvStatus_Close(s);
if (code != 0) {
throw CvException(code, msg: msg, file: file, func: funcName, line: line);
}
}

Expand Down
Loading

0 comments on commit 85a2290

Please sign in to comment.