From e9a7c0b83d18bb8c03b7a5255783be6dddc30d05 Mon Sep 17 00:00:00 2001
From: Dan Hirsch <thequux@upstandinghackers.com>
Date: Mon, 24 Jun 2013 21:26:07 +0200
Subject: [PATCH] Added new SConscript-based build system; not yet done porting

---
 SConstruct          | 30 +++++++++++++++++++++++
 examples/SConscript |  9 +++++++
 src/SConscript      | 59 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 SConstruct
 create mode 100644 examples/SConscript
 create mode 100644 src/SConscript

diff --git a/SConstruct b/SConstruct
new file mode 100644
index 00000000..10bcdecd
--- /dev/null
+++ b/SConstruct
@@ -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')
diff --git a/examples/SConscript b/examples/SConscript
new file mode 100644
index 00000000..94f32ac9
--- /dev/null
+++ b/examples/SConscript
@@ -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')
diff --git a/src/SConscript b/src/SConscript
new file mode 100644
index 00000000..70868a41
--- /dev/null
+++ b/src/SConscript
@@ -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'])
+    
-- 
GitLab