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.

66 lines
1.9KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2011 (ita)
  4. """
  5. Experimental F# stuff
  6. FSC="mono /path/to/fsc.exe" waf configure build
  7. """
  8. from waflib import Utils, Task, Options, Logs, Errors
  9. from waflib.TaskGen import before_method, after_method, feature
  10. from waflib.Tools import ccroot, cs
  11. from waflib.Configure import conf
  12. ccroot.USELIB_VARS['fsc'] = set(['CSFLAGS', 'ASSEMBLIES', 'RESOURCES'])
  13. @feature('fs')
  14. @before_method('process_source')
  15. def apply_fsc(self):
  16. cs_nodes = []
  17. no_nodes = []
  18. for x in self.to_nodes(self.source):
  19. if x.name.endswith('.fs'):
  20. cs_nodes.append(x)
  21. else:
  22. no_nodes.append(x)
  23. self.source = no_nodes
  24. bintype = getattr(self, 'type', self.gen.endswith('.dll') and 'library' or 'exe')
  25. self.cs_task = tsk = self.create_task('fsc', cs_nodes, self.path.find_or_declare(self.gen))
  26. tsk.env.CSTYPE = '/target:%s' % bintype
  27. tsk.env.OUT = '/out:%s' % tsk.outputs[0].abspath()
  28. inst_to = getattr(self, 'install_path', bintype=='exe' and '${BINDIR}' or '${LIBDIR}')
  29. if inst_to:
  30. # note: we are making a copy, so the files added to cs_task.outputs won't be installed automatically
  31. mod = getattr(self, 'chmod', bintype=='exe' and Utils.O755 or Utils.O644)
  32. self.install_task = self.bld.install_files(inst_to, self.cs_task.outputs[:], env=self.env, chmod=mod)
  33. feature('fs')(cs.use_cs)
  34. after_method('apply_fsc')(cs.use_cs)
  35. feature('fs')(cs.debug_cs)
  36. after_method('apply_fsc', 'use_cs')(cs.debug_cs)
  37. class fsc(Task.Task):
  38. """
  39. Compile F# files
  40. """
  41. color = 'YELLOW'
  42. run_str = '${FSC} ${CSTYPE} ${CSFLAGS} ${ASS_ST:ASSEMBLIES} ${RES_ST:RESOURCES} ${OUT} ${SRC}'
  43. def configure(conf):
  44. """
  45. Find a F# compiler, set the variable FSC for the compiler and FS_NAME (mono or fsc)
  46. """
  47. conf.find_program(['fsc.exe', 'fsharpc'], var='FSC')
  48. conf.env.ASS_ST = '/r:%s'
  49. conf.env.RES_ST = '/resource:%s'
  50. conf.env.FS_NAME = 'fsc'
  51. if str(conf.env.FSC).lower().find('fsharpc') > -1:
  52. conf.env.FS_NAME = 'mono'