resx.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. import os
  4. from waflib import Task
  5. from waflib.TaskGen import extension
  6. def configure(conf):
  7. conf.find_program(['resgen'], var='RESGEN')
  8. conf.env.RESGENFLAGS = '/useSourcePath'
  9. @extension('.resx')
  10. def resx_file(self, node):
  11. """
  12. Bind the .resx extension to a resgen task
  13. """
  14. if not getattr(self, 'cs_task', None):
  15. self.bld.fatal('resx_file has no link task for use %r' % self)
  16. # Given assembly 'Foo' and file 'Sub/Dir/File.resx', create 'Foo.Sub.Dir.File.resources'
  17. assembly = getattr(self, 'namespace', os.path.splitext(self.gen)[0])
  18. res = os.path.splitext(node.path_from(self.path))[0].replace('/', '.').replace('\\', '.')
  19. out = self.path.find_or_declare(assembly + '.' + res + '.resources')
  20. tsk = self.create_task('resgen', node, out)
  21. self.cs_task.dep_nodes.extend(tsk.outputs) # dependency
  22. self.env.append_value('RESOURCES', tsk.outputs[0].bldpath())
  23. class resgen(Task.Task):
  24. """
  25. Compile C# resource files
  26. """
  27. color = 'YELLOW'
  28. run_str = '${RESGEN} ${RESGENFLAGS} ${SRC} ${TGT}'