add support libc++_shared stl on android
This commit is contained in:
parent
b5b8f52d4f
commit
b0419db46f
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
from compat import open_utf8
|
from compat import open_utf8
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
from detect import get_ndk_version
|
||||||
|
|
||||||
Import('env')
|
Import('env')
|
||||||
|
|
||||||
|
@ -169,3 +171,7 @@ if lib_arch_dir != '':
|
||||||
|
|
||||||
out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir
|
out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir
|
||||||
env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
|
env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
|
||||||
|
ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"])
|
||||||
|
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||||
|
stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so'
|
||||||
|
env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
|
|
@ -204,12 +204,20 @@ def configure(env):
|
||||||
|
|
||||||
## Compile flags
|
## Compile flags
|
||||||
|
|
||||||
|
if env['android_stl']:
|
||||||
|
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"])
|
||||||
|
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"])
|
||||||
|
env.Append(CXXFLAGS=['-frtti',"-std=gnu++14"])
|
||||||
|
else:
|
||||||
|
env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST'])
|
||||||
|
|
||||||
ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"])
|
ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"])
|
||||||
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||||
print("Using NDK unified headers")
|
print("Using NDK unified headers")
|
||||||
sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot"
|
sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot"
|
||||||
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
|
env.Append(CPPFLAGS=["--sysroot="+sysroot])
|
||||||
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath])
|
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath])
|
||||||
|
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/android/support/include"])
|
||||||
# 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(get_platform(env['ndk_platform']))])
|
env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(get_platform(env['ndk_platform']))])
|
||||||
else:
|
else:
|
||||||
|
@ -246,23 +254,24 @@ def configure(env):
|
||||||
env.Append(CPPFLAGS=target_opts)
|
env.Append(CPPFLAGS=target_opts)
|
||||||
env.Append(CPPFLAGS=common_opts)
|
env.Append(CPPFLAGS=common_opts)
|
||||||
|
|
||||||
if env['android_stl']:
|
|
||||||
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"])
|
|
||||||
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"])
|
|
||||||
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath])
|
|
||||||
env.Append(LIBS=["gnustl_static"])
|
|
||||||
else:
|
|
||||||
env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST'])
|
|
||||||
|
|
||||||
## Link flags
|
## Link flags
|
||||||
|
if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"):
|
||||||
|
if LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"):
|
||||||
|
env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a','-Wl,--exclude-libs,libatomic.a','-nostdlib++'])
|
||||||
|
env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel'])
|
||||||
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/"])
|
||||||
|
env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libandroid_support.a"])
|
||||||
|
env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libc++_shared.so"])
|
||||||
|
else:
|
||||||
|
env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel'])
|
||||||
|
if mt_link:
|
||||||
|
env.Append(LINKFLAGS=['-Wl,--threads'])
|
||||||
|
|
||||||
env['LINKFLAGS'] = ['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']
|
|
||||||
if env["android_arch"] == "armv7":
|
if env["android_arch"] == "armv7":
|
||||||
env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split())
|
env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split())
|
||||||
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:
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue