3
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
6
if sys.hexversion < 0x020400f0: from sets import Set as set
8
from waflib import Task,Utils,Logs,Errors,ConfigSet
9
feats=Utils.defaultdict(set)
10
class task_gen(object):
12
prec=Utils.defaultdict(list)
13
def __init__(self,*k,**kw):
17
self.prec=Utils.defaultdict(list)
22
self.env=ConfigSet.ConfigSet()
27
self.env=self.bld.env.derive()
28
self.path=self.bld.path
30
self.idx=self.bld.idx[id(self.path)]=self.bld.idx.get(id(self.path),0)+1
31
except AttributeError:
33
self.idx=self.bld.idx[id(self.path)]=1
34
for key,val in kw.items():
37
return"<task_gen %r declared in %s>"%(self.name,self.path.abspath())
40
for x in self.__dict__.keys():
41
if x not in['env','bld','compiled_tasks','tasks']:
42
lst.append("%s=%s"%(x,repr(getattr(self,x))))
43
return"bld(%s) in %s"%(", ".join(lst),self.path.abspath())
47
except AttributeError:
48
if isinstance(self.target,list):
49
lst=[str(x)for x in self.target]
50
name=self._name=','.join(lst)
52
name=self._name=str(self.target)
54
def set_name(self,name):
56
name=property(get_name,set_name)
57
def to_list(self,val):
58
if isinstance(val,str):return val.split()
61
if getattr(self,'posted',None):
65
self.features=Utils.to_list(self.features)
66
for x in self.features+['*']:
69
if not x in Task.classes:
70
Logs.warn('feature %r does not exist - bind at least one method to it'%x)
73
prec_tbl=self.prec or task_gen.prec
79
for x in prec.values():
86
if e in keys:out.append(e)
100
raise Errors.WafError('Cycle detected in the method execution %r'%prec)
103
Logs.debug('task_gen: posting %s %d'%(self,id(self)))
107
except AttributeError:
108
raise Errors.WafError('%r is not a valid task generator method'%x)
109
Logs.debug('task_gen: -> %s (%d)'%(x,id(self)))
111
Logs.debug('task_gen: posted %s'%self.name)
113
def get_hook(self,node):
115
for k in self.mappings:
117
return self.mappings[k]
118
for k in task_gen.mappings:
120
return task_gen.mappings[k]
121
raise Errors.WafError("File %r has no mapping in %r (did you forget to load a waf tool?)"%(node,task_gen.mappings.keys()))
122
def create_task(self,name,src=None,tgt=None):
123
task=Task.classes[name](env=self.env.derive(),generator=self)
127
task.set_outputs(tgt)
128
self.tasks.append(task)
132
for x in self.__dict__:
133
if x in['env','bld']:
135
elif x in['path','features']:
136
setattr(newobj,x,getattr(self,x))
138
setattr(newobj,x,copy.copy(getattr(self,x)))
140
if isinstance(env,str):
141
newobj.env=self.bld.all_envs[env].derive()
143
newobj.env=env.derive()
145
def declare_chain(name='',rule=None,reentrant=None,color='BLUE',ext_in=[],ext_out=[],before=[],after=[],decider=None,scan=None,install_path=None,shell=False):
146
ext_in=Utils.to_list(ext_in)
147
ext_out=Utils.to_list(ext_out)
150
cls=Task.task_factory(name,rule,color=color,ext_in=ext_in,ext_out=ext_out,before=before,after=after,scan=scan,shell=shell)
151
def x_file(self,node):
152
ext=decider and decider(self,node)or cls.ext_out
155
tsk=self.create_task(name,node)
157
keys=self.mappings.keys()+self.__class__.mappings.keys()
159
k=node.change_ext(x,ext_in=_ext_in)
160
tsk.outputs.append(k)
162
if cnt<int(reentrant):
163
self.source.append(k)
166
if k.name.endswith(y):
167
self.source.append(k)
171
self.bld.install_files(install_path,tsk.outputs)
174
task_gen.mappings[x]=x_file
176
def taskgen_method(func):
177
setattr(task_gen,func.__name__,func)
181
setattr(task_gen,func.__name__,func)
183
feats[name].update([func.__name__])
186
def before_method(*k):
188
setattr(task_gen,func.__name__,func)
190
if not func.__name__ in task_gen.prec[fun_name]:
191
task_gen.prec[fun_name].append(func.__name__)
195
def after_method(*k):
197
setattr(task_gen,func.__name__,func)
199
if not fun_name in task_gen.prec[func.__name__]:
200
task_gen.prec[func.__name__].append(fun_name)
206
setattr(task_gen,func.__name__,func)
208
task_gen.mappings[x]=func
211
def to_nodes(self,lst,path=None):
213
path=path or self.path
214
find=path.find_resource
215
if isinstance(lst,self.path.__class__):
217
for x in Utils.to_list(lst):
218
if isinstance(x,str):
223
raise Errors.WafError("source not found: %r in %r"%(x,self))
226
def process_source(self):
227
self.source=self.to_nodes(getattr(self,'source',[]))
228
for node in self.source:
229
self.get_hook(node)(self,node)
230
def process_rule(self):
231
if not getattr(self,'rule',None):
233
name=str(getattr(self,'name',None)or self.target or self.rule)
234
cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'))
235
tsk=self.create_task(name)
236
if getattr(self,'target',None):
237
if isinstance(self.target,str):
238
self.target=self.target.split()
239
if not isinstance(self.target,list):
240
self.target=[self.target]
241
for x in self.target:
242
if isinstance(x,str):
243
tsk.outputs.append(self.path.find_or_declare(x))
246
tsk.outputs.append(x)
247
if getattr(self,'install_path',None):
248
self.bld.install_files(self.install_path,tsk.outputs)
249
if getattr(self,'source',None):
250
tsk.inputs=self.to_nodes(self.source)
252
if getattr(self,'scan',None):
254
elif getattr(self,'deps',None):
257
for x in self.generator.to_list(self.generator.deps):
258
node=self.generator.path.find_resource(x)
260
self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
264
if getattr(self,'cwd',None):
266
if getattr(self,'update_outputs',None)or getattr(self,'on_results',None):
267
Task.update_outputs(cls)
268
if getattr(self,'always',None):
270
for x in['after','before','ext_in','ext_out']:
271
setattr(cls,x,getattr(self,x,[]))
272
def sequence_order(self):
273
if self.meths and self.meths[-1]!='sequence_order':
274
self.meths.append('sequence_order')
276
if getattr(self,'seq_start',None):
278
if getattr(self.bld,'prev',None):
280
for x in self.bld.prev.tasks:
284
re_m4=re.compile('@(\w+)@',re.M)
285
class subst_pc(Task.Task):
287
code=self.inputs[0].read()
288
code=code.replace('%','%%')
296
code=re_m4.sub(repl,code)
299
except AttributeError:
302
tmp=getattr(self.generator,x,'')or self.env.get_flat(x)or self.env.get_flat(x.upper())
304
self.outputs[0].write(code%d)
305
self.generator.bld.raw_deps[self.uid()]=self.dep_vars=lst
306
try:delattr(self,'cache_sig')
307
except AttributeError:pass
308
if getattr(self.generator,'chmod',None):
309
os.chmod(self.outputs[0].abspath(),self.generator.chmod)
311
bld=self.generator.bld
314
vars=self.generator.bld.raw_deps.get(self.uid(),[])
315
act_sig=bld.hash_env_vars(env,vars)
317
lst=[getattr(self.generator,x,'')for x in vars]
318
upd(Utils.h_list(lst))
319
return self.m.digest()
320
def add_pcfile(self,node):
321
tsk=self.create_task('subst_pc',node,node.change_ext('.pc','.pc.in'))
322
self.bld.install_files(getattr(self,'install_path','${LIBDIR}/pkgconfig/'),tsk.outputs)
323
class subst(subst_pc):
325
def process_subst(self):
326
src=self.to_nodes(getattr(self,'source',[]))
327
tgt=getattr(self,'target',[])
328
if isinstance(tgt,self.path.__class__):
330
tgt=[isinstance(x,self.path.__class__)and x or self.path.find_or_declare(x)for x in Utils.to_list(tgt)]
331
if len(src)!=len(tgt):
332
raise Errors.WafError('invalid source or target for %r'%self)
333
for x,y in zip(src,tgt):
335
raise Errors.WafError('invalid source or target for %r'%self)
336
tsk=self.create_task('subst',x,y)
337
for a in('after','before','ext_in','ext_out'):
338
val=getattr(self,a,None)
341
inst_to=getattr(self,'install_path',None)
343
self.bld.install_files(inst_to,tgt,chmod=getattr(self,'chmod',Utils.O644))
346
taskgen_method(to_nodes)
347
feature('*')(process_source)
348
feature('*')(process_rule)
349
before_method('process_source')(process_rule)
350
feature('seq')(sequence_order)
351
extension('.pc.in')(add_pcfile)
352
feature('subst')(process_subst)
353
before_method('process_source','process_rule')(process_subst)
b'\\ No newline at end of file'