3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
6 from waflib import ConfigSet,Logs,Options,Scripting,Task,Build,Configure,Node,Runner,TaskGen,Utils,Errors,Context
7 sys.modules['Environment']=ConfigSet
8 ConfigSet.Environment=ConfigSet.ConfigSet
9 sys.modules['Logs']=Logs
10 sys.modules['Options']=Options
11 sys.modules['Scripting']=Scripting
12 sys.modules['Task']=Task
13 sys.modules['Build']=Build
14 sys.modules['Configure']=Configure
15 sys.modules['Node']=Node
16 sys.modules['Runner']=Runner
17 sys.modules['TaskGen']=TaskGen
18 sys.modules['Utils']=Utils
19 from waflib.Tools import c_preproc
20 sys.modules['preproc']=c_preproc
21 from waflib.Tools import c_config
22 sys.modules['config_c']=c_config
23 ConfigSet.ConfigSet.copy=ConfigSet.ConfigSet.derive
24 ConfigSet.ConfigSet.set_variant=Utils.nada
25 Build.BuildContext.add_subdirs=Build.BuildContext.recurse
26 Build.BuildContext.new_task_gen=Build.BuildContext.__call__
27 Build.BuildContext.is_install=0
28 Node.Node.relpath_gen=Node.Node.path_from
29 Utils.pproc=Utils.subprocess
30 Utils.get_term_cols=Logs.get_term_cols
31 def cmd_output(cmd,**kw):
40 kw['shell']=isinstance(cmd,str)
41 kw['stdout']=Utils.subprocess.PIPE
43 kw['stderr']=Utils.subprocess.PIPE
45 p=Utils.subprocess.Popen(cmd,**kw)
46 output=p.communicate()[0]
48 raise ValueError(str(e))
51 msg="command execution failed: %s -> %r"%(cmd,str(output))
55 Utils.cmd_output=cmd_output
56 def name_to_obj(self,s,env=None):
58 Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"')
59 return self.get_tgen_by_name(s)
60 Build.BuildContext.name_to_obj=name_to_obj
61 def env_of_name(self,name):
63 return self.all_envs[name]
65 Logs.error('no such environment: '+name)
67 Build.BuildContext.env_of_name=env_of_name
68 def set_env_name(self,name,env):
69 self.all_envs[name]=env
71 Configure.ConfigurationContext.set_env_name=set_env_name
72 def retrieve(self,name,fromenv=None):
74 env=self.all_envs[name]
76 env=ConfigSet.ConfigSet()
78 self.all_envs[name]=env
81 Logs.warn("The environment %s may have been configured already"%name)
83 Configure.ConfigurationContext.retrieve=retrieve
84 Configure.ConfigurationContext.sub_config=Configure.ConfigurationContext.recurse
85 Configure.ConfigurationContext.check_tool=Configure.ConfigurationContext.load
86 Configure.conftest=Configure.conf
87 Configure.ConfigurationError=Errors.ConfigurationError
88 Utils.WafError=Errors.WafError
89 Options.OptionsContext.sub_options=Options.OptionsContext.recurse
90 Options.OptionsContext.tool_options=Context.Context.load
91 Options.Handler=Options.OptionsContext
92 Task.simple_task_type=Task.task_type_from_func=Task.task_factory
93 Task.TaskBase.classes=Task.classes
94 def setitem(self,key,value):
95 if key.startswith('CCFLAGS'):
98 ConfigSet.ConfigSet.__setitem__=setitem
100 @TaskGen.before('apply_incpaths')
101 def old_importpaths(self):
102 if getattr(self,'importpaths',[]):
103 self.includes=self.importpaths
104 from waflib import Context
105 eld=Context.load_tool
106 def load_tool(*k,**kw):
108 if'set_options'in ret.__dict__:
110 Logs.warn('compat: rename "set_options" to options')
111 ret.options=ret.set_options
112 if'detect'in ret.__dict__:
114 Logs.warn('compat: rename "detect" to "configure"')
115 ret.configure=ret.detect
117 Context.load_tool=load_tool
118 def get_curdir(self):
119 return self.path.abspath()
120 Context.Context.curdir=property(get_curdir,Utils.nada)
121 rev=Context.load_module
122 def load_module(path,encoding=None):
123 ret=rev(path,encoding)
124 if'set_options'in ret.__dict__:
126 Logs.warn('compat: rename "set_options" to "options" (%r)'%path)
127 ret.options=ret.set_options
128 if'srcdir'in ret.__dict__:
130 Logs.warn('compat: rename "srcdir" to "top" (%r)'%path)
132 if'blddir'in ret.__dict__:
134 Logs.warn('compat: rename "blddir" to "out" (%r)'%path)
137 Context.load_module=load_module
138 old_post=TaskGen.task_gen.post
140 self.features=self.to_list(self.features)
141 if'cc'in self.features:
143 Logs.warn('compat: the feature cc does not exist anymore (use "c")')
144 self.features.remove('cc')
145 self.features.append('c')
146 if'cstaticlib'in self.features:
148 Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")')
149 self.features.remove('cstaticlib')
150 self.features.append(('cxx'in self.features)and'cxxstlib'or'cstlib')
151 if getattr(self,'ccflags',None):
153 Logs.warn('compat: "ccflags" was renamed to "cflags"')
154 self.cflags=self.ccflags
155 return old_post(self)
156 TaskGen.task_gen.post=post
157 def waf_version(*k,**kw):
158 Logs.warn('wrong version (waf_version was removed in waf 1.6)')
159 Utils.waf_version=waf_version
161 @TaskGen.feature('c','cxx','d')
162 @TaskGen.before('apply_incpaths','propagate_uselib_vars')
163 @TaskGen.after('apply_link','process_source')
164 def apply_uselib_local(self):
166 from waflib.Tools.ccroot import stlink_task
167 self.uselib=self.to_list(getattr(self,'uselib',[]))
168 self.includes=self.to_list(getattr(self,'includes',[]))
169 names=self.to_list(getattr(self,'uselib_local',[]))
170 get=self.bld.get_tgen_by_name
173 tmp=Utils.deque(names)
176 Logs.warn('compat: "uselib_local" is deprecated, replace by "use"')
178 lib_name=tmp.popleft()
184 if getattr(y,'uselib_local',None):
185 for x in self.to_list(getattr(y,'uselib_local',[])):
188 if getattr(obj,'link_task',None):
189 if not isinstance(obj.link_task,stlink_task):
191 if getattr(y,'link_task',None):
192 link_name=y.target[y.target.rfind(os.sep)+1:]
193 if isinstance(y.link_task,stlink_task):
194 env.append_value('STLIB',[link_name])
196 env.append_value('LIB',[link_name])
197 self.link_task.set_run_after(y.link_task)
198 self.link_task.dep_nodes+=y.link_task.outputs
199 tmp_path=y.link_task.outputs[0].parent.bldpath()
200 if not tmp_path in env['LIBPATH']:
201 env.prepend_value('LIBPATH',[tmp_path])
202 for v in self.to_list(getattr(y,'uselib',[])):
203 if v not in seen_uselib:
205 if not env['STLIB_'+v]:
206 if not v in self.uselib:
207 self.uselib.insert(0,v)
208 if getattr(y,'export_includes',None):
209 self.includes.extend(y.to_incnodes(y.export_includes))
210 @TaskGen.feature('cprogram','cxxprogram','cstlib','cxxstlib','cshlib','cxxshlib','dprogram','dstlib','dshlib')
211 @TaskGen.after('apply_link')
212 def apply_objdeps(self):
213 names=getattr(self,'add_objects',[])
216 names=self.to_list(names)
217 get=self.bld.get_tgen_by_name
225 if getattr(y,'add_objects',None):
227 lst=y.to_list(y.add_objects)
230 if u in seen:continue
236 for t in getattr(y,'compiled_tasks',[]):
237 self.link_task.inputs.extend(t.outputs)
238 @TaskGen.after('apply_link')
239 def process_obj_files(self):
240 if not hasattr(self,'obj_files'):
242 for x in self.obj_files:
243 node=self.path.find_resource(x)
244 self.link_task.inputs.append(node)
245 @TaskGen.taskgen_method
246 def add_obj_file(self,file):
247 if not hasattr(self,'obj_files'):self.obj_files=[]
248 if not'process_obj_files'in self.meths:self.meths.append('process_obj_files')
249 self.obj_files.append(file)
250 old_define=Configure.ConfigurationContext.__dict__['define']
252 def define(self,key,val,quote=True):
253 old_define(self,key,val,quote)
254 if key.startswith('HAVE_'):
256 old_undefine=Configure.ConfigurationContext.__dict__['undefine']
258 def undefine(self,key):
259 old_undefine(self,key)
260 if key.startswith('HAVE_'):
262 def set_incdirs(self,val):
263 Logs.warn('compat: change "export_incdirs" by "export_includes"')
264 self.export_includes=val
265 TaskGen.task_gen.export_incdirs=property(None,set_incdirs)
266 def install_dir(self,path):
269 destpath=Utils.subst_vars(path,self.env)
270 if self.is_install>0:
271 Logs.info('* creating %s'%destpath)
272 Utils.check_dir(destpath)
273 elif self.is_install<0:
274 Logs.info('* removing %s'%destpath)
279 Build.BuildContext.install_dir=install_dir