jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # John O'Meara, 2006
  4. # Thomas Nagy, 2006-2010 (ita)
  5. """
  6. The **flex** program is a code generator which creates C or C++ files.
  7. The generated files are compiled into object files.
  8. """
  9. import waflib.TaskGen, os, re
  10. def decide_ext(self, node):
  11. if 'cxx' in self.features:
  12. return ['.lex.cc']
  13. return ['.lex.c']
  14. def flexfun(tsk):
  15. env = tsk.env
  16. bld = tsk.generator.bld
  17. wd = bld.variant_dir
  18. def to_list(xx):
  19. if isinstance(xx, str): return [xx]
  20. return xx
  21. tsk.last_cmd = lst = []
  22. lst.extend(to_list(env['FLEX']))
  23. lst.extend(to_list(env['FLEXFLAGS']))
  24. inputs = [a.path_from(bld.bldnode) for a in tsk.inputs]
  25. if env.FLEX_MSYS:
  26. inputs = [x.replace(os.sep, '/') for x in inputs]
  27. lst.extend(inputs)
  28. lst = [x for x in lst if x]
  29. txt = bld.cmd_and_log(lst, cwd=wd, env=env.env or None, quiet=0)
  30. tsk.outputs[0].write(txt.replace('\r\n', '\n').replace('\r', '\n')) # issue #1207
  31. waflib.TaskGen.declare_chain(
  32. name = 'flex',
  33. rule = flexfun, # issue #854
  34. ext_in = '.l',
  35. decider = decide_ext,
  36. )
  37. def configure(conf):
  38. """
  39. Detect the *flex* program
  40. """
  41. conf.find_program('flex', var='FLEX')
  42. conf.env.FLEXFLAGS = ['-t']
  43. if re.search (r"\\msys\\[0-9.]+\\bin\\flex.exe$", conf.env.FLEX[0]):
  44. # this is the flex shipped with MSYS
  45. conf.env.FLEX_MSYS = True