# Configures the build to use the Android NDK toolchain if supplied on the command line import os import platform import subprocess import SCons compiler_suffix = "" if platform.system() == "Windows": compiler_suffix = ".cmd" toolchain_root = SCons.Script.Main.GetOption('toolchain-root') if not toolchain_root: print("Path to Android standalone toolchain must be set with --toolchain-root when using android_toolchain.vars") SCons.Script.Exit(1) toolchain_bindir = os.path.join(toolchain_root, 'bin') # Get the default SCons path as a list default_path = SCons.Defaults.DefaultEnvironment()['ENV']['PATH'].split(os.pathsep) # Put the toolchain path first so we prefer all tools from there in subprocs ENV = { 'PATH' : os.pathsep.join([toolchain_bindir] + default_path) } CC=os.path.join(toolchain_bindir, "clang" + compiler_suffix) CXX=os.path.join(toolchain_bindir, "clang++" + compiler_suffix) try: AR = subprocess.check_output([CXX, '-print-prog-name=ar']).strip() AS = subprocess.check_output([CXX, '-print-prog-name=as']).strip() OBJCOPY = subprocess.check_output([CXX, '-print-prog-name=objcopy']).strip() except subprocess.CalledProcessError as e: print("Failed while invoking toolchain binary " + CXX + ": " + e.output) SCons.Script.Exit(-1) except OSError as e: print("Failed to invoke toolchain binary " + CXX + ": " + str(e)) SCons.Script.Exit(-1) LINKFLAGS='-static-libstdc++ -fuse-ld=gold' CPPDEFINES='__ANDROID_API__=21 _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR' TARGET_OS="android" TOOLS="gcc g++ gnulink ar gas" PROGSUFFIX = ""