1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#! /usr/bin/env python
# encoding: utf-8
#! /usr/bin/env python
# encoding: utf-8
# John O'Meara, 2006
"Bison processing"
import Object
def decide_ext(self, node):
c_ext = '.tab.c'
if node.m_name.endswith('.yc'): c_ext = '.tab.cc'
if '-d' in self.env['BISONFLAGS']:
return [c_ext, c_ext.replace('c', 'h')]
else:
return c_ext
Object.declare_chain(
name = 'bison',
action = 'cd ${SRC[0].bld_dir(env)} && ${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].m_name}',
ext_in = ['.y', '.yc'],
ext_out = decide_ext
)
def detect(conf):
bison = conf.find_program('bison', var='BISON')
if not bison: conf.fatal("bison was not found")
v = conf.env
v['BISONFLAGS'] = '-d'
|