mirror of https://github.com/FWGS/xash3d-fwgs
waifulib/xcompile: add objcopy tool to android configuration, allow switching to ndk binutils with host clang
This commit is contained in:
parent
55943ad1ce
commit
1b9af8c515
|
@ -44,6 +44,7 @@ class Android:
|
|||
ndk_rev = 0
|
||||
is_hardfloat = False
|
||||
clang = False
|
||||
ndk_binutils = False
|
||||
|
||||
def __init__(self, ctx, arch, toolchain, api):
|
||||
self.ctx = ctx
|
||||
|
@ -229,7 +230,7 @@ class Android:
|
|||
return self.gen_toolchain_path() + ('clang++' if self.is_clang() else 'g++')
|
||||
|
||||
def strip(self):
|
||||
if self.is_host():
|
||||
if self.is_host() and not self.ndk_binutils:
|
||||
environ = getattr(self.ctx, 'environ', os.environ)
|
||||
|
||||
if 'STRIP' in environ:
|
||||
|
@ -240,6 +241,18 @@ class Android:
|
|||
return os.path.join(self.gen_binutils_path(), 'llvm-strip')
|
||||
return os.path.join(self.gen_binutils_path(), 'strip')
|
||||
|
||||
def objcopy(self):
|
||||
if self.is_host() and not self.ndk_binutils:
|
||||
environ = getattr(self.ctx, 'environ', os.environ)
|
||||
|
||||
if 'OBJCOPY' in environ:
|
||||
return environ['OBJCOPY']
|
||||
return 'llvm-objcopy'
|
||||
|
||||
if self.ndk_rev >= 23:
|
||||
return os.path.join(self.gen_binutils_path(), 'llvm-objcopy')
|
||||
return os.path.join(self.gen_binutils_path(), 'objcopy')
|
||||
|
||||
def system_stl(self):
|
||||
# TODO: proper STL support
|
||||
#return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include')) broken with clang-15? TODO: check different ndk versions
|
||||
|
@ -327,7 +340,10 @@ class Android:
|
|||
if self.is_host():
|
||||
linkflags += ['--gcc-toolchain=%s' % self.gen_gcc_toolchain_path()]
|
||||
linkflags += ['--gcc-install-dir=%s/lib/gcc/%s/4.9/' % (self.gen_gcc_toolchain_path(), self.ndk_triplet())]
|
||||
linkflags += ['-fuse-ld=%s/bin/%s-ld.bfd' % (self.gen_gcc_toolchain_path(), self.ndk_triplet())]
|
||||
if self.ndk_binutils:
|
||||
linkflags += ['-fuse-ld=%s/bin/%s-ld.bfd' % (self.gen_gcc_toolchain_path(), self.ndk_triplet())]
|
||||
else:
|
||||
linkflags += ['-fuse-ld=lld']
|
||||
linkflags += ['--unwindlib=none']
|
||||
linkflags += ['--rtlib=libgcc']
|
||||
|
||||
|
@ -543,6 +559,7 @@ def configure(conf):
|
|||
conf.environ['CC'] = android.cc()
|
||||
conf.environ['CXX'] = android.cxx()
|
||||
conf.environ['STRIP'] = android.strip()
|
||||
conf.environ['OBJCOPY'] = android.objcopy()
|
||||
conf.env.CFLAGS += android.cflags()
|
||||
conf.env.CXXFLAGS += android.cflags(True)
|
||||
conf.env.LINKFLAGS += android.linkflags()
|
||||
|
|
Loading…
Reference in New Issue