mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-23 21:24:27 +00:00
waifulib: xcompile: append SONAME to shared libraries, experimental support for host compiling with NDK r10e(don't work), replace exceptions with fatal messages
This commit is contained in:
parent
cb51d2aa17
commit
56ac345977
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
try: from fwgslib import get_flags_by_compiler
|
try: from fwgslib import get_flags_by_compiler
|
||||||
except: from waflib.extras.fwgslib import get_flags_by_compiler
|
except: from waflib.extras.fwgslib import get_flags_by_compiler
|
||||||
from waflib import Logs
|
from waflib import Logs, TaskGen
|
||||||
from waflib.Tools import c_config
|
from waflib.Tools import c_config
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import os
|
import os
|
||||||
@ -142,13 +142,14 @@ class Android:
|
|||||||
def gen_gcc_toolchain_path(self):
|
def gen_gcc_toolchain_path(self):
|
||||||
path = 'toolchains'
|
path = 'toolchains'
|
||||||
|
|
||||||
if sys.platform.startswith('linux') or self.is_host():
|
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
|
||||||
toolchain_host = 'linux'
|
toolchain_host = 'windows'
|
||||||
elif sys.platform.startswith('darwin'):
|
elif sys.platform.startswith('darwin'):
|
||||||
toolchain_host = 'darwin'
|
toolchain_host = 'darwin'
|
||||||
elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
|
elif sys.platform.startswith('linux') or self.is_host():
|
||||||
toolchain_host = 'windows'
|
toolchain_host = 'linux'
|
||||||
else: raise Exception('Unsupported by NDK host platform')
|
else:
|
||||||
|
self.ctx.fatal('Unsupported by NDK host platform')
|
||||||
|
|
||||||
toolchain_host += '-'
|
toolchain_host += '-'
|
||||||
|
|
||||||
@ -159,11 +160,16 @@ class Android:
|
|||||||
|
|
||||||
if self.is_clang():
|
if self.is_clang():
|
||||||
if self.ndk_rev < 19:
|
if self.ndk_rev < 19:
|
||||||
raise Exception('Clang is not supported for this NDK')
|
raise self.ctx.fatal('Clang is not supported for this NDK')
|
||||||
|
|
||||||
toolchain_folder = 'llvm'
|
toolchain_folder = 'llvm'
|
||||||
else:
|
else:
|
||||||
toolchain_folder = '%s-%s' % (self.ndk_triplet(toolchain_folder = True), self.toolchain)
|
if self.is_host():
|
||||||
|
toolchain = '4.9'
|
||||||
|
else:
|
||||||
|
toolchain = self.toolchain
|
||||||
|
|
||||||
|
toolchain_folder = '%s-%s' % (self.ndk_triplet(toolchain_folder = True), toolchain)
|
||||||
|
|
||||||
return os.path.abspath(os.path.join(self.ndk_home, path, toolchain_folder, 'prebuilt', toolchain_host))
|
return os.path.abspath(os.path.join(self.ndk_home, path, toolchain_folder, 'prebuilt', toolchain_host))
|
||||||
|
|
||||||
@ -207,7 +213,7 @@ class Android:
|
|||||||
return os.path.abspath(os.path.join(self.ndk_home, path))
|
return os.path.abspath(os.path.join(self.ndk_home, path))
|
||||||
|
|
||||||
def sysroot(self):
|
def sysroot(self):
|
||||||
if self.ndk_rev >= 19 or self.is_host():
|
if self.ndk_rev >= 19:
|
||||||
return os.path.abspath(os.path.join(self.ndk_home, 'sysroot'))
|
return os.path.abspath(os.path.join(self.ndk_home, 'sysroot'))
|
||||||
else:
|
else:
|
||||||
return self.libsysroot()
|
return self.libsysroot()
|
||||||
@ -215,10 +221,12 @@ class Android:
|
|||||||
def cflags(self):
|
def cflags(self):
|
||||||
cflags = []
|
cflags = []
|
||||||
if self.is_host():
|
if self.is_host():
|
||||||
cflags += [
|
if self.ndk_rev >= 19:
|
||||||
'--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path()),
|
cflags += [
|
||||||
'-I%s/usr/include/' % (self.sysroot())
|
'--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path()),
|
||||||
]
|
'-I%s/usr/include/' % (self.sysroot())
|
||||||
|
]
|
||||||
|
else: cflags += ['--sysroot=%s' % (self.sysroot())]
|
||||||
elif self.ndk_rev < 20:
|
elif self.ndk_rev < 20:
|
||||||
cflags += ['--sysroot=%s' % (self.sysroot())]
|
cflags += ['--sysroot=%s' % (self.sysroot())]
|
||||||
|
|
||||||
@ -228,7 +236,7 @@ class Android:
|
|||||||
# ARMv7 support
|
# ARMv7 support
|
||||||
cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS']
|
cflags += ['-mthumb', '-mfpu=neon', '-mcpu=cortex-a9', '-DHAVE_EFFICIENT_UNALIGNED_ACCESS', '-DVECTORIZE_SINCOS']
|
||||||
|
|
||||||
if not self.is_clang():
|
if not self.is_clang() and not self.is_host():
|
||||||
cflags += [ '-mvectorize-with-neon-quad' ]
|
cflags += [ '-mvectorize-with-neon-quad' ]
|
||||||
|
|
||||||
if self.is_hardfloat:
|
if self.is_hardfloat:
|
||||||
@ -248,11 +256,15 @@ class Android:
|
|||||||
if self.is_host():
|
if self.is_host():
|
||||||
linkflags += ['--gcc-toolchain=%s' % self.gen_gcc_toolchain_path()]
|
linkflags += ['--gcc-toolchain=%s' % self.gen_gcc_toolchain_path()]
|
||||||
|
|
||||||
if self.ndk_rev < 20 or self.is_host():
|
if self.ndk_rev < 20:
|
||||||
|
linkflags += ['--sysroot=%s' % (self.sysroot())]
|
||||||
|
elif self.is_host():
|
||||||
linkflags += ['--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path())]
|
linkflags += ['--sysroot=%s/sysroot' % (self.gen_gcc_toolchain_path())]
|
||||||
|
|
||||||
if self.is_clang():
|
if self.is_clang() or self.is_host():
|
||||||
linkflags += ['-fuse-ld=lld']
|
linkflags += ['-fuse-ld=lld']
|
||||||
|
|
||||||
|
linkflags += ['-Wl,--hash-style=both']
|
||||||
return linkflags
|
return linkflags
|
||||||
|
|
||||||
def ldflags(self):
|
def ldflags(self):
|
||||||
@ -260,7 +272,7 @@ class Android:
|
|||||||
if self.is_arm():
|
if self.is_arm():
|
||||||
if self.arch == 'armeabi-v7a':
|
if self.arch == 'armeabi-v7a':
|
||||||
ldflags += ['-march=armv7-a', '-mthumb']
|
ldflags += ['-march=armv7-a', '-mthumb']
|
||||||
if not self.is_clang(): # lld only
|
if not self.is_clang() and not self.is_host(): # lld only
|
||||||
ldflags += ['-Wl,--fix-cortex-a8']
|
ldflags += ['-Wl,--fix-cortex-a8']
|
||||||
if self.is_hardfloat:
|
if self.is_hardfloat:
|
||||||
ldflags += ['-Wl,--no-warn-mismatch', '-lm_hard']
|
ldflags += ['-Wl,--no-warn-mismatch', '-lm_hard']
|
||||||
@ -347,3 +359,20 @@ def patch_compiler_c_configure(conf):
|
|||||||
|
|
||||||
setattr(compiler_cxx, 'configure', patch_compiler_cxx_configure)
|
setattr(compiler_cxx, 'configure', patch_compiler_cxx_configure)
|
||||||
setattr(compiler_c, 'configure', patch_compiler_c_configure)
|
setattr(compiler_c, 'configure', patch_compiler_c_configure)
|
||||||
|
|
||||||
|
@TaskGen.feature('cshlib', 'cxxshlib', 'dshlib', 'fcshlib', 'vnum')
|
||||||
|
@TaskGen.after_method('apply_link', 'propagate_uselib_vars')
|
||||||
|
@TaskGen.before_method('apply_vnum')
|
||||||
|
def apply_android_soname(self):
|
||||||
|
"""
|
||||||
|
Enforce SONAME on Android
|
||||||
|
"""
|
||||||
|
if self.env.DEST_OS != 'android':
|
||||||
|
return
|
||||||
|
|
||||||
|
setattr(self, 'vnum', None) # remove vnum, so SONAME would not be overwritten
|
||||||
|
link = self.link_task
|
||||||
|
node = link.outputs[0]
|
||||||
|
libname = node.name
|
||||||
|
v = self.env.SONAME_ST % libname
|
||||||
|
self.env.append_value('LINKFLAGS', v.split())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user