boo.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # Yannick LM 2011
  4. """
  5. Support for the boo programming language, for example::
  6. bld(features = "boo", # necessary feature
  7. source = "src.boo", # list of boo files
  8. gen = "world.dll", # target
  9. type = "library", # library/exe ("-target:xyz" flag)
  10. name = "world" # necessary if the target is referenced by 'use'
  11. )
  12. """
  13. from waflib import Task
  14. from waflib.Configure import conf
  15. from waflib.TaskGen import feature, after_method, before_method, extension
  16. @extension('.boo')
  17. def boo_hook(self, node):
  18. # Nothing here yet ...
  19. # TODO filter the non-boo source files in 'apply_booc' and remove this method
  20. pass
  21. @feature('boo')
  22. @before_method('process_source')
  23. def apply_booc(self):
  24. """Create a booc task """
  25. src_nodes = self.to_nodes(self.source)
  26. out_node = self.path.find_or_declare(self.gen)
  27. self.boo_task = self.create_task('booc', src_nodes, [out_node])
  28. # Set variables used by the 'booc' task
  29. self.boo_task.env.OUT = '-o:%s' % out_node.abspath()
  30. # type is "exe" by default
  31. type = getattr(self, "type", "exe")
  32. self.boo_task.env.BOO_TARGET_TYPE = "-target:%s" % type
  33. @feature('boo')
  34. @after_method('apply_boo')
  35. def use_boo(self):
  36. """"
  37. boo applications honor the **use** keyword::
  38. """
  39. dep_names = self.to_list(getattr(self, 'use', []))
  40. for dep_name in dep_names:
  41. dep_task_gen = self.bld.get_tgen_by_name(dep_name)
  42. if not dep_task_gen:
  43. continue
  44. dep_task_gen.post()
  45. dep_task = getattr(dep_task_gen, 'boo_task', None)
  46. if not dep_task:
  47. # Try a cs task:
  48. dep_task = getattr(dep_task_gen, 'cs_task', None)
  49. if not dep_task:
  50. # Try a link task:
  51. dep_task = getattr(dep_task, 'link_task', None)
  52. if not dep_task:
  53. # Abort ...
  54. continue
  55. self.boo_task.set_run_after(dep_task) # order
  56. self.boo_task.dep_nodes.extend(dep_task.outputs) # dependency
  57. self.boo_task.env.append_value('BOO_FLAGS', '-reference:%s' % dep_task.outputs[0].abspath())
  58. class booc(Task.Task):
  59. """Compiles .boo files """
  60. color = 'YELLOW'
  61. run_str = '${BOOC} ${BOO_FLAGS} ${BOO_TARGET_TYPE} ${OUT} ${SRC}'
  62. @conf
  63. def check_booc(self):
  64. self.find_program('booc', 'BOOC')
  65. self.env.BOO_FLAGS = ['-nologo']
  66. def configure(self):
  67. """Check that booc is available """
  68. self.check_booc()