3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
8 # Thomas Nagy 2009-2016 (ita)
11 The **bison** program is a code generator which creates C or C++ files.
12 The generated files are compiled into object files.
15 from waflib import Task
16 from waflib.TaskGen import extension
18 class bison(Task.Task):
19 """Compiles bison files"""
21 run_str = '${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}'
22 ext_out = ['.h'] # just to make sure
24 @extension('.y', '.yc', '.yy')
25 def big_bison(self, node):
27 Creates a bison task, which must be executed from the directory of the output file.
29 has_h = '-d' in self.env.BISONFLAGS
32 if node.name.endswith('.yc'):
33 outs.append(node.change_ext('.tab.cc'))
35 outs.append(node.change_ext('.tab.hh'))
37 outs.append(node.change_ext('.tab.c'))
39 outs.append(node.change_ext('.tab.h'))
41 tsk = self.create_task('bison', node, outs)
42 tsk.cwd = node.parent.get_bld()
44 # and the c/cxx file must be compiled too
45 self.source.append(outs[0])
49 Detects the *bison* program
51 conf.find_program('bison', var='BISON')
52 conf.env.BISONFLAGS = ['-d']