Merge pull request #18 from alliedmodders/static-libstdcxx

Link amxxpc with static libstdc++ on Linux.
This commit is contained in:
Scott Ehlert 2014-05-18 19:04:43 -05:00
commit d83ec1810a
2 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,7 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python :
import os
import subprocess
import locale
class AMXXConfig(object):
def __init__(self):
@ -13,6 +15,7 @@ class AMXXConfig(object):
self.mysql_path = None
self.generated_headers = None
self.csx_app = None
self.stdcxx_path = None
def detectProductVersion(self):
builder.AddConfigureFile('product.version')
@ -93,6 +96,19 @@ class AMXXConfig(object):
if not self.mysql_path:
raise Exception('Could not find MySQL! Try passing --mysql to configure.py.')
# Returns list of lines of output from the compiler
@staticmethod
def invokeCompiler(args):
if builder.compiler:
p = subprocess.Popen(builder.compiler.argv + args, stdout=subprocess.PIPE)
output = p.communicate()[0]
if hasattr(output,'encoding') and output.encoding is not None:
encoding = output.encoding
else:
encoding = locale.getpreferredencoding()
return output.decode(encoding, 'replace').split('\n')
return None
def configure(self):
builder.AddConfigureFile('pushbuild.txt')
@ -199,6 +215,8 @@ class AMXXConfig(object):
cfg.postlink += ['-static-libgcc']
elif cxx.name == 'clang':
cfg.postlink += ['-lgcc_eh']
if cxx.behavior == 'gcc':
self.stdcxx_path = self.invokeCompiler(['-m32', '-print-file-name=' + 'libstdc++.a'])[0]
elif builder.target_platform == 'mac':
cfg.defines += ['OSX', '_OSX', 'POSIX']
cfg.cflags += ['-mmacosx-version-min=10.5']

View File

@ -14,6 +14,7 @@ if builder.target_platform == 'linux':
binary.compiler.postlink += [
'-ldl',
binary.Dep('libz.a'),
binary.Dep(AMXX.stdcxx_path),
]
elif builder.target_platform == 'mac':
binary.compiler.postlink += [binary.Dep('libz-darwin.a')]