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