3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
8 # Thomas Nagy, 2006-2016 (ita)
11 The **flex** program is a code generator which creates C or C++ files.
12 The generated files are compiled into object files.
16 from waflib import Task, TaskGen
17 from waflib.Tools import ccroot
19 def decide_ext(self, node):
20 if 'cxx' in self.features:
26 bld = tsk.generator.bld
29 if isinstance(xx, str): return [xx]
31 tsk.last_cmd = lst = []
32 lst.extend(to_list(env.FLEX))
33 lst.extend(to_list(env.FLEXFLAGS))
34 inputs = [a.path_from(tsk.get_cwd()) for a in tsk.inputs]
36 inputs = [x.replace(os.sep, '/') for x in inputs]
38 lst = [x for x in lst if x]
39 txt = bld.cmd_and_log(lst, cwd=wd, env=env.env or None, quiet=0)
40 tsk.outputs[0].write(txt.replace('\r\n', '\n').replace('\r', '\n')) # issue #1207
42 TaskGen.declare_chain(
44 rule = flexfun, # issue #854
49 # To support the following:
50 # bld(features='c', flexflags='-P/foo')
51 Task.classes['flex'].vars = ['FLEXFLAGS', 'FLEX']
52 ccroot.USELIB_VARS['c'].add('FLEXFLAGS')
53 ccroot.USELIB_VARS['cxx'].add('FLEXFLAGS')
57 Detect the *flex* program
59 conf.find_program('flex', var='FLEX')
60 conf.env.FLEXFLAGS = ['-t']
62 if re.search (r"\\msys\\[0-9.]+\\bin\\flex.exe$", conf.env.FLEX[0]):
63 # this is the flex shipped with MSYS
64 conf.env.FLEX_MSYS = True