[0fa325b] | 1 | #! /usr/bin/env python |
---|
| 2 | # encoding: utf-8 |
---|
| 3 | # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file |
---|
| 4 | |
---|
| 5 | typos={'feature':'features','sources':'source','targets':'target','include':'includes','export_include':'export_includes','define':'defines','importpath':'includes','installpath':'install_path','iscopy':'is_copy',} |
---|
| 6 | meths_typos=['__call__','program','shlib','stlib','objects'] |
---|
| 7 | from waflib import Logs,Build,Node,Task,TaskGen,ConfigSet,Errors,Utils |
---|
| 8 | import waflib.Tools.ccroot |
---|
| 9 | def check_same_targets(self): |
---|
| 10 | mp=Utils.defaultdict(list) |
---|
| 11 | uids={} |
---|
| 12 | def check_task(tsk): |
---|
| 13 | if not isinstance(tsk,Task.Task): |
---|
| 14 | return |
---|
| 15 | for node in tsk.outputs: |
---|
| 16 | mp[node].append(tsk) |
---|
| 17 | try: |
---|
| 18 | uids[tsk.uid()].append(tsk) |
---|
| 19 | except KeyError: |
---|
| 20 | uids[tsk.uid()]=[tsk] |
---|
| 21 | for g in self.groups: |
---|
| 22 | for tg in g: |
---|
| 23 | try: |
---|
| 24 | for tsk in tg.tasks: |
---|
| 25 | check_task(tsk) |
---|
| 26 | except AttributeError: |
---|
| 27 | check_task(tg) |
---|
| 28 | dupe=False |
---|
| 29 | for(k,v)in mp.items(): |
---|
| 30 | if len(v)>1: |
---|
| 31 | dupe=True |
---|
| 32 | msg='* Node %r is created more than once%s. The task generators are:'%(k,Logs.verbose==1 and" (full message on 'waf -v -v')"or"") |
---|
| 33 | Logs.error(msg) |
---|
| 34 | for x in v: |
---|
| 35 | if Logs.verbose>1: |
---|
| 36 | Logs.error(' %d. %r'%(1+v.index(x),x.generator)) |
---|
| 37 | else: |
---|
| 38 | Logs.error(' %d. %r in %r'%(1+v.index(x),x.generator.name,getattr(x.generator,'path',None))) |
---|
| 39 | if not dupe: |
---|
| 40 | for(k,v)in uids.items(): |
---|
| 41 | if len(v)>1: |
---|
| 42 | Logs.error('* Several tasks use the same identifier. Please check the information on\n http://docs.waf.googlecode.com/git/apidocs_16/Task.html#waflib.Task.Task.uid') |
---|
| 43 | for tsk in v: |
---|
| 44 | Logs.error(' - object %r (%r) defined in %r'%(tsk.__class__.__name__,tsk,tsk.generator)) |
---|
| 45 | def check_invalid_constraints(self): |
---|
| 46 | feat=set([]) |
---|
| 47 | for x in list(TaskGen.feats.values()): |
---|
| 48 | feat.union(set(x)) |
---|
| 49 | for(x,y)in TaskGen.task_gen.prec.items(): |
---|
| 50 | feat.add(x) |
---|
| 51 | feat.union(set(y)) |
---|
| 52 | ext=set([]) |
---|
| 53 | for x in TaskGen.task_gen.mappings.values(): |
---|
| 54 | ext.add(x.__name__) |
---|
| 55 | invalid=ext&feat |
---|
| 56 | if invalid: |
---|
| 57 | Logs.error('The methods %r have invalid annotations: @extension <-> @feature/@before_method/@after_method'%list(invalid)) |
---|
| 58 | for cls in list(Task.classes.values()): |
---|
| 59 | for x in('before','after'): |
---|
| 60 | for y in Utils.to_list(getattr(cls,x,[])): |
---|
| 61 | if not Task.classes.get(y,None): |
---|
| 62 | Logs.error('Erroneous order constraint %r=%r on task class %r'%(x,y,cls.__name__)) |
---|
| 63 | if getattr(cls,'rule',None): |
---|
| 64 | Logs.error('Erroneous attribute "rule" on task class %r (rename to "run_str")'%cls.__name__) |
---|
| 65 | def replace(m): |
---|
| 66 | oldcall=getattr(Build.BuildContext,m) |
---|
| 67 | def call(self,*k,**kw): |
---|
| 68 | ret=oldcall(self,*k,**kw) |
---|
| 69 | for x in typos: |
---|
| 70 | if x in kw: |
---|
| 71 | if x=='iscopy'and'subst'in getattr(self,'features',''): |
---|
| 72 | continue |
---|
| 73 | err=True |
---|
| 74 | Logs.error('Fix the typo %r -> %r on %r'%(x,typos[x],ret)) |
---|
| 75 | return ret |
---|
| 76 | setattr(Build.BuildContext,m,call) |
---|
| 77 | def enhance_lib(): |
---|
| 78 | for m in meths_typos: |
---|
| 79 | replace(m) |
---|
| 80 | def ant_glob(self,*k,**kw): |
---|
| 81 | if k: |
---|
| 82 | lst=Utils.to_list(k[0]) |
---|
| 83 | for pat in lst: |
---|
| 84 | if'..'in pat.split('/'): |
---|
| 85 | Logs.error("In ant_glob pattern %r: '..' means 'two dots', not 'parent directory'"%k[0]) |
---|
| 86 | if kw.get('remove',True): |
---|
| 87 | try: |
---|
| 88 | if self.is_child_of(self.ctx.bldnode)and not kw.get('quiet',False): |
---|
| 89 | Logs.error('Using ant_glob on the build folder (%r) is dangerous (quiet=True to disable this warning)'%self) |
---|
| 90 | except AttributeError: |
---|
| 91 | pass |
---|
| 92 | return self.old_ant_glob(*k,**kw) |
---|
| 93 | Node.Node.old_ant_glob=Node.Node.ant_glob |
---|
| 94 | Node.Node.ant_glob=ant_glob |
---|
| 95 | old=Task.is_before |
---|
| 96 | def is_before(t1,t2): |
---|
| 97 | ret=old(t1,t2) |
---|
| 98 | if ret and old(t2,t1): |
---|
| 99 | Logs.error('Contradictory order constraints in classes %r %r'%(t1,t2)) |
---|
| 100 | return ret |
---|
| 101 | Task.is_before=is_before |
---|
| 102 | def check_err_features(self): |
---|
| 103 | lst=self.to_list(self.features) |
---|
| 104 | if'shlib'in lst: |
---|
| 105 | Logs.error('feature shlib -> cshlib, dshlib or cxxshlib') |
---|
| 106 | for x in('c','cxx','d','fc'): |
---|
| 107 | if not x in lst and lst and lst[0]in[x+y for y in('program','shlib','stlib')]: |
---|
| 108 | Logs.error('%r features is probably missing %r'%(self,x)) |
---|
| 109 | TaskGen.feature('*')(check_err_features) |
---|
| 110 | def check_err_order(self): |
---|
| 111 | if not hasattr(self,'rule')and not'subst'in Utils.to_list(self.features): |
---|
| 112 | for x in('before','after','ext_in','ext_out'): |
---|
| 113 | if hasattr(self,x): |
---|
| 114 | Logs.warn('Erroneous order constraint %r on non-rule based task generator %r'%(x,self)) |
---|
| 115 | else: |
---|
| 116 | for x in('before','after'): |
---|
| 117 | for y in self.to_list(getattr(self,x,[])): |
---|
| 118 | if not Task.classes.get(y,None): |
---|
| 119 | Logs.error('Erroneous order constraint %s=%r on %r (no such class)'%(x,y,self)) |
---|
| 120 | TaskGen.feature('*')(check_err_order) |
---|
| 121 | def check_compile(self): |
---|
| 122 | check_invalid_constraints(self) |
---|
| 123 | try: |
---|
| 124 | ret=self.orig_compile() |
---|
| 125 | finally: |
---|
| 126 | check_same_targets(self) |
---|
| 127 | return ret |
---|
| 128 | Build.BuildContext.orig_compile=Build.BuildContext.compile |
---|
| 129 | Build.BuildContext.compile=check_compile |
---|
| 130 | def use_rec(self,name,**kw): |
---|
| 131 | try: |
---|
| 132 | y=self.bld.get_tgen_by_name(name) |
---|
| 133 | except Errors.WafError: |
---|
| 134 | pass |
---|
| 135 | else: |
---|
| 136 | idx=self.bld.get_group_idx(self) |
---|
| 137 | odx=self.bld.get_group_idx(y) |
---|
| 138 | if odx>idx: |
---|
| 139 | msg="Invalid 'use' across build groups:" |
---|
| 140 | if Logs.verbose>1: |
---|
| 141 | msg+='\n target %r\n uses:\n %r'%(self,y) |
---|
| 142 | else: |
---|
| 143 | msg+=" %r uses %r (try 'waf -v -v' for the full error)"%(self.name,name) |
---|
| 144 | raise Errors.WafError(msg) |
---|
| 145 | self.orig_use_rec(name,**kw) |
---|
| 146 | TaskGen.task_gen.orig_use_rec=TaskGen.task_gen.use_rec |
---|
| 147 | TaskGen.task_gen.use_rec=use_rec |
---|
| 148 | def getattri(self,name,default=None): |
---|
| 149 | if name=='append'or name=='add': |
---|
| 150 | raise Errors.WafError('env.append and env.add do not exist: use env.append_value/env.append_unique') |
---|
| 151 | elif name=='prepend': |
---|
| 152 | raise Errors.WafError('env.prepend does not exist: use env.prepend_value') |
---|
| 153 | if name in self.__slots__: |
---|
| 154 | return object.__getattr__(self,name,default) |
---|
| 155 | else: |
---|
| 156 | return self[name] |
---|
| 157 | ConfigSet.ConfigSet.__getattr__=getattri |
---|
| 158 | def options(opt): |
---|
| 159 | enhance_lib() |
---|
| 160 | def configure(conf): |
---|
| 161 | pass |
---|