sourcemod/sourcepawn/compiler/AMBuilder

117 lines
3.2 KiB
Plaintext
Raw Normal View History

2014-07-24 14:54:52 +02:00
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
2009-08-30 09:46:56 +02:00
import os
# Build the packing binary garbage.
scpack = SM.Program(builder, 'scpack')
2014-07-24 16:40:51 +02:00
if scpack.compiler.cc.behavior == 'msvc':
scpack.compiler.linkflags.remove('/SUBSYSTEM:WINDOWS')
scpack.compiler.linkflags.append('/SUBSYSTEM:CONSOLE')
scpack.compiler.cxxflags.remove('/TP')
scpack.sources = ['scpack.c']
scpack = builder.Add(scpack)
# Generate pack files.
packed_files = ['sc5', 'sc7']
packed_includes = []
for packed_file in packed_files:
2014-07-24 14:54:52 +02:00
# The absolute path to sc5-in.scp etc.
in_path = os.path.join(builder.currentSourcePath, '{0}-in.scp'.format(packed_file))
2014-07-24 14:54:52 +02:00
# The output file relative to the output folder, i.e. sourcepawn/compiler/sc5.scp.
out_path = os.path.join(builder.buildFolder, '{0}.scp'.format(packed_file))
2014-07-24 14:54:52 +02:00
# The absolute path to the build folder, i.e. /Users/.../sourcepawn/compiler.
build_folder = os.path.join(builder.buildPath, builder.buildFolder)
2014-07-24 14:54:52 +02:00
# scpack runs in ./sourcepawn/compiler/scpack/ so we build relative paths
# from there.
scpack_argv = [
os.path.join(builder.buildPath, scpack.binary.path),
os.path.relpath(in_path, build_folder),
os.path.relpath(os.path.join(builder.buildPath, out_path), build_folder),
]
2014-07-24 14:54:52 +02:00
_, (entry,) = builder.AddCommand(
inputs = [scpack.binary, in_path],
argv = scpack_argv,
outputs = ['{0}.scp'.format(packed_file)],
)
packed_includes += [entry]
binary = SM.Program(builder, 'spcomp')
compiler = binary.compiler
compiler.includes += [
os.path.join(builder.sourcePath, 'public'),
2014-08-22 08:36:26 +02:00
os.path.join(builder.sourcePath, 'public', 'amtl'),
os.path.join(builder.sourcePath, 'public', 'sourcepawn'),
os.path.join(builder.sourcePath, 'sourcepawn', 'compiler'),
os.path.join(builder.buildPath, 'includes'),
2014-07-24 14:54:52 +02:00
os.path.join(builder.buildPath, builder.buildFolder),
]
compiler.sourcedeps += packed_includes
if compiler.cc.behavior == 'gcc':
2014-08-22 08:36:26 +02:00
compiler.cflags += ['-Wno-format']
compiler.c_only_flags += ['-std=c99']
if builder.target_platform == 'linux':
compiler.postlink += ['-lgcc', '-lm']
elif compiler.cc.behavior == 'msvc':
compiler.linkflags.remove('/SUBSYSTEM:WINDOWS')
compiler.linkflags.append('/SUBSYSTEM:CONSOLE')
compiler.cxxflags.remove('/TP')
2014-08-23 05:41:24 +02:00
compiler.defines += ['HAVE_STDINT_H']
if builder.target_platform == 'linux':
compiler.defines += [
'LINUX',
'AMX_ANSIONLY',
'ENABLE_BINRELOC',
'_GNU_SOURCE'
]
elif builder.target_platform == 'mac':
compiler.defines += [
'DARWIN',
'AMX_ANSIONLY',
'ENABLE_BINRELOC',
'HAVE_SAFESTR'
]
binary.sources += [
2014-08-22 08:53:11 +02:00
'libpawnc.cpp',
2014-08-22 08:58:19 +02:00
'lstring.cpp',
2014-08-22 08:53:11 +02:00
'memfile.cpp',
'pawncc.cpp',
2014-08-22 09:38:04 +02:00
'sc1.cpp',
2014-08-22 09:23:02 +02:00
'sc2.cpp',
2014-08-22 09:17:00 +02:00
'sc3.cpp',
2014-08-22 09:12:16 +02:00
'sc4.cpp',
2014-08-22 09:09:28 +02:00
'sc5.cpp',
2014-08-22 09:07:40 +02:00
'sc6.cpp',
2014-08-22 09:04:48 +02:00
'sc7.cpp',
2014-08-22 09:00:31 +02:00
'scexpand.cpp',
'sci18n.cpp',
2014-08-22 08:58:19 +02:00
'sclist.cpp',
2014-08-22 08:53:11 +02:00
'scmemfil.cpp',
2014-08-22 08:54:10 +02:00
'scstate.cpp',
2014-08-22 09:39:03 +02:00
'sctracker.cpp',
'scvars.cpp',
2014-08-22 08:53:11 +02:00
'sp_file.cpp',
'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',
2014-08-22 08:36:26 +02:00
'sp_symhash.cpp'
]
2014-07-24 08:21:03 +02:00
if builder.target_platform != 'windows':
binary.sources.append('binreloc.c')
SM.spcomp = builder.Add(binary)