mirror of
https://gitlab.com/ita1024/waf.git
synced 2025-01-24 17:31:23 +01:00
another example
This commit is contained in:
parent
3c49de07a7
commit
a122bc98c9
0
playground/file_climbing/a.txt
Normal file
0
playground/file_climbing/a.txt
Normal file
69
playground/file_climbing/wscript
Normal file
69
playground/file_climbing/wscript
Normal file
@ -0,0 +1,69 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Thomas Nagy, 2014 (ita)
|
||||
|
||||
"""
|
||||
Climb dependencies without using build groups and without annotating them.
|
||||
|
||||
In practice, one may want to avoid this:
|
||||
* This adds some overhead as the task generators have to be searched and processed
|
||||
* This is also unlikely to work in the real-world (complex targets, not all dependencies are file-based, etc)
|
||||
* This also makes the dependencies more complicated to understand when reading a wscript file (what requires what?)
|
||||
|
||||
This example will create "d.txt" and all the required files but no "aa*.txt".
|
||||
The target "john" is hard-coded below, just call "waf", or comment the line to call "waf --targets=john"
|
||||
"""
|
||||
|
||||
VERSION='0.0.1'
|
||||
APPNAME='file_climbing'
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
return
|
||||
|
||||
def configure(conf):
|
||||
return
|
||||
|
||||
def build(bld):
|
||||
for i in range(10):
|
||||
bld(rule='cp ${SRC} ${TGT}', source='a.txt', target='aa%d.txt' % i)
|
||||
bld(rule='cp ${SRC} ${TGT}', source='a.txt', target='b.txt')
|
||||
bld(rule='cp ${SRC} ${TGT}', source='b.txt', target='c.txt')
|
||||
bld(rule='cp ${SRC} ${TGT}', source='c.txt', target='d.txt', name='john')
|
||||
|
||||
# HERE
|
||||
bld.targets = 'john'
|
||||
|
||||
import os
|
||||
from waflib import Utils
|
||||
from waflib.TaskGen import before_method, feature
|
||||
|
||||
@feature('*')
|
||||
@before_method('process_source', 'process_rule')
|
||||
def post_other_task_generators_if_necessary(self):
|
||||
|
||||
if not self.bld.targets:
|
||||
return
|
||||
|
||||
if not getattr(self, 'source', None):
|
||||
return
|
||||
|
||||
group = self.bld.get_group(self.bld.get_group_idx(self))
|
||||
for x in Utils.to_list(self.source):
|
||||
y = os.path.split(x)[1]
|
||||
|
||||
for tg in group:
|
||||
if id(tg) == id(self):
|
||||
continue
|
||||
|
||||
if getattr(tg, 'target', None):
|
||||
pass
|
||||
|
||||
for target in Utils.to_list(tg.target):
|
||||
y2 = os.path.split(target)[1]
|
||||
|
||||
if y == y2:
|
||||
tg.post()
|
||||
|
Loading…
x
Reference in New Issue
Block a user