diff --git a/README.md b/README.md index 9f66d46..1770ae1 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ Flutter plugin for OnnxRuntime via `dart:ffi` provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms. -| **Platform** | Android | iOS | Linux | macOS | Windows | -|-------------------|---------------|-----|-------|-------|---------| -| **Compatibility** | API level 21+ | * | * | * | * | -| **Architecture** | arm32/arm64 | * | * | * | * | +| **Platform** | Android | iOS | Linux | macOS | Windows | +|-------------------|---------|-----|-------|-------|---------| +| **Compatibility** | * | * | * | * | * | +| **Architecture** | * | * | * | * | * | *: [Consistent with Flutter](https://docs.flutter.dev/reference/supported-platforms) diff --git a/android/build.gradle b/android/build.gradle index 8e2a24a..65c9cbd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -19,6 +19,10 @@ rootProject.allprojects { repositories { google() mavenCentral() + + flatDir { + dirs project(':onnxruntime').file('libs') + } } } @@ -48,3 +52,8 @@ android { minSdkVersion 21 } } + +dependencies { + implementation (name: 'onnxruntime-android-1.20.1', ext: 'aar') + implementation (name: 'onnxruntime-extensions-android-0.13.0', ext: 'aar') +} \ No newline at end of file diff --git a/android/libs/onnxruntime-android-1.20.1.aar b/android/libs/onnxruntime-android-1.20.1.aar new file mode 100644 index 0000000..945db1f Binary files /dev/null and b/android/libs/onnxruntime-android-1.20.1.aar differ diff --git a/android/src/main/jniLibs/arm64-v8a/libonnxruntime.so b/android/libs/onnxruntime-extensions-android-0.13.0.aar similarity index 58% rename from android/src/main/jniLibs/arm64-v8a/libonnxruntime.so rename to android/libs/onnxruntime-extensions-android-0.13.0.aar index 52a655f..89a2d06 100644 Binary files a/android/src/main/jniLibs/arm64-v8a/libonnxruntime.so and b/android/libs/onnxruntime-extensions-android-0.13.0.aar differ diff --git a/android/src/main/jniLibs/armeabi-v7a/libonnxruntime.so b/android/src/main/jniLibs/armeabi-v7a/libonnxruntime.so deleted file mode 100644 index f119be6..0000000 Binary files a/android/src/main/jniLibs/armeabi-v7a/libonnxruntime.so and /dev/null differ diff --git a/ios/onnxruntime.podspec b/ios/onnxruntime.podspec index ebdb942..987727a 100644 --- a/ios/onnxruntime.podspec +++ b/ios/onnxruntime.podspec @@ -20,8 +20,9 @@ OnnxRuntime plugin for Flutter apps. s.source = { :path => '.' } # s.source_files = 'Classes/**/*' s.dependency 'Flutter' - s.dependency 'onnxruntime-objc', '1.15.1' - s.platform = :ios, '11.0' + s.dependency 'onnxruntime-objc', '1.20.0' + s.dependency 'onnxruntime-extensions-c', '0.13.0' + s.platform = :ios, '13.3' s.static_framework = true # Flutter.framework does not contain a i386 slice. diff --git a/src/build-scripts/build-android-extensions.sh b/src/build-scripts/build-android-extensions.sh new file mode 100644 index 0000000..e9efec2 --- /dev/null +++ b/src/build-scripts/build-android-extensions.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +./prepare-extensions.sh + +./tools/android/build_aar.py --output_dir build --config Release --mode build_aar --api_level 21 --sdk_path="$ANDROID_HOME/Sdk" --ndk_path="$ANDROID_HOME/Sdk/ndk/22.1.7171670" +# Output is ./build/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-extensions-android/0.13.0/onnxruntime-extensions-android-0.13.0.aar \ No newline at end of file diff --git a/src/build-scripts/build-android.sh b/src/build-scripts/build-android.sh new file mode 100644 index 0000000..488cd27 --- /dev/null +++ b/src/build-scripts/build-android.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +./prepare.sh + +python3 tools/android_custom_build/build_custom_android_package.py --onnxruntime_branch_or_tag v1.20.1 --build_settings tools/ci_build/github/android/default_full_aar_build_settings.json build +# Output is ./build/output/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-android/1.20.1/onnxruntime-android-1.20.1.aar \ No newline at end of file diff --git a/src/build-scripts/build-ios-extensions.sh b/src/build-scripts/build-ios-extensions.sh new file mode 100644 index 0000000..1f5d8ff --- /dev/null +++ b/src/build-scripts/build-ios-extensions.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +./prepare-extensions.sh + +# Tests fail with xcode build system +rm cmake/ext_tests.cmake +touch cmake/ext_tests.cmake + +python3 tools/ios/build_xcframework.py --output_dir build --mode build_xcframework --config Release --ios_deployment_target 13.3 --macos_deployment_target 16 -- --skip_tests --parallel \ No newline at end of file diff --git a/src/build-scripts/build-ios.sh b/src/build-scripts/build-ios.sh new file mode 100644 index 0000000..12bf6b9 --- /dev/null +++ b/src/build-scripts/build-ios.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +./prepare.sh + +# We need to make minor tweaks in order to make this buildable +sed -i 's/"--apple_deploy_target=14.0"/"--apple_deploy_target=16.0"/' tools/ci_build/github/apple/default_full_ios_framework_build_settings.json +sed -i 's/"--apple_deploy_target=13.0"/"--apple_deploy_target=13.3"/' tools/ci_build/github/apple/default_full_ios_framework_build_settings.json + +python3 tools/ci_build/github/apple/build_and_assemble_apple_pods.py --staging-dir build --build-settings-file tools/ci_build/github/apple/default_full_ios_framework_build_settings.json \ No newline at end of file diff --git a/src/build-scripts/prepare-extensions.sh b/src/build-scripts/prepare-extensions.sh new file mode 100644 index 0000000..67a645b --- /dev/null +++ b/src/build-scripts/prepare-extensions.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +dir_name="onnxruntime-extensions" +onnx_version=v0.13.0 + +if [ ! -d "$dir_name" ]; then + echo "Cloning onnxruntime-extensions..." + git clone https://github.com/microsoft/onnxruntime-extensions -b "$onnx_version" "$dir_name" + + if [ ! $? -eq 0 ]; then + echo "Failed to clone the onnxruntime-extensions repository." + exit 1 + fi +fi diff --git a/src/build-scripts/prepare.sh b/src/build-scripts/prepare.sh new file mode 100644 index 0000000..b54e759 --- /dev/null +++ b/src/build-scripts/prepare.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +dir_name="onnxruntime" +onnx_version=v1.20.1 + +if [ ! -d "$dir_name" ]; then + echo "Cloning onnxruntime..." + git clone https://github.com/microsoft/onnxruntime -b "$onnx_version" "$dir_name" + + if [ ! $? -eq 0 ]; then + echo "Failed to clone the onnxruntime repository." + exit 1 + fi +fi