4 # Thomas Nagy 2009-2018 (ita)
7 The **bison** program is a code generator which creates C or C++ files.
8 The generated files are compiled into object files.
11 from waflib import Task
12 from waflib.TaskGen import extension
14 class bison(Task.Task):
15 """Compiles bison files"""
17 run_str = '${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}'
18 ext_out = ['.h'] # just to make sure
20 @extension('.y', '.yc', '.yy')
21 def big_bison(self, node):
23 Creates a bison task, which must be executed from the directory of the output file.
25 has_h = '-d' in self.env.BISONFLAGS
28 if node.name.endswith('.yc'):
29 outs.append(node.change_ext('.tab.cc'))
31 outs.append(node.change_ext('.tab.hh'))
33 outs.append(node.change_ext('.tab.c'))
35 outs.append(node.change_ext('.tab.h'))
37 tsk = self.create_task('bison', node, outs)
38 tsk.cwd = node.parent.get_bld()
40 # and the c/cxx file must be compiled too
41 self.source.append(outs[0])
45 Detects the *bison* program
47 conf.find_program('bison', var='BISON')
48 conf.env.BISONFLAGS = ['-d']