Added new SConscript-based build system; not yet done porting

This commit is contained in:
Dan Hirsch 2013-06-24 21:26:07 +02:00
parent ce74cf7939
commit e9a7c0b83d
3 changed files with 98 additions and 0 deletions

30
SConstruct Normal file
View file

@ -0,0 +1,30 @@
env = Environment()
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes")
env['MODE'] = 'shared'
AddOption("--variant",
dest="variant",
nargs=1, type="choice",
choices=["debug", "opt"],
default="debug",
action="store",
help="Build variant (debug or opt)")
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
Export('env')
env.SConscript(["src/SConscript"], variant_dir='build/$VARIANT/src')
env.SConscript(["examples/SConscript"], variant_dir='build/$VARIANT/examples')

9
examples/SConscript Normal file
View file

@ -0,0 +1,9 @@
Import('env')
example = env.Clone()
example.Append(LIBS="hammer", LIBPATH="../src")
example.Program('dns', ['dns.c', 'rr.c', 'dns_common.c'])
example.Program('base64', 'base64.c')
example.Program('base64_sem1', 'base64_sem1.c')
example.Program('base64_sem2', 'base64_sem2.c')

59
src/SConscript Normal file
View file

@ -0,0 +1,59 @@
Import('env')
parsers = ['parsers/%s.c'%s for s in
['action',
'and',
'attr_bool',
'bits',
'butnot',
'ch',
'charset',
'choice',
'difference',
'end',
'epsilon',
'ignore',
'ignoreseq',
'indirect',
'int_range',
'many',
'not',
'nothing',
'optional',
'sequence',
'token',
'unimplemented',
'whitespace',
'xor']]
backends = ['backends/%s.c' % s for s in
['packrat', 'llk', 'regex']]
misc_hammer_parts = [
'allocator.c',
'benchmark.c',
'bitreader.c',
'bitwriter.c',
'cfgrammar.c',
'datastructures.c',
'desugar.c',
'glue.c',
'hammer.c',
'pprint.c',
'system_allocator.c']
tests = ['t_benchmark.c',
't_bitreader.c',
't_bitwriter.c',
't_parser.c',
't_grammar.c',
't_misc.c']
libhammer = env.SharedLibrary('hammer', parsers + backends + misc_hammer_parts)
libhammer = env.StaticLibrary('hammer', parsers + backends + misc_hammer_parts)
testenv = env.Clone()
testenv.ParseConfig('pkg-config --cflags --libs glib-2.0')
testenv.Append(LIBS=['hammer'], LIBPATH=['.'])
testenv.Program('test_suite', tests + ['test_suite.c'])