Add android ndk support to scons
This commit is contained in:
parent
1fb83c3c7a
commit
26f56e767b
3 changed files with 48 additions and 9 deletions
|
@ -103,6 +103,8 @@ opts.AddVariables(
|
|||
PathVariable('gtkdir', 'Directory where GTK SDK is installed.', "", OptionalPath),
|
||||
PathVariable('luadir', 'Directory where Lua binary package is unpacked.', "", OptionalPath),
|
||||
('host', 'Cross-compile host.', ''),
|
||||
PathVariable('ndkdir', 'Root directory of android NDK to use', "", OptionalPath),
|
||||
('android_api', 'Target android api', 31),
|
||||
EnumVariable('multilib_arch', 'Address model for multilib compiler: 32-bit or 64-bit', "", ["", "32", "64"]),
|
||||
('jobs', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
|
||||
BoolVariable('distcc', 'Use distcc', False),
|
||||
|
|
34
scons/android-ndk.py
Normal file
34
scons/android-ndk.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# vi: syntax=python:et:ts=4
|
||||
import json
|
||||
|
||||
#Intended usage:
|
||||
#- env["ndkdir"] set to ndk home
|
||||
#- env["android_api"] set to target api
|
||||
#- host needs to be set to android-$ABI where $ABI is one of keys in
|
||||
# ndkdir/meta/abis.json
|
||||
#- prefix needs to be set to sysroot containing cross-compiled
|
||||
# dependencies for matching android abi
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
def generate(env):
|
||||
api = env["android_api"]
|
||||
ndk = env["ndkdir"]
|
||||
|
||||
assert ndk
|
||||
|
||||
android, abi = env["host"].split("-", 1)
|
||||
assert android == "android"
|
||||
|
||||
abi_spec = json.load(open(ndk + "/meta/abis.json"))[abi]
|
||||
print(abi_spec)
|
||||
env["ANDROID_TOOLCHAIN"] = f"{ndk}/toolchains/llvm/prebuilt/linux-x86_64"
|
||||
env["AR"] = "$ANDROID_TOOLCHAIN/bin/llvm-ar"
|
||||
env["CC"] = "$ANDROID_TOOLCHAIN/bin/clang"
|
||||
env["CXX"] = "$ANDROID_TOOLCHAIN/bin/clang++"
|
||||
#env["LINK"] = "$ANDROID_TOOLCHAIN/bin/ld"
|
||||
env["RANLIB"] = "$ANDROID_TOOLCHAIN/bin/llvm-ranlib"
|
||||
env["ANDROID_LLVM_TRIPLE"] = abi_spec["llvm_triple"]
|
||||
env.Append(CCFLAGS = "-target $ANDROID_LLVM_TRIPLE$android_api")
|
||||
env.Append(LINKFLAGS = "-target $ANDROID_LLVM_TRIPLE$android_api")
|
|
@ -11,16 +11,19 @@ def setup_cross_compile(env):
|
|||
env.Tool("default")
|
||||
|
||||
if env["host"]:
|
||||
tools = [
|
||||
"CXX",
|
||||
"CC",
|
||||
"AR",
|
||||
"RANLIB",
|
||||
"RC"
|
||||
if env["host"].startswith("android-"):
|
||||
env.Tool("android-ndk")
|
||||
else:
|
||||
tools = [
|
||||
"CXX",
|
||||
"CC",
|
||||
"AR",
|
||||
"RANLIB",
|
||||
"RC"
|
||||
]
|
||||
for tool in tools:
|
||||
if tool in env:
|
||||
env[tool] = env["host"] + "-" + env[tool]
|
||||
for tool in tools:
|
||||
if tool in env:
|
||||
env[tool] = env["host"] + "-" + env[tool]
|
||||
|
||||
env.PrependUnique(CPPPATH="$prefix/include", LIBPATH="$prefix/lib")
|
||||
if not env["sdldir"] and env["PLATFORM"] == "win32":
|
||||
|
|
Loading…
Add table
Reference in a new issue