wscript (1776B)
1 #! /usr/bin/env python 2 # encoding: utf-8 3 # Thomas Nagy, 2014-2015 (ita) 4 5 """ 6 Climb dependencies without using build groups and without annotating them. 7 8 In practice, one may want to avoid this: 9 * This adds some overhead as the task generators have to be searched and processed 10 * This is also unlikely to work in the real-world (complex targets, not all dependencies are file-based, etc) 11 * This also makes the dependencies more complicated to understand when reading a wscript file (what requires what?) 12 13 This example will create "d.txt" and all the required files but no "aa*.txt". 14 The target "john" is hard-coded below, just call "waf", or comment the line to call "waf --targets=john" 15 """ 16 17 VERSION='0.0.1' 18 APPNAME='file_climbing' 19 20 top = '.' 21 out = 'build' 22 23 def options(opt): 24 return 25 26 def configure(conf): 27 return 28 29 def build(bld): 30 for i in range(10): 31 bld(rule='cp ${SRC} ${TGT}', source='a.txt', target='aa%d.txt' % i) 32 bld(rule='cp ${SRC} ${TGT}', source='a.txt', target='b.txt') 33 bld(rule='cp ${SRC} ${TGT}', source='b.txt', target='c.txt') 34 bld(rule='cp ${SRC} ${TGT}', source='c.txt', target='d.txt', name='john') 35 36 # HERE 37 bld.targets = 'john' 38 39 import os 40 from waflib import Utils 41 from waflib.TaskGen import before_method, feature 42 43 @feature('*') 44 @before_method('process_source', 'process_rule') 45 def post_other_task_generators_if_necessary(self): 46 47 if not self.bld.targets: 48 return 49 50 if not getattr(self, 'source', None): 51 return 52 53 group = self.bld.get_group(self.bld.get_group_idx(self)) 54 for x in Utils.to_list(self.source): 55 y = os.path.split(x)[1] 56 57 for tg in group: 58 if id(tg) == id(self): 59 continue 60 61 if getattr(tg, 'target', None): 62 pass 63 64 for target in Utils.to_list(tg.target): 65 y2 = os.path.split(target)[1] 66 67 if y == y2: 68 tg.post() 69