sourcemod/sourcepawn/compiler/AMBuilder
Asher Baker 29ddb9f4d9 Fix spcomp compilation on OS X 10.9
Summary:
10.9's SDK changed strlcat and strlcmp to macros, which has broken lots of code. As they will always be available from the system (being BSD functions), just use the system ones there.

tempnam has also been deprecated, refactoring spcomp to use it safely is quite a bit of work, and it's not critical, so just hacking around it with mkstemp.

Test Plan: Compiled spcomp.

Reviewers: dvander

Differential Revision: https://phabricator.alliedmods.net/D3

--HG--
extra : rebase_source : 535b88f815727b186fa6a141036599651a60e334
2013-12-02 13:08:27 +00:00

73 lines
2.2 KiB
Python

# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
compiler = SM.DefaultCompiler()
compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public'))
compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourcepawn'))
compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'compiler'))
compiler['CINCLUDES'].append(os.path.join(AMBuild.outputFolder, 'includes'))
if compiler.cc.name == 'gcc' or compiler.cc.name == 'clang':
compiler['CFLAGS'].append('-Wno-format')
if AMBuild.target['platform'] == 'linux':
compiler['POSTLINKFLAGS'].extend(['-lgcc', '-lm'])
elif compiler.cc.name == 'msvc':
compiler['POSTLINKFLAGS'].remove('/SUBSYSTEM:WINDOWS')
compiler['POSTLINKFLAGS'].append('/SUBSYSTEM:CONSOLE')
if AMBuild.target['platform'] == 'linux':
compiler['CDEFINES'].extend(['LINUX', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC', '_GNU_SOURCE'])
elif AMBuild.target['platform'] == 'darwin':
compiler['CDEFINES'].extend(['DARWIN', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC', 'HAVE_SAFESTR'])
extension = AMBuild.AddJob('spcomp')
binary = Cpp.ExecutableBuilder('spcomp', AMBuild, extension, compiler)
files = [
'libpawnc.c',
'lstring.c',
'memfile.c',
'pawncc.c',
'sc1.c',
'sc2.c',
'sc3.c',
'sc4.c',
'sc5.c',
'sc6.c',
'sc7.c',
'scexpand.c',
'sci18n.c',
'sclist.c',
'scmemfil.c',
'scstate.c',
'sctracker.c',
'scvars.c',
'sp_file.c',
'zlib/adler32.c',
'zlib/compress.c',
'zlib/crc32.c',
'zlib/deflate.c',
'zlib/gzio.c',
'zlib/infback.c',
'zlib/inffast.c',
'zlib/inflate.c',
'zlib/inftrees.c',
'zlib/trees.c',
'zlib/uncompr.c',
'zlib/zutil.c',
'sp_symhash.c'
]
if AMBuild.target['platform'] == 'linux':
files.append('binreloc.c')
binary.AddSourceFiles('sourcepawn/compiler', files)
if AMBuild.target['platform'] == 'windows':
env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"', 'SM_GENERATED_BUILD']}
binary.AddResourceFile('sourcepawn/compiler/libpawnc.rc', env)
elif AMBuild.target['platform'] == 'darwin' and isinstance(binary, Cpp.LibraryBuilder):
binary.compiler['POSTLINKFLAGS'].extend(['-compatibility_version', '1.0.0'])
binary.compiler['POSTLINKFLAGS'].extend(['-current_version', AMBuild.cache['version']])
SM.ExtractDebugInfo(extension, binary)
binary.SendToJob()