ort-customops/prebuild
Scott McKay c81981b74c
Enable using system certs on Android. (#543)
Disable in-memory cert store and loading certs from model.
  - TBD if it will be needed - need to know how reliable using the Android system certs will be and whether any scenarios need to have custom cert management.
2023-08-24 12:17:07 +10:00
..
build_curl_for_android.sh Enable using system certs on Android. (#543) 2023-08-24 12:17:07 +10:00
build_curl_for_android_on_linux.patch Enable using system certs on Android. (#543) 2023-08-24 12:17:07 +10:00
openssl_crypto_x509_android_hash.patch Enable using system certs on Android. (#543) 2023-08-24 12:17:07 +10:00
readme.md Refactor setup for Azure ops. Add Android support. (#507) 2023-08-08 19:54:30 +10:00

readme.md

Mobile Azure EP pre-build

Manual libraries that need to be prebuilt for the Azure operators on Android and iOS. There is no simple cmake setup that works, so we prebuild as a one-off.

Requirements:

  • pkg-config
  • Android
    • Android SDK installed with NDK 25 or later
      • You can install a package but that means you have to use sudo for all updates like installing an NDK

      • Using command line tools

        • Download the command line tools from https://developer.android.com/studio
          • Download the 'Command line tools only' and unzip
        • mkdir ~/Android
        • unzip commandlinetools-linux-9477386_latest.zip
        • mkdir -p ~/Android/cmdline-tools/latest
        • mv cmdline-tools/* ~/Android/cmdline-tools/latest
        • export ANDROID_HOME=~/Android
        • Add these to PATH
          • ~/Android/cmdline-tools/latest/bin
          • ~/Android/platform-tools/bin
        • sdkmanager --list to make sure the setup works
        • Install platform-tools and latest NDK
          • sdkmanager --install platform-tools
          • e.g. sdkmanager --install ndk;25.2.9519653

        That should be enough to build. e.g. ./build_lib.sh --android --android_api=24 --android_home=/home/me/Android --android_abi=x86_64 --android_ndk_path=/home/me/Android/ndk/25.2.9519653 --enable_cxx_tests

        See Android documentation for installing a system image with sdkmanager and creating an emulator with avdmanager.

  • iOS
    • TBD

Android build

Export ANDROID_NDK_ROOT with the value set to the NDK path as this is used by the build script

  • e.g. export ANDROID_NDK_ROOT=~/Android/ndk/25.2.9519653 From this directory run ./build_curl_for_android.sh An architecture can optionally be specified as the first argument to limit the build to that architecture. Otherwise all 4 architectures (arm, arm64, x86, x86_64) will be built. e.g. if you just want to build locally for the emulator you can do ./build_curl_for_android.sh x86_64

Android testing

Build with --enable_cxx_tests. This should result in the 'bin' directory of the build output having the two test executables. Create/start Android emulator Use adb push to copy bin, lib and data directories from the build output to the /data/local/tmp directory - adb push build/Android/bin /data/local/tmp - repeat for 'lib' and 'data'

  • copy the onnxruntime shared library to the lib dir (adjust version number as needed)
    • adjust architecture as needed (most likely x86_64 for emulator and arm)
    • adb push build/Android/Debug/_deps/onnxruntime-src/jni/x86_64/libonnxruntime.so /data/local/tmp/lib
  • Connect to emulator
    • adb shell
    • cd /data/local/tmp
    • Add path to .so
      • export LD_LIBRARY_PATH=/data/local/tmp/lib:$LD_LIBRARY_PATH
    • Make tests executable
      • chmod +x bin/ocos_test
      • chmod +x bin/extensions_test
    • Run tests from tmp dir so paths to data are as expected
      • ./bin/ocos_test
      • ./bin/extensions_test