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