rendered paste body#!SCons
# Command line options
opts = Options()
opts.AddOptions(
BoolOption('DEBUG', 'Debug build', False),
BoolOption('OFFSET', 'Offset finding', False)
)
# Main build environment
env = Environment(options=opts)
env.Append(toolpath='.', tools=["DistZip"]);
# Generate help text
Help(opts.GenerateHelpText(env))
# Add default compiler flags
env.Append(
CPPFLAGS=['-m32', '-fPIC', '-march=i686', '-fno-strict-aliasing', '-fvisibility=hidden', '-DETH32_DEBUG'],
LINKFLAGS=['-m32', '-shared'],
LIBS=['m', 'pthread', 'elf', 'bfd', 'opcodes'],
)
env.MergeFlags('!pkg-config --cflags libelf')
# Release/Debug compiler flags
if env['DEBUG']:
env.Append(
CPPFLAGS=['-ggdb3'],
CPPDEFINES={'ETH32_DEBUG': '1'},
LIBS=['elf', 'bfd', 'opcodes'],
)
elif env['OFFSET']:
env.Append(
CPPFLAGS=['-ggdb3', '-DETH32_DEBUG', '-DETH32_PRELIM_OFFSETS'],
CPPDEFINES={'ETH32_DEBUG': '1'},
LIBS=['elf', 'bfd', 'opcodes'],
)
else:
env.Append(
CPPFLAGS=['-O3', '-ffast-math'],
LIBS=['dl'],
LINKFLAGS=['-s', '/usr/lib/libelf.a', '/usr/lib/libopcodes.a', '/usr/lib/libbfd.a'],
)
# Set build directory
if env['DEBUG']:
buildDir = 'build/debug'
elif env ['OFFSET']:
buildDir = 'build/offset'
else:
buildDir = 'build/release'
SConscript(
dirs='src',
build_dir=buildDir,
duplicate=False,
exports='env'
)
if 'zip' in COMMAND_LINE_TARGETS:
env.Append(toolpath = '.', tools = ["DistZip"]);
zip = env.DistZip("out.zip", [env.Dir('pk3')])
env.Alias("zip", zip)
env.Clean(DEFAULT_TARGETS, 'build')