46 lines
1.8 KiB
Plaintext
46 lines
1.8 KiB
Plaintext
# 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)
|
|
|
|
host="linux-x86_64"
|
|
android_version="21"
|
|
|
|
toolchain_bindir = os.path.join(toolchain_root,'ndk-bundle','toolchains','llvm','prebuilt',host,'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)
|
|
}
|
|
|
|
AR= os.path.join(toolchain_bindir, "llvm-ar" + compiler_suffix)
|
|
AS= os.path.join(toolchain_bindir, android_tool_target + "-as" + compiler_suffix)
|
|
CC= os.path.join(toolchain_bindir, android_compiler_target + android_version + "-clang" + compiler_suffix)
|
|
CXX= os.path.join(toolchain_bindir, android_compiler_target + android_version + "-clang++" + compiler_suffix)
|
|
LD= os.path.join(toolchain_bindir, android_tool_target + "-ld" + compiler_suffix)
|
|
RANLIB= os.path.join(toolchain_bindir, android_tool_target + "-ranlib" + compiler_suffix)
|
|
STRIP= os.path.join(toolchain_bindir, android_tool_target + "-strip" + compiler_suffix)
|
|
OBJCOPY=os.path.join(toolchain_bindir, android_tool_target + "-objcopy" + compiler_suffix)
|
|
|
|
LINKFLAGS='-static-libstdc++ -fuse-ld=gold'
|
|
CXXFLAGS='-stdlib=libc++'
|
|
CPPDEFINES='__ANDROID_API__=' + android_version + ' _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR'
|
|
|
|
TARGET_OS="android"
|
|
TOOLS="gcc g++ gnulink ar gas"
|
|
PROGSUFFIX = ""
|