|
@@ -16,13 +16,17 @@ def can_build():
|
|
return ("ANDROID_NDK_ROOT" in os.environ)
|
|
return ("ANDROID_NDK_ROOT" in os.environ)
|
|
|
|
|
|
|
|
|
|
|
|
+def get_platform(platform):
|
|
|
|
+ return int(platform.split("-")[1])
|
|
|
|
+
|
|
|
|
+
|
|
def get_opts():
|
|
def get_opts():
|
|
|
|
|
|
return [
|
|
return [
|
|
('ANDROID_NDK_ROOT', 'the path to Android NDK',
|
|
('ANDROID_NDK_ROOT', 'the path to Android NDK',
|
|
os.environ.get("ANDROID_NDK_ROOT", 0)),
|
|
os.environ.get("ANDROID_NDK_ROOT", 0)),
|
|
('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"),
|
|
('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"),
|
|
- ('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"),
|
|
|
|
|
|
+ ('android_arch', 'select compiler architecture: (armv7/armv6/arm64v8/x86)', "armv7"),
|
|
('android_neon', 'enable neon (armv7 only)', "yes"),
|
|
('android_neon', 'enable neon (armv7 only)', "yes"),
|
|
('android_stl', 'enable STL support in android port (for modules)', "no")
|
|
('android_stl', 'enable STL support in android port (for modules)', "no")
|
|
]
|
|
]
|
|
@@ -89,7 +93,7 @@ def configure(env):
|
|
|
|
|
|
ndk_platform = env['ndk_platform']
|
|
ndk_platform = env['ndk_platform']
|
|
|
|
|
|
- if env['android_arch'] not in ['armv7', 'armv6', 'x86']:
|
|
|
|
|
|
+ if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86']:
|
|
env['android_arch'] = 'armv7'
|
|
env['android_arch'] = 'armv7'
|
|
|
|
|
|
if env['android_arch'] == 'x86':
|
|
if env['android_arch'] == 'x86':
|
|
@@ -107,16 +111,19 @@ def configure(env):
|
|
env.Append(CPPPATH=['#platform/android'])
|
|
env.Append(CPPPATH=['#platform/android'])
|
|
|
|
|
|
if env['android_arch'] == 'x86':
|
|
if env['android_arch'] == 'x86':
|
|
|
|
+ env['ARCH'] = 'arch-x86'
|
|
env.extra_suffix = ".x86" + env.extra_suffix
|
|
env.extra_suffix = ".x86" + env.extra_suffix
|
|
target_subpath = "x86-4.9"
|
|
target_subpath = "x86-4.9"
|
|
abi_subpath = "i686-linux-android"
|
|
abi_subpath = "i686-linux-android"
|
|
arch_subpath = "x86"
|
|
arch_subpath = "x86"
|
|
elif env['android_arch'] == 'armv6':
|
|
elif env['android_arch'] == 'armv6':
|
|
|
|
+ env['ARCH'] = 'arch-arm'
|
|
env.extra_suffix = ".armv6" + env.extra_suffix
|
|
env.extra_suffix = ".armv6" + env.extra_suffix
|
|
target_subpath = "arm-linux-androideabi-4.9"
|
|
target_subpath = "arm-linux-androideabi-4.9"
|
|
abi_subpath = "arm-linux-androideabi"
|
|
abi_subpath = "arm-linux-androideabi"
|
|
arch_subpath = "armeabi"
|
|
arch_subpath = "armeabi"
|
|
elif env["android_arch"] == "armv7":
|
|
elif env["android_arch"] == "armv7":
|
|
|
|
+ env['ARCH'] = 'arch-arm'
|
|
target_subpath = "arm-linux-androideabi-4.9"
|
|
target_subpath = "arm-linux-androideabi-4.9"
|
|
abi_subpath = "arm-linux-androideabi"
|
|
abi_subpath = "arm-linux-androideabi"
|
|
arch_subpath = "armeabi-v7a"
|
|
arch_subpath = "armeabi-v7a"
|
|
@@ -124,6 +131,15 @@ def configure(env):
|
|
env.extra_suffix = ".armv7.neon" + env.extra_suffix
|
|
env.extra_suffix = ".armv7.neon" + env.extra_suffix
|
|
else:
|
|
else:
|
|
env.extra_suffix = ".armv7" + env.extra_suffix
|
|
env.extra_suffix = ".armv7" + env.extra_suffix
|
|
|
|
+ elif env["android_arch"] == "arm64v8":
|
|
|
|
+ if get_platform(ndk_platform) < 21:
|
|
|
|
+ print("WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than andorid-21; setting ndk_platform=android-21")
|
|
|
|
+ ndk_platform = "android-21"
|
|
|
|
+ env['ARCH'] = 'arch-arm64'
|
|
|
|
+ target_subpath = "aarch64-linux-android-4.9"
|
|
|
|
+ abi_subpath = "aarch64-linux-android"
|
|
|
|
+ arch_subpath = "arm64-v8a"
|
|
|
|
+ env.extra_suffix = ".armv8" + env.extra_suffix
|
|
|
|
|
|
mt_link = True
|
|
mt_link = True
|
|
if (sys.platform.startswith("linux")):
|
|
if (sys.platform.startswith("linux")):
|
|
@@ -137,10 +153,11 @@ def configure(env):
|
|
mt_link = False
|
|
mt_link = False
|
|
host_subpath = "windows"
|
|
host_subpath = "windows"
|
|
|
|
|
|
- compiler_path = env["ANDROID_NDK_ROOT"] + \
|
|
|
|
- "/toolchains/llvm/prebuilt/" + host_subpath + "/bin"
|
|
|
|
- gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + \
|
|
|
|
- "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath
|
|
|
|
|
|
+ if env["android_arch"] == "arm64v8":
|
|
|
|
+ mt_link = False
|
|
|
|
+
|
|
|
|
+ compiler_path = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/" + host_subpath + "/bin"
|
|
|
|
+ gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath
|
|
tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin"
|
|
tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin"
|
|
|
|
|
|
# For Clang to find NDK tools in preference of those system-wide
|
|
# For Clang to find NDK tools in preference of those system-wide
|
|
@@ -159,11 +176,6 @@ def configure(env):
|
|
env['RANLIB'] = tools_path + "/ranlib"
|
|
env['RANLIB'] = tools_path + "/ranlib"
|
|
env['AS'] = tools_path + "/as"
|
|
env['AS'] = tools_path + "/as"
|
|
|
|
|
|
- if env['android_arch'] == 'x86':
|
|
|
|
- env['ARCH'] = 'arch-x86'
|
|
|
|
- else:
|
|
|
|
- env['ARCH'] = 'arch-arm'
|
|
|
|
-
|
|
|
|
common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path]
|
|
common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path]
|
|
|
|
|
|
lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + ndk_platform + "/" + env['ARCH']
|
|
lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + ndk_platform + "/" + env['ARCH']
|
|
@@ -175,7 +187,7 @@ def configure(env):
|
|
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
|
|
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
|
|
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath])
|
|
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath])
|
|
# For unified headers this define has to be set manually
|
|
# For unified headers this define has to be set manually
|
|
- env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(int(ndk_platform.split("-")[1]))])
|
|
|
|
|
|
+ env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(get_platform(ndk_platform))])
|
|
else:
|
|
else:
|
|
print("Using NDK deprecated headers")
|
|
print("Using NDK deprecated headers")
|
|
env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"])
|
|
env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"])
|
|
@@ -204,6 +216,12 @@ def configure(env):
|
|
else:
|
|
else:
|
|
env.Append(CPPFLAGS=['-mfpu=vfpv3-d16'])
|
|
env.Append(CPPFLAGS=['-mfpu=vfpv3-d16'])
|
|
|
|
|
|
|
|
+ elif env["android_arch"] == "arm64v8":
|
|
|
|
+ can_vectorize = True
|
|
|
|
+ target_opts = ['-target', 'aarch64-none-linux-android']
|
|
|
|
+ env.Append(CPPFLAGS=['-D__ARM_ARCH_8A__'])
|
|
|
|
+ env.Append(CPPFLAGS=['-mfix-cortex-a53-835769'])
|
|
|
|
+
|
|
env.Append(CPPFLAGS=target_opts)
|
|
env.Append(CPPFLAGS=target_opts)
|
|
env.Append(CPPFLAGS=common_opts)
|
|
env.Append(CPPFLAGS=common_opts)
|
|
|
|
|
|
@@ -215,18 +233,20 @@ def configure(env):
|
|
env['SHLIBSUFFIX'] = '.so'
|
|
env['SHLIBSUFFIX'] = '.so'
|
|
|
|
|
|
env['LINKFLAGS'] = ['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']
|
|
env['LINKFLAGS'] = ['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']
|
|
- env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split())
|
|
|
|
|
|
+ if env["android_arch"] == "armv7":
|
|
|
|
+ env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8'))
|
|
env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split())
|
|
env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split())
|
|
env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split())
|
|
env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split())
|
|
|
|
+
|
|
if mt_link:
|
|
if mt_link:
|
|
env.Append(LINKFLAGS=['-Wl,--threads'])
|
|
env.Append(LINKFLAGS=['-Wl,--threads'])
|
|
env.Append(LINKFLAGS=target_opts)
|
|
env.Append(LINKFLAGS=target_opts)
|
|
env.Append(LINKFLAGS=common_opts)
|
|
env.Append(LINKFLAGS=common_opts)
|
|
|
|
|
|
- env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' +
|
|
|
|
|
|
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/' + target_subpath + '/prebuilt/' +
|
|
host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x'])
|
|
host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x'])
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] +
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] +
|
|
- '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib'])
|
|
|
|
|
|
+ '/toolchains/' + target_subpath + '/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib'])
|
|
|
|
|
|
if (env["target"].startswith("release")):
|
|
if (env["target"].startswith("release")):
|
|
env.Append(LINKFLAGS=['-O2'])
|
|
env.Append(LINKFLAGS=['-O2'])
|