lua.py 851 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Sebastian Schlingmann, 2008
  4. # Thomas Nagy, 2008-2018 (ita)
  5. """
  6. Lua support.
  7. Compile *.lua* files into *.luac*::
  8. def configure(conf):
  9. conf.load('lua')
  10. conf.env.LUADIR = '/usr/local/share/myapp/scripts/'
  11. def build(bld):
  12. bld(source='foo.lua')
  13. """
  14. from waflib.TaskGen import extension
  15. from waflib import Task
  16. @extension('.lua')
  17. def add_lua(self, node):
  18. tsk = self.create_task('luac', node, node.change_ext('.luac'))
  19. inst_to = getattr(self, 'install_path', self.env.LUADIR and '${LUADIR}' or None)
  20. if inst_to:
  21. self.add_install_files(install_to=inst_to, install_from=tsk.outputs)
  22. return tsk
  23. class luac(Task.Task):
  24. run_str = '${LUAC} -s -o ${TGT} ${SRC}'
  25. color = 'PINK'
  26. def configure(conf):
  27. """
  28. Detect the luac compiler and set *conf.env.LUAC*
  29. """
  30. conf.find_program('luac', var='LUAC')