From c1a852d0e8a69f80bdff814c201ec0dac530a99a Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Wed, 13 Dec 2023 11:48:22 -0600 Subject: [PATCH] android: Pick toolchain based on current OS --- python/build/toolchain.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/build/toolchain.py b/python/build/toolchain.py index 70ea5289b..94617ba64 100644 --- a/python/build/toolchain.py +++ b/python/build/toolchain.py @@ -1,4 +1,5 @@ import os.path +import platform import shutil from typing import Union @@ -28,14 +29,22 @@ android_abis = { }, } +# https://developer.android.com/ndk/guides/other_build_systems +def build_arch() : + platforms = { + 'Linux': 'linux-x86_64', + 'Windows': 'windows-x86_64', + 'Darwin': 'darwin-x86_64' # Despite the x86_64 tag in the Darwin name, those are fat binaries that include M1 support. + } + + return platforms.get(platform.system()) + + class AndroidNdkToolchain: def __init__(self, top_path: str, lib_path: str, tarball_path: str, src_path: str, ndk_path: str, android_abi: str, use_cxx): - # build host configuration - build_arch = 'linux-x86_64' - # select the NDK target abi_info = android_abis[android_abi] host_triplet = abi_info['arch'] @@ -54,7 +63,7 @@ class AndroidNdkToolchain: self.host_triplet = host_triplet self.install_prefix = install_prefix - llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch) + llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch()) llvm_triple = host_triplet + android_api_level common_flags = '-Os -g'