From 6ccae02aefabc453c1077b3dd613fd7a086cc0cf Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 6 Sep 2024 22:43:20 +0800 Subject: [PATCH] feat: install libcxx for android (#6) --- maadeps/runtime_android.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/maadeps/runtime_android.py b/maadeps/runtime_android.py index a9dd9ef..ae438c1 100644 --- a/maadeps/runtime_android.py +++ b/maadeps/runtime_android.py @@ -1,9 +1,11 @@ import os +import sys from pathlib import Path import subprocess import shutil from .common import resdir from . import runtime_linux as linux +from .vcpkg import triplet exclude = [ "*onnxruntime_providers_shared*", @@ -47,3 +49,24 @@ def install_runtime(target, debug): install_file(file, target_path) set_rpath(target_path, '$ORIGIN') split_debug(target_path, Path(debug, target_path.name + '.debug')) + + + print("Installing libc++_shared.so for Android") + android_ndk = os.environ.get("ANDROID_NDK_HOME", "/opt/android-ndk") + + if sys.platform == "win32" or sys.platform == "cygwin": + host = "windows-x86_64" + elif sys.platform == "linux": + host = "linux-x86_64" + elif sys.platform == "darwin": + host = "darwin-x86_64" + + if "arm64" in triplet: + runtime = "aarch64-linux-android" + elif "arm" in triplet: + runtime = "arm-linux-androideabi" + elif "x64" in triplet: + runtime = "x86_64-linux-android" + + libcxx_shared = os.path.join(android_ndk, f"toolchains/llvm/prebuilt/{host}/sysroot/usr/lib/{runtime}/libc++_shared.so") + install_file(libcxx_shared, target / "libc++_shared.so")