Skip to content

Android Plugin custom arch support #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ OpenCV Bindings for Dart Language. Support both asynchronous and synchronous!
> 1. If you want to setup manually, please set `OPENCV_DART_DISABLE_AUTO_BUILD` environment variable,
> e.g., `export OPENCV_DART_DISABLE_AUTO_BUILD=1`(for Unix-like)
> or `$env:OPENCV_DART_DISABLE_AUTO_BUILD=1`(for Windows)
>

> For `v1.0.4` and below, make sure run the following setup commands before running your app:
>
> 1. `flutter pub add opencv_dart` or `dart pub add opencv_dart`
Expand Down Expand Up @@ -159,6 +159,14 @@ void main() {

#### Flutter

> Android only
>
> if you want build Android apk with custom arch , you can set `OPENCV_DART_ANDROID_SUPPORT_ARCHS` environment variable before **flutter build**
>
> e.g., `export OPENCV_DART_ANDROID_SUPPORT_ARCHS=arm64-v8a,armeabi-v7a`(for Unix-like)
>
> or `$env:OPENCV_DART_DISABLE_AUTO_BUILD=arm64-v8a,armeabi-v7a`(for Windows)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be moved to Q&A #212


see [example](https://github.com/rainyl/opencv_dart/tree/main/example)

~~More examples are on the way...~~see [opencv_dart.examples](https://github.com/rainyl/opencv_dart.examples) and share yours
Expand Down
23 changes: 22 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ def CACHE_DIR = SOURCE_DIR.parentFile
def CVD_VERSION = new File("${project.buildscript.sourceFile.parentFile.parentFile}/binary.version").text
def CVD_LIB_URL_BASE = "https://github.com/rainyl/opencv_dart/releases/download"
def ARCHS = ['x86_64', 'arm64-v8a', 'armeabi-v7a']
def OPENCV_DART_ANDROID_SUPPORT_ARCHS=System.env.OPENCV_DART_ANDROID_SUPPORT_ARCHS ?: null
if(OPENCV_DART_ANDROID_SUPPORT_ARCHS != null){
println "OPENCV_DART_ANDROID_SUPPORT_ARCHS is defined : $OPENCV_DART_ANDROID_SUPPORT_ARCHS"
def supportedArchs = OPENCV_DART_ANDROID_SUPPORT_ARCHS.split(",")
def acceptedArchs = []
supportedArchs.each { supportArch ->
if(ARCHS.contains(supportArch)){
println "[opencv_dart] Support arch: ${supportArch}"
acceptedArchs.add(supportArch)
}else{
println "[opencv_dart] Unsupport arch: ${supportArch}"
}
}
println "[opencv_dart] OPENCV_DART for Android support arch : $acceptedArchs"
ARCHS = acceptedArchs
}

task downloadLibs(type: Download) {
println "[opencv_dart] Downloading libraries..."
Expand All @@ -95,7 +111,12 @@ ARCHS.each { arch ->
}
}

task extractLibs(dependsOn: downloadLibs) {
task cleanupExtractLibs(type: Delete) {
println "[opencv_dart] Cleaning up opencv_dart libraries..."
delete "${SOURCE_DIR}/src/main/jniLibs"
}

task extractLibs(dependsOn: [downloadLibs,cleanupExtractLibs]) {
println "[opencv_dart] Extracting libraries..."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete clean up task, unnecessary extraction and copy will be run if added.

ARCHS.each { arch ->
finalizedBy "opencv_dart_extract_libs_${arch}"
Expand Down
Loading