hammer/SConstruct

49 lines
1.3 KiB
Text
Raw Normal View History

2013-07-11 23:44:28 +02:00
# -*- python -*-
import os
env = Environment()
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -lrt")
AddOption("--variant",
dest="variant",
nargs=1, type="choice",
choices=["debug", "opt"],
2013-07-10 21:32:05 +02:00
default="opt",
action="store",
help="Build variant (debug or opt)")
2013-09-13 01:14:40 -07:00
AddOption("--coverage",
dest="coverage",
default=False,
action="store_true",
help="Build with coverage instrumentation")
env['BUILDDIR'] = 'build/$VARIANT'
dbg = env.Clone(VARIANT='debug')
dbg.Append(CCFLAGS=['-g'])
opt = env.Clone(VARIANT='opt')
opt.Append(CCFLAGS="-O3")
if GetOption("variant") == 'debug':
env = dbg
else:
env = opt
2013-07-11 23:44:28 +02:00
2013-09-13 01:14:40 -07:00
if GetOption("coverage"):
env.Append(CFLAGS=["-fprofile-arcs", "-ftest-coverage"],
CXXFLAGS=["-fprofile-arcs", "-ftest-coverage"],
LDFLAGS=["-fprofile-arcs", "-ftest-coverage"],
LIBS=['gcov'])
2013-07-11 23:44:28 +02:00
if os.getenv("CC") == "clang":
env.Replace(CC="clang",
CXX="clang++")
Export('env')
env.SConscript(["src/SConscript"], variant_dir='build/$VARIANT/src')
env.SConscript(["examples/SConscript"], variant_dir='build/$VARIANT/examples')
2013-07-10 21:32:05 +02:00
2013-07-11 23:44:28 +02:00
env.Command('test', 'build/$VARIANT/src/test_suite', 'env LD_LIBRARY_PATH=build/$VARIANT/src $SOURCE')