waf, waflib: import unpacked waf 1.7.13
authorPaul Brossier <piem@piem.org>
Sat, 7 Dec 2013 19:04:04 +0000 (14:04 -0500)
committerPaul Brossier <piem@piem.org>
Sat, 7 Dec 2013 19:04:04 +0000 (14:04 -0500)
107 files changed:
waf [new file with mode: 0755]
waflib/Build.py [new file with mode: 0644]
waflib/Build.pyc [new file with mode: 0644]
waflib/ConfigSet.py [new file with mode: 0644]
waflib/ConfigSet.pyc [new file with mode: 0644]
waflib/Configure.py [new file with mode: 0644]
waflib/Configure.pyc [new file with mode: 0644]
waflib/Context.py [new file with mode: 0644]
waflib/Context.pyc [new file with mode: 0644]
waflib/Errors.py [new file with mode: 0644]
waflib/Errors.pyc [new file with mode: 0644]
waflib/Logs.py [new file with mode: 0644]
waflib/Logs.pyc [new file with mode: 0644]
waflib/Node.py [new file with mode: 0644]
waflib/Node.pyc [new file with mode: 0644]
waflib/Options.py [new file with mode: 0644]
waflib/Options.pyc [new file with mode: 0644]
waflib/Runner.py [new file with mode: 0644]
waflib/Runner.pyc [new file with mode: 0644]
waflib/Scripting.py [new file with mode: 0644]
waflib/Scripting.pyc [new file with mode: 0644]
waflib/Task.py [new file with mode: 0644]
waflib/Task.pyc [new file with mode: 0644]
waflib/TaskGen.py [new file with mode: 0644]
waflib/TaskGen.pyc [new file with mode: 0644]
waflib/Tools/__init__.py [new file with mode: 0644]
waflib/Tools/__init__.pyc [new file with mode: 0644]
waflib/Tools/ar.py [new file with mode: 0644]
waflib/Tools/ar.pyc [new file with mode: 0644]
waflib/Tools/asm.py [new file with mode: 0644]
waflib/Tools/bison.py [new file with mode: 0644]
waflib/Tools/c.py [new file with mode: 0644]
waflib/Tools/c.pyc [new file with mode: 0644]
waflib/Tools/c_aliases.py [new file with mode: 0644]
waflib/Tools/c_aliases.pyc [new file with mode: 0644]
waflib/Tools/c_config.py [new file with mode: 0755]
waflib/Tools/c_config.pyc [new file with mode: 0644]
waflib/Tools/c_osx.py [new file with mode: 0644]
waflib/Tools/c_osx.pyc [new file with mode: 0644]
waflib/Tools/c_preproc.py [new file with mode: 0644]
waflib/Tools/c_preproc.pyc [new file with mode: 0644]
waflib/Tools/c_tests.py [new file with mode: 0644]
waflib/Tools/c_tests.pyc [new file with mode: 0644]
waflib/Tools/ccroot.py [new file with mode: 0644]
waflib/Tools/ccroot.pyc [new file with mode: 0644]
waflib/Tools/compiler_c.py [new file with mode: 0644]
waflib/Tools/compiler_c.pyc [new file with mode: 0644]
waflib/Tools/compiler_cxx.py [new file with mode: 0644]
waflib/Tools/compiler_d.py [new file with mode: 0644]
waflib/Tools/compiler_fc.py [new file with mode: 0644]
waflib/Tools/cs.py [new file with mode: 0644]
waflib/Tools/cxx.py [new file with mode: 0644]
waflib/Tools/d.py [new file with mode: 0644]
waflib/Tools/d_config.py [new file with mode: 0644]
waflib/Tools/d_scan.py [new file with mode: 0644]
waflib/Tools/dbus.py [new file with mode: 0644]
waflib/Tools/dmd.py [new file with mode: 0644]
waflib/Tools/errcheck.py [new file with mode: 0644]
waflib/Tools/errcheck.pyc [new file with mode: 0644]
waflib/Tools/fc.py [new file with mode: 0644]
waflib/Tools/fc_config.py [new file with mode: 0644]
waflib/Tools/fc_scan.py [new file with mode: 0644]
waflib/Tools/flex.py [new file with mode: 0644]
waflib/Tools/g95.py [new file with mode: 0644]
waflib/Tools/gas.py [new file with mode: 0644]
waflib/Tools/gcc.py [new file with mode: 0644]
waflib/Tools/gcc.pyc [new file with mode: 0644]
waflib/Tools/gdc.py [new file with mode: 0644]
waflib/Tools/gfortran.py [new file with mode: 0644]
waflib/Tools/glib2.py [new file with mode: 0644]
waflib/Tools/gnu_dirs.py [new file with mode: 0644]
waflib/Tools/gnu_dirs.pyc [new file with mode: 0644]
waflib/Tools/gxx.py [new file with mode: 0644]
waflib/Tools/icc.py [new file with mode: 0644]
waflib/Tools/icpc.py [new file with mode: 0644]
waflib/Tools/ifort.py [new file with mode: 0644]
waflib/Tools/intltool.py [new file with mode: 0644]
waflib/Tools/irixcc.py [new file with mode: 0644]
waflib/Tools/javaw.py [new file with mode: 0644]
waflib/Tools/kde4.py [new file with mode: 0644]
waflib/Tools/ldc2.py [new file with mode: 0644]
waflib/Tools/lua.py [new file with mode: 0644]
waflib/Tools/msvc.py [new file with mode: 0644]
waflib/Tools/nasm.py [new file with mode: 0644]
waflib/Tools/perl.py [new file with mode: 0644]
waflib/Tools/python.py [new file with mode: 0644]
waflib/Tools/qt4.py [new file with mode: 0644]
waflib/Tools/ruby.py [new file with mode: 0644]
waflib/Tools/suncc.py [new file with mode: 0644]
waflib/Tools/suncxx.py [new file with mode: 0644]
waflib/Tools/tex.py [new file with mode: 0644]
waflib/Tools/vala.py [new file with mode: 0644]
waflib/Tools/waf_unit_test.py [new file with mode: 0644]
waflib/Tools/waf_unit_test.pyc [new file with mode: 0644]
waflib/Tools/winres.py [new file with mode: 0644]
waflib/Tools/xlc.py [new file with mode: 0644]
waflib/Tools/xlcxx.py [new file with mode: 0644]
waflib/Utils.py [new file with mode: 0644]
waflib/Utils.pyc [new file with mode: 0644]
waflib/__init__.py [new file with mode: 0644]
waflib/__init__.pyc [new file with mode: 0644]
waflib/ansiterm.py [new file with mode: 0644]
waflib/ansiterm.pyc [new file with mode: 0644]
waflib/extras/__init__.py [new file with mode: 0644]
waflib/extras/compat15.py [new file with mode: 0644]
waflib/fixpy2.py [new file with mode: 0644]
waflib/fixpy2.pyc [new file with mode: 0644]

diff --git a/waf b/waf
new file mode 100755 (executable)
index 0000000..4ba08d8
--- /dev/null
+++ b/waf
@@ -0,0 +1,164 @@
+#!/usr/bin/env python
+# encoding: ISO8859-1
+# Thomas Nagy, 2005-2012
+
+"""
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+"""
+
+import os, sys
+
+VERSION="1.7.13"
+REVISION="5a064c2686fe54de4e11018d22148cfc"
+INSTALL=''
+C1='#('
+C2='#$'
+cwd = os.getcwd()
+join = os.path.join
+
+
+WAF='waf'
+def b(x):
+       return x
+if sys.hexversion>0x300000f:
+       WAF='waf3'
+       def b(x):
+               return x.encode()
+
+def err(m):
+       print(('\033[91mError: %s\033[0m' % m))
+       sys.exit(1)
+
+def unpack_wafdir(dir):
+       f = open(sys.argv[0],'rb')
+       c = 'corrupt archive (%d)'
+       while 1:
+               line = f.readline()
+               if not line: err('run waf-light from a folder containing waflib')
+               if line == b('#==>\n'):
+                       txt = f.readline()
+                       if not txt: err(c % 1)
+                       if f.readline() != b('#<==\n'): err(c % 2)
+                       break
+       if not txt: err(c % 3)
+       txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r'))
+
+       import shutil, tarfile
+       try: shutil.rmtree(dir)
+       except OSError: pass
+       try:
+               for x in ['Tools', 'extras']:
+                       os.makedirs(join(dir, 'waflib', x))
+       except OSError:
+               err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
+
+       os.chdir(dir)
+       tmp = 't.bz2'
+       t = open(tmp,'wb')
+       try: t.write(txt)
+       finally: t.close()
+
+       try:
+               t = tarfile.open(tmp)
+       except:
+               try:
+                       os.system('bunzip2 t.bz2')
+                       t = tarfile.open('t')
+                       tmp = 't'
+               except:
+                       os.chdir(cwd)
+                       try: shutil.rmtree(dir)
+                       except OSError: pass
+                       err("Waf cannot be unpacked, check that bzip2 support is present")
+
+       try:
+               for x in t: t.extract(x)
+       finally:
+               t.close()
+
+       for x in ['Tools', 'extras']:
+               os.chmod(join('waflib',x), 493)
+
+       if sys.hexversion<0x300000f:
+               sys.path = [join(dir, 'waflib')] + sys.path
+               import fixpy2
+               fixpy2.fixdir(dir)
+
+       os.remove(tmp)
+       os.chdir(cwd)
+
+       try: dir = unicode(dir, 'mbcs')
+       except: pass
+       try:
+               from ctypes import windll
+               windll.kernel32.SetFileAttributesW(dir, 2)
+       except:
+               pass
+
+def test(dir):
+       try:
+               os.stat(join(dir, 'waflib'))
+               return os.path.abspath(dir)
+       except OSError:
+               pass
+
+def find_lib():
+       name = sys.argv[0]
+       base = os.path.dirname(os.path.abspath(name))
+
+       #devs use $WAFDIR
+       w=test(os.environ.get('WAFDIR', ''))
+       if w: return w
+
+       #waf-light
+       if name.endswith('waf-light'):
+               w = test(base)
+               if w: return w
+               err('waf-light requires waflib -> export WAFDIR=/folder')
+
+       dirname = '%s-%s-%s' % (WAF, VERSION, REVISION)
+       for i in [INSTALL,'/usr','/usr/local','/opt']:
+               w = test(i + '/lib/' + dirname)
+               if w: return w
+
+       #waf-local
+       dir = join(base, (sys.platform != 'win32' and '.' or '') + dirname)
+       w = test(dir)
+       if w: return w
+
+       #unpack
+       unpack_wafdir(dir)
+       return dir
+
+wafdir = find_lib()
+sys.path.insert(0, wafdir)
+
+if __name__ == '__main__':
+
+       from waflib import Scripting
+       Scripting.waf_entry_point(cwd, VERSION, wafdir)
+
diff --git a/waflib/Build.py b/waflib/Build.py
new file mode 100644 (file)
index 0000000..f76933a
--- /dev/null
@@ -0,0 +1,758 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,sys,errno,re,shutil
+try:
+       import cPickle
+except ImportError:
+       import pickle as cPickle
+from waflib import Runner,TaskGen,Utils,ConfigSet,Task,Logs,Options,Context,Errors
+import waflib.Node
+CACHE_DIR='c4che'
+CACHE_SUFFIX='_cache.py'
+INSTALL=1337
+UNINSTALL=-1337
+SAVED_ATTRS='root node_deps raw_deps task_sigs'.split()
+CFG_FILES='cfg_files'
+POST_AT_ONCE=0
+POST_LAZY=1
+POST_BOTH=2
+class BuildContext(Context.Context):
+       '''executes the build'''
+       cmd='build'
+       variant=''
+       def __init__(self,**kw):
+               super(BuildContext,self).__init__(**kw)
+               self.is_install=0
+               self.top_dir=kw.get('top_dir',Context.top_dir)
+               self.run_dir=kw.get('run_dir',Context.run_dir)
+               self.post_mode=POST_AT_ONCE
+               self.out_dir=kw.get('out_dir',Context.out_dir)
+               self.cache_dir=kw.get('cache_dir',None)
+               if not self.cache_dir:
+                       self.cache_dir=self.out_dir+os.sep+CACHE_DIR
+               self.all_envs={}
+               self.task_sigs={}
+               self.node_deps={}
+               self.raw_deps={}
+               self.cache_dir_contents={}
+               self.task_gen_cache_names={}
+               self.launch_dir=Context.launch_dir
+               self.jobs=Options.options.jobs
+               self.targets=Options.options.targets
+               self.keep=Options.options.keep
+               self.cache_global=Options.cache_global
+               self.nocache=Options.options.nocache
+               self.progress_bar=Options.options.progress_bar
+               self.deps_man=Utils.defaultdict(list)
+               self.current_group=0
+               self.groups=[]
+               self.group_names={}
+       def get_variant_dir(self):
+               if not self.variant:
+                       return self.out_dir
+               return os.path.join(self.out_dir,self.variant)
+       variant_dir=property(get_variant_dir,None)
+       def __call__(self,*k,**kw):
+               kw['bld']=self
+               ret=TaskGen.task_gen(*k,**kw)
+               self.task_gen_cache_names={}
+               self.add_to_group(ret,group=kw.get('group',None))
+               return ret
+       def rule(self,*k,**kw):
+               def f(rule):
+                       ret=self(*k,**kw)
+                       ret.rule=rule
+                       return ret
+               return f
+       def __copy__(self):
+               raise Errors.WafError('build contexts are not supposed to be copied')
+       def install_files(self,*k,**kw):
+               pass
+       def install_as(self,*k,**kw):
+               pass
+       def symlink_as(self,*k,**kw):
+               pass
+       def load_envs(self):
+               node=self.root.find_node(self.cache_dir)
+               if not node:
+                       raise Errors.WafError('The project was not configured: run "waf configure" first!')
+               lst=node.ant_glob('**/*%s'%CACHE_SUFFIX,quiet=True)
+               if not lst:
+                       raise Errors.WafError('The cache directory is empty: reconfigure the project')
+               for x in lst:
+                       name=x.path_from(node).replace(CACHE_SUFFIX,'').replace('\\','/')
+                       env=ConfigSet.ConfigSet(x.abspath())
+                       self.all_envs[name]=env
+                       for f in env[CFG_FILES]:
+                               newnode=self.root.find_resource(f)
+                               try:
+                                       h=Utils.h_file(newnode.abspath())
+                               except(IOError,AttributeError):
+                                       Logs.error('cannot find %r'%f)
+                                       h=Utils.SIG_NIL
+                               newnode.sig=h
+       def init_dirs(self):
+               if not(os.path.isabs(self.top_dir)and os.path.isabs(self.out_dir)):
+                       raise Errors.WafError('The project was not configured: run "waf configure" first!')
+               self.path=self.srcnode=self.root.find_dir(self.top_dir)
+               self.bldnode=self.root.make_node(self.variant_dir)
+               self.bldnode.mkdir()
+       def execute(self):
+               self.restore()
+               if not self.all_envs:
+                       self.load_envs()
+               self.execute_build()
+       def execute_build(self):
+               Logs.info("Waf: Entering directory `%s'"%self.variant_dir)
+               self.recurse([self.run_dir])
+               self.pre_build()
+               self.timer=Utils.Timer()
+               if self.progress_bar:
+                       sys.stderr.write(Logs.colors.cursor_off)
+               try:
+                       self.compile()
+               finally:
+                       if self.progress_bar==1:
+                               c=len(self.returned_tasks)or 1
+                               self.to_log(self.progress_line(c,c,Logs.colors.BLUE,Logs.colors.NORMAL))
+                               print('')
+                               sys.stdout.flush()
+                               sys.stderr.write(Logs.colors.cursor_on)
+                       Logs.info("Waf: Leaving directory `%s'"%self.variant_dir)
+               self.post_build()
+       def restore(self):
+               try:
+                       env=ConfigSet.ConfigSet(os.path.join(self.cache_dir,'build.config.py'))
+               except(IOError,OSError):
+                       pass
+               else:
+                       if env['version']<Context.HEXVERSION:
+                               raise Errors.WafError('Version mismatch! reconfigure the project')
+                       for t in env['tools']:
+                               self.setup(**t)
+               dbfn=os.path.join(self.variant_dir,Context.DBFILE)
+               try:
+                       data=Utils.readf(dbfn,'rb')
+               except(IOError,EOFError):
+                       Logs.debug('build: Could not load the build cache %s (missing)'%dbfn)
+               else:
+                       try:
+                               waflib.Node.pickle_lock.acquire()
+                               waflib.Node.Nod3=self.node_class
+                               try:
+                                       data=cPickle.loads(data)
+                               except Exception ,e:
+                                       Logs.debug('build: Could not pickle the build cache %s: %r'%(dbfn,e))
+                               else:
+                                       for x in SAVED_ATTRS:
+                                               setattr(self,x,data[x])
+                       finally:
+                               waflib.Node.pickle_lock.release()
+               self.init_dirs()
+       def store(self):
+               data={}
+               for x in SAVED_ATTRS:
+                       data[x]=getattr(self,x)
+               db=os.path.join(self.variant_dir,Context.DBFILE)
+               try:
+                       waflib.Node.pickle_lock.acquire()
+                       waflib.Node.Nod3=self.node_class
+                       x=cPickle.dumps(data,-1)
+               finally:
+                       waflib.Node.pickle_lock.release()
+               Utils.writef(db+'.tmp',x,m='wb')
+               try:
+                       st=os.stat(db)
+                       os.remove(db)
+                       if not Utils.is_win32:
+                               os.chown(db+'.tmp',st.st_uid,st.st_gid)
+               except(AttributeError,OSError):
+                       pass
+               os.rename(db+'.tmp',db)
+       def compile(self):
+               Logs.debug('build: compile()')
+               self.producer=Runner.Parallel(self,self.jobs)
+               self.producer.biter=self.get_build_iterator()
+               self.returned_tasks=[]
+               try:
+                       self.producer.start()
+               except KeyboardInterrupt:
+                       self.store()
+                       raise
+               else:
+                       if self.producer.dirty:
+                               self.store()
+               if self.producer.error:
+                       raise Errors.BuildError(self.producer.error)
+       def setup(self,tool,tooldir=None,funs=None):
+               if isinstance(tool,list):
+                       for i in tool:self.setup(i,tooldir)
+                       return
+               module=Context.load_tool(tool,tooldir)
+               if hasattr(module,"setup"):module.setup(self)
+       def get_env(self):
+               try:
+                       return self.all_envs[self.variant]
+               except KeyError:
+                       return self.all_envs['']
+       def set_env(self,val):
+               self.all_envs[self.variant]=val
+       env=property(get_env,set_env)
+       def add_manual_dependency(self,path,value):
+               if path is None:
+                       raise ValueError('Invalid input')
+               if isinstance(path,waflib.Node.Node):
+                       node=path
+               elif os.path.isabs(path):
+                       node=self.root.find_resource(path)
+               else:
+                       node=self.path.find_resource(path)
+               if isinstance(value,list):
+                       self.deps_man[id(node)].extend(value)
+               else:
+                       self.deps_man[id(node)].append(value)
+       def launch_node(self):
+               try:
+                       return self.p_ln
+               except AttributeError:
+                       self.p_ln=self.root.find_dir(self.launch_dir)
+                       return self.p_ln
+       def hash_env_vars(self,env,vars_lst):
+               if not env.table:
+                       env=env.parent
+                       if not env:
+                               return Utils.SIG_NIL
+               idx=str(id(env))+str(vars_lst)
+               try:
+                       cache=self.cache_env
+               except AttributeError:
+                       cache=self.cache_env={}
+               else:
+                       try:
+                               return self.cache_env[idx]
+                       except KeyError:
+                               pass
+               lst=[env[a]for a in vars_lst]
+               ret=Utils.h_list(lst)
+               Logs.debug('envhash: %s %r',Utils.to_hex(ret),lst)
+               cache[idx]=ret
+               return ret
+       def get_tgen_by_name(self,name):
+               cache=self.task_gen_cache_names
+               if not cache:
+                       for g in self.groups:
+                               for tg in g:
+                                       try:
+                                               cache[tg.name]=tg
+                                       except AttributeError:
+                                               pass
+               try:
+                       return cache[name]
+               except KeyError:
+                       raise Errors.WafError('Could not find a task generator for the name %r'%name)
+       def progress_line(self,state,total,col1,col2):
+               n=len(str(total))
+               Utils.rot_idx+=1
+               ind=Utils.rot_chr[Utils.rot_idx%4]
+               pc=(100.*state)/total
+               eta=str(self.timer)
+               fs="[%%%dd/%%%dd][%%s%%2d%%%%%%s][%s]["%(n,n,ind)
+               left=fs%(state,total,col1,pc,col2)
+               right='][%s%s%s]'%(col1,eta,col2)
+               cols=Logs.get_term_cols()-len(left)-len(right)+2*len(col1)+2*len(col2)
+               if cols<7:cols=7
+               ratio=((cols*state)//total)-1
+               bar=('='*ratio+'>').ljust(cols)
+               msg=Utils.indicator%(left,bar,right)
+               return msg
+       def declare_chain(self,*k,**kw):
+               return TaskGen.declare_chain(*k,**kw)
+       def pre_build(self):
+               for m in getattr(self,'pre_funs',[]):
+                       m(self)
+       def post_build(self):
+               for m in getattr(self,'post_funs',[]):
+                       m(self)
+       def add_pre_fun(self,meth):
+               try:
+                       self.pre_funs.append(meth)
+               except AttributeError:
+                       self.pre_funs=[meth]
+       def add_post_fun(self,meth):
+               try:
+                       self.post_funs.append(meth)
+               except AttributeError:
+                       self.post_funs=[meth]
+       def get_group(self,x):
+               if not self.groups:
+                       self.add_group()
+               if x is None:
+                       return self.groups[self.current_group]
+               if x in self.group_names:
+                       return self.group_names[x]
+               return self.groups[x]
+       def add_to_group(self,tgen,group=None):
+               assert(isinstance(tgen,TaskGen.task_gen)or isinstance(tgen,Task.TaskBase))
+               tgen.bld=self
+               self.get_group(group).append(tgen)
+       def get_group_name(self,g):
+               if not isinstance(g,list):
+                       g=self.groups[g]
+               for x in self.group_names:
+                       if id(self.group_names[x])==id(g):
+                               return x
+               return''
+       def get_group_idx(self,tg):
+               se=id(tg)
+               for i in range(len(self.groups)):
+                       for t in self.groups[i]:
+                               if id(t)==se:
+                                       return i
+               return None
+       def add_group(self,name=None,move=True):
+               if name and name in self.group_names:
+                       Logs.error('add_group: name %s already present'%name)
+               g=[]
+               self.group_names[name]=g
+               self.groups.append(g)
+               if move:
+                       self.current_group=len(self.groups)-1
+       def set_group(self,idx):
+               if isinstance(idx,str):
+                       g=self.group_names[idx]
+                       for i in range(len(self.groups)):
+                               if id(g)==id(self.groups[i]):
+                                       self.current_group=i
+               else:
+                       self.current_group=idx
+       def total(self):
+               total=0
+               for group in self.groups:
+                       for tg in group:
+                               try:
+                                       total+=len(tg.tasks)
+                               except AttributeError:
+                                       total+=1
+               return total
+       def get_targets(self):
+               to_post=[]
+               min_grp=0
+               for name in self.targets.split(','):
+                       tg=self.get_tgen_by_name(name)
+                       if not tg:
+                               raise Errors.WafError('target %r does not exist'%name)
+                       m=self.get_group_idx(tg)
+                       if m>min_grp:
+                               min_grp=m
+                               to_post=[tg]
+                       elif m==min_grp:
+                               to_post.append(tg)
+               return(min_grp,to_post)
+       def get_all_task_gen(self):
+               lst=[]
+               for g in self.groups:
+                       lst.extend(g)
+               return lst
+       def post_group(self):
+               if self.targets=='*':
+                       for tg in self.groups[self.cur]:
+                               try:
+                                       f=tg.post
+                               except AttributeError:
+                                       pass
+                               else:
+                                       f()
+               elif self.targets:
+                       if self.cur<self._min_grp:
+                               for tg in self.groups[self.cur]:
+                                       try:
+                                               f=tg.post
+                                       except AttributeError:
+                                               pass
+                                       else:
+                                               f()
+                       else:
+                               for tg in self._exact_tg:
+                                       tg.post()
+               else:
+                       ln=self.launch_node()
+                       if ln.is_child_of(self.bldnode):
+                               Logs.warn('Building from the build directory, forcing --targets=*')
+                               ln=self.srcnode
+                       elif not ln.is_child_of(self.srcnode):
+                               Logs.warn('CWD %s is not under %s, forcing --targets=* (run distclean?)'%(ln.abspath(),self.srcnode.abspath()))
+                               ln=self.srcnode
+                       for tg in self.groups[self.cur]:
+                               try:
+                                       f=tg.post
+                               except AttributeError:
+                                       pass
+                               else:
+                                       if tg.path.is_child_of(ln):
+                                               f()
+       def get_tasks_group(self,idx):
+               tasks=[]
+               for tg in self.groups[idx]:
+                       try:
+                               tasks.extend(tg.tasks)
+                       except AttributeError:
+                               tasks.append(tg)
+               return tasks
+       def get_build_iterator(self):
+               self.cur=0
+               if self.targets and self.targets!='*':
+                       (self._min_grp,self._exact_tg)=self.get_targets()
+               global lazy_post
+               if self.post_mode!=POST_LAZY:
+                       while self.cur<len(self.groups):
+                               self.post_group()
+                               self.cur+=1
+                       self.cur=0
+               while self.cur<len(self.groups):
+                       if self.post_mode!=POST_AT_ONCE:
+                               self.post_group()
+                       tasks=self.get_tasks_group(self.cur)
+                       Task.set_file_constraints(tasks)
+                       Task.set_precedence_constraints(tasks)
+                       self.cur_tasks=tasks
+                       self.cur+=1
+                       if not tasks:
+                               continue
+                       yield tasks
+               while 1:
+                       yield[]
+class inst(Task.Task):
+       color='CYAN'
+       def uid(self):
+               lst=[self.dest,self.path]+self.source
+               return Utils.h_list(repr(lst))
+       def post(self):
+               buf=[]
+               for x in self.source:
+                       if isinstance(x,waflib.Node.Node):
+                               y=x
+                       else:
+                               y=self.path.find_resource(x)
+                               if not y:
+                                       if Logs.verbose:
+                                               Logs.warn('Could not find %s immediately (may cause broken builds)'%x)
+                                       idx=self.generator.bld.get_group_idx(self)
+                                       for tg in self.generator.bld.groups[idx]:
+                                               if not isinstance(tg,inst)and id(tg)!=id(self):
+                                                       tg.post()
+                                               y=self.path.find_resource(x)
+                                               if y:
+                                                       break
+                                       else:
+                                               raise Errors.WafError('Could not find %r in %r'%(x,self.path))
+                       buf.append(y)
+               self.inputs=buf
+       def runnable_status(self):
+               ret=super(inst,self).runnable_status()
+               if ret==Task.SKIP_ME:
+                       return Task.RUN_ME
+               return ret
+       def __str__(self):
+               return''
+       def run(self):
+               return self.generator.exec_task()
+       def get_install_path(self,destdir=True):
+               dest=Utils.subst_vars(self.dest,self.env)
+               dest=dest.replace('/',os.sep)
+               if destdir and Options.options.destdir:
+                       dest=os.path.join(Options.options.destdir,os.path.splitdrive(dest)[1].lstrip(os.sep))
+               return dest
+       def exec_install_files(self):
+               destpath=self.get_install_path()
+               if not destpath:
+                       raise Errors.WafError('unknown installation path %r'%self.generator)
+               for x,y in zip(self.source,self.inputs):
+                       if self.relative_trick:
+                               destfile=os.path.join(destpath,y.path_from(self.path))
+                       else:
+                               destfile=os.path.join(destpath,y.name)
+                       self.generator.bld.do_install(y.abspath(),destfile,self.chmod)
+       def exec_install_as(self):
+               destfile=self.get_install_path()
+               self.generator.bld.do_install(self.inputs[0].abspath(),destfile,self.chmod)
+       def exec_symlink_as(self):
+               destfile=self.get_install_path()
+               src=self.link
+               if self.relative_trick:
+                       src=os.path.relpath(src,os.path.dirname(destfile))
+               self.generator.bld.do_link(src,destfile)
+class InstallContext(BuildContext):
+       '''installs the targets on the system'''
+       cmd='install'
+       def __init__(self,**kw):
+               super(InstallContext,self).__init__(**kw)
+               self.uninstall=[]
+               self.is_install=INSTALL
+       def do_install(self,src,tgt,chmod=Utils.O644):
+               d,_=os.path.split(tgt)
+               if not d:
+                       raise Errors.WafError('Invalid installation given %r->%r'%(src,tgt))
+               Utils.check_dir(d)
+               srclbl=src.replace(self.srcnode.abspath()+os.sep,'')
+               if not Options.options.force:
+                       try:
+                               st1=os.stat(tgt)
+                               st2=os.stat(src)
+                       except OSError:
+                               pass
+                       else:
+                               if st1.st_mtime+2>=st2.st_mtime and st1.st_size==st2.st_size:
+                                       if not self.progress_bar:
+                                               Logs.info('- install %s (from %s)'%(tgt,srclbl))
+                                       return False
+               if not self.progress_bar:
+                       Logs.info('+ install %s (from %s)'%(tgt,srclbl))
+               try:
+                       os.remove(tgt)
+               except OSError:
+                       pass
+               try:
+                       shutil.copy2(src,tgt)
+                       os.chmod(tgt,chmod)
+               except IOError:
+                       try:
+                               os.stat(src)
+                       except(OSError,IOError):
+                               Logs.error('File %r does not exist'%src)
+                       raise Errors.WafError('Could not install the file %r'%tgt)
+       def do_link(self,src,tgt):
+               d,_=os.path.split(tgt)
+               Utils.check_dir(d)
+               link=False
+               if not os.path.islink(tgt):
+                       link=True
+               elif os.readlink(tgt)!=src:
+                       link=True
+               if link:
+                       try:os.remove(tgt)
+                       except OSError:pass
+                       if not self.progress_bar:
+                               Logs.info('+ symlink %s (to %s)'%(tgt,src))
+                       os.symlink(src,tgt)
+               else:
+                       if not self.progress_bar:
+                               Logs.info('- symlink %s (to %s)'%(tgt,src))
+       def run_task_now(self,tsk,postpone):
+               tsk.post()
+               if not postpone:
+                       if tsk.runnable_status()==Task.ASK_LATER:
+                               raise self.WafError('cannot post the task %r'%tsk)
+                       tsk.run()
+       def install_files(self,dest,files,env=None,chmod=Utils.O644,relative_trick=False,cwd=None,add=True,postpone=True):
+               tsk=inst(env=env or self.env)
+               tsk.bld=self
+               tsk.path=cwd or self.path
+               tsk.chmod=chmod
+               if isinstance(files,waflib.Node.Node):
+                       tsk.source=[files]
+               else:
+                       tsk.source=Utils.to_list(files)
+               tsk.dest=dest
+               tsk.exec_task=tsk.exec_install_files
+               tsk.relative_trick=relative_trick
+               if add:self.add_to_group(tsk)
+               self.run_task_now(tsk,postpone)
+               return tsk
+       def install_as(self,dest,srcfile,env=None,chmod=Utils.O644,cwd=None,add=True,postpone=True):
+               tsk=inst(env=env or self.env)
+               tsk.bld=self
+               tsk.path=cwd or self.path
+               tsk.chmod=chmod
+               tsk.source=[srcfile]
+               tsk.dest=dest
+               tsk.exec_task=tsk.exec_install_as
+               if add:self.add_to_group(tsk)
+               self.run_task_now(tsk,postpone)
+               return tsk
+       def symlink_as(self,dest,src,env=None,cwd=None,add=True,postpone=True,relative_trick=False):
+               if Utils.is_win32:
+                       return
+               tsk=inst(env=env or self.env)
+               tsk.bld=self
+               tsk.dest=dest
+               tsk.path=cwd or self.path
+               tsk.source=[]
+               tsk.link=src
+               tsk.relative_trick=relative_trick
+               tsk.exec_task=tsk.exec_symlink_as
+               if add:self.add_to_group(tsk)
+               self.run_task_now(tsk,postpone)
+               return tsk
+class UninstallContext(InstallContext):
+       '''removes the targets installed'''
+       cmd='uninstall'
+       def __init__(self,**kw):
+               super(UninstallContext,self).__init__(**kw)
+               self.is_install=UNINSTALL
+       def do_install(self,src,tgt,chmod=Utils.O644):
+               if not self.progress_bar:
+                       Logs.info('- remove %s'%tgt)
+               self.uninstall.append(tgt)
+               try:
+                       os.remove(tgt)
+               except OSError ,e:
+                       if e.errno!=errno.ENOENT:
+                               if not getattr(self,'uninstall_error',None):
+                                       self.uninstall_error=True
+                                       Logs.warn('build: some files could not be uninstalled (retry with -vv to list them)')
+                               if Logs.verbose>1:
+                                       Logs.warn('Could not remove %s (error code %r)'%(e.filename,e.errno))
+               while tgt:
+                       tgt=os.path.dirname(tgt)
+                       try:
+                               os.rmdir(tgt)
+                       except OSError:
+                               break
+       def do_link(self,src,tgt):
+               try:
+                       if not self.progress_bar:
+                               Logs.info('- remove %s'%tgt)
+                       os.remove(tgt)
+               except OSError:
+                       pass
+               while tgt:
+                       tgt=os.path.dirname(tgt)
+                       try:
+                               os.rmdir(tgt)
+                       except OSError:
+                               break
+       def execute(self):
+               try:
+                       def runnable_status(self):
+                               return Task.SKIP_ME
+                       setattr(Task.Task,'runnable_status_back',Task.Task.runnable_status)
+                       setattr(Task.Task,'runnable_status',runnable_status)
+                       super(UninstallContext,self).execute()
+               finally:
+                       setattr(Task.Task,'runnable_status',Task.Task.runnable_status_back)
+class CleanContext(BuildContext):
+       '''cleans the project'''
+       cmd='clean'
+       def execute(self):
+               self.restore()
+               if not self.all_envs:
+                       self.load_envs()
+               self.recurse([self.run_dir])
+               try:
+                       self.clean()
+               finally:
+                       self.store()
+       def clean(self):
+               Logs.debug('build: clean called')
+               if self.bldnode!=self.srcnode:
+                       lst=[]
+                       for e in self.all_envs.values():
+                               lst.extend(self.root.find_or_declare(f)for f in e[CFG_FILES])
+                       for n in self.bldnode.ant_glob('**/*',excl='.lock* *conf_check_*/** config.log c4che/*',quiet=True):
+                               if n in lst:
+                                       continue
+                               n.delete()
+               self.root.children={}
+               for v in'node_deps task_sigs raw_deps'.split():
+                       setattr(self,v,{})
+class ListContext(BuildContext):
+       '''lists the targets to execute'''
+       cmd='list'
+       def execute(self):
+               self.restore()
+               if not self.all_envs:
+                       self.load_envs()
+               self.recurse([self.run_dir])
+               self.pre_build()
+               self.timer=Utils.Timer()
+               for g in self.groups:
+                       for tg in g:
+                               try:
+                                       f=tg.post
+                               except AttributeError:
+                                       pass
+                               else:
+                                       f()
+               try:
+                       self.get_tgen_by_name('')
+               except Exception:
+                       pass
+               lst=list(self.task_gen_cache_names.keys())
+               lst.sort()
+               for k in lst:
+                       Logs.pprint('GREEN',k)
+class StepContext(BuildContext):
+       '''executes tasks in a step-by-step fashion, for debugging'''
+       cmd='step'
+       def __init__(self,**kw):
+               super(StepContext,self).__init__(**kw)
+               self.files=Options.options.files
+       def compile(self):
+               if not self.files:
+                       Logs.warn('Add a pattern for the debug build, for example "waf step --files=main.c,app"')
+                       BuildContext.compile(self)
+                       return
+               targets=None
+               if self.targets and self.targets!='*':
+                       targets=self.targets.split(',')
+               for g in self.groups:
+                       for tg in g:
+                               if targets and tg.name not in targets:
+                                       continue
+                               try:
+                                       f=tg.post
+                               except AttributeError:
+                                       pass
+                               else:
+                                       f()
+                       for pat in self.files.split(','):
+                               matcher=self.get_matcher(pat)
+                               for tg in g:
+                                       if isinstance(tg,Task.TaskBase):
+                                               lst=[tg]
+                                       else:
+                                               lst=tg.tasks
+                                       for tsk in lst:
+                                               do_exec=False
+                                               for node in getattr(tsk,'inputs',[]):
+                                                       if matcher(node,output=False):
+                                                               do_exec=True
+                                                               break
+                                               for node in getattr(tsk,'outputs',[]):
+                                                       if matcher(node,output=True):
+                                                               do_exec=True
+                                                               break
+                                               if do_exec:
+                                                       ret=tsk.run()
+                                                       Logs.info('%s -> exit %r'%(str(tsk),ret))
+       def get_matcher(self,pat):
+               inn=True
+               out=True
+               if pat.startswith('in:'):
+                       out=False
+                       pat=pat.replace('in:','')
+               elif pat.startswith('out:'):
+                       inn=False
+                       pat=pat.replace('out:','')
+               anode=self.root.find_node(pat)
+               pattern=None
+               if not anode:
+                       if not pat.startswith('^'):
+                               pat='^.+?%s'%pat
+                       if not pat.endswith('$'):
+                               pat='%s$'%pat
+                       pattern=re.compile(pat)
+               def match(node,output):
+                       if output==True and not out:
+                               return False
+                       if output==False and not inn:
+                               return False
+                       if anode:
+                               return anode==node
+                       else:
+                               return pattern.match(node.abspath())
+               return match
+BuildContext.store=Utils.nogc(BuildContext.store)
+BuildContext.restore=Utils.nogc(BuildContext.restore)
diff --git a/waflib/Build.pyc b/waflib/Build.pyc
new file mode 100644 (file)
index 0000000..2916a2a
Binary files /dev/null and b/waflib/Build.pyc differ
diff --git a/waflib/ConfigSet.py b/waflib/ConfigSet.py
new file mode 100644 (file)
index 0000000..f9fdcc7
--- /dev/null
@@ -0,0 +1,152 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import copy,re,os
+from waflib import Logs,Utils
+re_imp=re.compile('^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
+class ConfigSet(object):
+       __slots__=('table','parent')
+       def __init__(self,filename=None):
+               self.table={}
+               if filename:
+                       self.load(filename)
+       def __contains__(self,key):
+               if key in self.table:return True
+               try:return self.parent.__contains__(key)
+               except AttributeError:return False
+       def keys(self):
+               keys=set()
+               cur=self
+               while cur:
+                       keys.update(cur.table.keys())
+                       cur=getattr(cur,'parent',None)
+               keys=list(keys)
+               keys.sort()
+               return keys
+       def __str__(self):
+               return"\n".join(["%r %r"%(x,self.__getitem__(x))for x in self.keys()])
+       def __getitem__(self,key):
+               try:
+                       while 1:
+                               x=self.table.get(key,None)
+                               if not x is None:
+                                       return x
+                               self=self.parent
+               except AttributeError:
+                       return[]
+       def __setitem__(self,key,value):
+               self.table[key]=value
+       def __delitem__(self,key):
+               self[key]=[]
+       def __getattr__(self,name):
+               if name in self.__slots__:
+                       return object.__getattr__(self,name)
+               else:
+                       return self[name]
+       def __setattr__(self,name,value):
+               if name in self.__slots__:
+                       object.__setattr__(self,name,value)
+               else:
+                       self[name]=value
+       def __delattr__(self,name):
+               if name in self.__slots__:
+                       object.__delattr__(self,name)
+               else:
+                       del self[name]
+       def derive(self):
+               newenv=ConfigSet()
+               newenv.parent=self
+               return newenv
+       def detach(self):
+               tbl=self.get_merged_dict()
+               try:
+                       delattr(self,'parent')
+               except AttributeError:
+                       pass
+               else:
+                       keys=tbl.keys()
+                       for x in keys:
+                               tbl[x]=copy.deepcopy(tbl[x])
+                       self.table=tbl
+       def get_flat(self,key):
+               s=self[key]
+               if isinstance(s,str):return s
+               return' '.join(s)
+       def _get_list_value_for_modification(self,key):
+               try:
+                       value=self.table[key]
+               except KeyError:
+                       try:value=self.parent[key]
+                       except AttributeError:value=[]
+                       if isinstance(value,list):
+                               value=value[:]
+                       else:
+                               value=[value]
+               else:
+                       if not isinstance(value,list):
+                               value=[value]
+               self.table[key]=value
+               return value
+       def append_value(self,var,val):
+               current_value=self._get_list_value_for_modification(var)
+               if isinstance(val,str):
+                       val=[val]
+               current_value.extend(val)
+       def prepend_value(self,var,val):
+               if isinstance(val,str):
+                       val=[val]
+               self.table[var]=val+self._get_list_value_for_modification(var)
+       def append_unique(self,var,val):
+               if isinstance(val,str):
+                       val=[val]
+               current_value=self._get_list_value_for_modification(var)
+               for x in val:
+                       if x not in current_value:
+                               current_value.append(x)
+       def get_merged_dict(self):
+               table_list=[]
+               env=self
+               while 1:
+                       table_list.insert(0,env.table)
+                       try:env=env.parent
+                       except AttributeError:break
+               merged_table={}
+               for table in table_list:
+                       merged_table.update(table)
+               return merged_table
+       def store(self,filename):
+               try:
+                       os.makedirs(os.path.split(filename)[0])
+               except OSError:
+                       pass
+               buf=[]
+               merged_table=self.get_merged_dict()
+               keys=list(merged_table.keys())
+               keys.sort()
+               try:
+                       fun=ascii
+               except NameError:
+                       fun=repr
+               for k in keys:
+                       if k!='undo_stack':
+                               buf.append('%s = %s\n'%(k,fun(merged_table[k])))
+               Utils.writef(filename,''.join(buf))
+       def load(self,filename):
+               tbl=self.table
+               code=Utils.readf(filename,m='rU')
+               for m in re_imp.finditer(code):
+                       g=m.group
+                       tbl[g(2)]=eval(g(3))
+               Logs.debug('env: %s'%str(self.table))
+       def update(self,d):
+               for k,v in d.items():
+                       self[k]=v
+       def stash(self):
+               orig=self.table
+               tbl=self.table=self.table.copy()
+               for x in tbl.keys():
+                       tbl[x]=copy.deepcopy(tbl[x])
+               self.undo_stack=self.undo_stack+[orig]
+       def revert(self):
+               self.table=self.undo_stack.pop(-1)
diff --git a/waflib/ConfigSet.pyc b/waflib/ConfigSet.pyc
new file mode 100644 (file)
index 0000000..b3f2108
Binary files /dev/null and b/waflib/ConfigSet.pyc differ
diff --git a/waflib/Configure.py b/waflib/Configure.py
new file mode 100644 (file)
index 0000000..e8148d5
--- /dev/null
@@ -0,0 +1,317 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,shlex,sys,time
+from waflib import ConfigSet,Utils,Options,Logs,Context,Build,Errors
+try:
+       from urllib import request
+except ImportError:
+       from urllib import urlopen
+else:
+       urlopen=request.urlopen
+BREAK='break'
+CONTINUE='continue'
+WAF_CONFIG_LOG='config.log'
+autoconfig=False
+conf_template='''# project %(app)s configured on %(now)s by
+# waf %(wafver)s (abi %(abi)s, python %(pyver)x on %(systype)s)
+# using %(args)s
+#'''
+def download_check(node):
+       pass
+def download_tool(tool,force=False,ctx=None):
+       for x in Utils.to_list(Context.remote_repo):
+               for sub in Utils.to_list(Context.remote_locs):
+                       url='/'.join((x,sub,tool+'.py'))
+                       try:
+                               web=urlopen(url)
+                               try:
+                                       if web.getcode()!=200:
+                                               continue
+                               except AttributeError:
+                                       pass
+                       except Exception:
+                               continue
+                       else:
+                               tmp=ctx.root.make_node(os.sep.join((Context.waf_dir,'waflib','extras',tool+'.py')))
+                               tmp.write(web.read(),'wb')
+                               Logs.warn('Downloaded %s from %s'%(tool,url))
+                               download_check(tmp)
+                               try:
+                                       module=Context.load_tool(tool)
+                               except Exception:
+                                       Logs.warn('The tool %s from %s is unusable'%(tool,url))
+                                       try:
+                                               tmp.delete()
+                                       except Exception:
+                                               pass
+                                       continue
+                               return module
+       raise Errors.WafError('Could not load the Waf tool')
+class ConfigurationContext(Context.Context):
+       '''configures the project'''
+       cmd='configure'
+       error_handlers=[]
+       def __init__(self,**kw):
+               super(ConfigurationContext,self).__init__(**kw)
+               self.environ=dict(os.environ)
+               self.all_envs={}
+               self.top_dir=None
+               self.out_dir=None
+               self.tools=[]
+               self.hash=0
+               self.files=[]
+               self.tool_cache=[]
+               self.setenv('')
+       def setenv(self,name,env=None):
+               if name not in self.all_envs or env:
+                       if not env:
+                               env=ConfigSet.ConfigSet()
+                               self.prepare_env(env)
+                       else:
+                               env=env.derive()
+                       self.all_envs[name]=env
+               self.variant=name
+       def get_env(self):
+               return self.all_envs[self.variant]
+       def set_env(self,val):
+               self.all_envs[self.variant]=val
+       env=property(get_env,set_env)
+       def init_dirs(self):
+               top=self.top_dir
+               if not top:
+                       top=Options.options.top
+               if not top:
+                       top=getattr(Context.g_module,Context.TOP,None)
+               if not top:
+                       top=self.path.abspath()
+               top=os.path.abspath(top)
+               self.srcnode=(os.path.isabs(top)and self.root or self.path).find_dir(top)
+               assert(self.srcnode)
+               out=self.out_dir
+               if not out:
+                       out=Options.options.out
+               if not out:
+                       out=getattr(Context.g_module,Context.OUT,None)
+               if not out:
+                       out=Options.lockfile.replace('.lock-waf_%s_'%sys.platform,'').replace('.lock-waf','')
+               self.bldnode=(os.path.isabs(out)and self.root or self.path).make_node(out)
+               self.bldnode.mkdir()
+               if not os.path.isdir(self.bldnode.abspath()):
+                       conf.fatal('Could not create the build directory %s'%self.bldnode.abspath())
+       def execute(self):
+               self.init_dirs()
+               self.cachedir=self.bldnode.make_node(Build.CACHE_DIR)
+               self.cachedir.mkdir()
+               path=os.path.join(self.bldnode.abspath(),WAF_CONFIG_LOG)
+               self.logger=Logs.make_logger(path,'cfg')
+               app=getattr(Context.g_module,'APPNAME','')
+               if app:
+                       ver=getattr(Context.g_module,'VERSION','')
+                       if ver:
+                               app="%s (%s)"%(app,ver)
+               now=time.ctime()
+               pyver=sys.hexversion
+               systype=sys.platform
+               args=" ".join(sys.argv)
+               wafver=Context.WAFVERSION
+               abi=Context.ABI
+               self.to_log(conf_template%vars())
+               self.msg('Setting top to',self.srcnode.abspath())
+               self.msg('Setting out to',self.bldnode.abspath())
+               if id(self.srcnode)==id(self.bldnode):
+                       Logs.warn('Setting top == out (remember to use "update_outputs")')
+               elif id(self.path)!=id(self.srcnode):
+                       if self.srcnode.is_child_of(self.path):
+                               Logs.warn('Are you certain that you do not want to set top="." ?')
+               super(ConfigurationContext,self).execute()
+               self.store()
+               Context.top_dir=self.srcnode.abspath()
+               Context.out_dir=self.bldnode.abspath()
+               env=ConfigSet.ConfigSet()
+               env['argv']=sys.argv
+               env['options']=Options.options.__dict__
+               env.run_dir=Context.run_dir
+               env.top_dir=Context.top_dir
+               env.out_dir=Context.out_dir
+               env['hash']=self.hash
+               env['files']=self.files
+               env['environ']=dict(self.environ)
+               if not self.env.NO_LOCK_IN_RUN:
+                       env.store(Context.run_dir+os.sep+Options.lockfile)
+               if not self.env.NO_LOCK_IN_TOP:
+                       env.store(Context.top_dir+os.sep+Options.lockfile)
+               if not self.env.NO_LOCK_IN_OUT:
+                       env.store(Context.out_dir+os.sep+Options.lockfile)
+       def prepare_env(self,env):
+               if not env.PREFIX:
+                       if Options.options.prefix or Utils.is_win32:
+                               env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
+                       else:
+                               env.PREFIX=''
+               if not env.BINDIR:
+                       env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
+               if not env.LIBDIR:
+                       env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env)
+       def store(self):
+               n=self.cachedir.make_node('build.config.py')
+               n.write('version = 0x%x\ntools = %r\n'%(Context.HEXVERSION,self.tools))
+               if not self.all_envs:
+                       self.fatal('nothing to store in the configuration context!')
+               for key in self.all_envs:
+                       tmpenv=self.all_envs[key]
+                       tmpenv.store(os.path.join(self.cachedir.abspath(),key+Build.CACHE_SUFFIX))
+       def load(self,input,tooldir=None,funs=None,download=True):
+               tools=Utils.to_list(input)
+               if tooldir:tooldir=Utils.to_list(tooldir)
+               for tool in tools:
+                       mag=(tool,id(self.env),funs)
+                       if mag in self.tool_cache:
+                               self.to_log('(tool %s is already loaded, skipping)'%tool)
+                               continue
+                       self.tool_cache.append(mag)
+                       module=None
+                       try:
+                               module=Context.load_tool(tool,tooldir)
+                       except ImportError ,e:
+                               if Options.options.download:
+                                       module=download_tool(tool,ctx=self)
+                                       if not module:
+                                               self.fatal('Could not load the Waf tool %r or download a suitable replacement from the repository (sys.path %r)\n%s'%(tool,sys.path,e))
+                               else:
+                                       self.fatal('Could not load the Waf tool %r from %r (try the --download option?):\n%s'%(tool,sys.path,e))
+                       except Exception ,e:
+                               self.to_log('imp %r (%r & %r)'%(tool,tooldir,funs))
+                               self.to_log(Utils.ex_stack())
+                               raise
+                       if funs is not None:
+                               self.eval_rules(funs)
+                       else:
+                               func=getattr(module,'configure',None)
+                               if func:
+                                       if type(func)is type(Utils.readf):func(self)
+                                       else:self.eval_rules(func)
+                       self.tools.append({'tool':tool,'tooldir':tooldir,'funs':funs})
+       def post_recurse(self,node):
+               super(ConfigurationContext,self).post_recurse(node)
+               self.hash=hash((self.hash,node.read('rb')))
+               self.files.append(node.abspath())
+       def eval_rules(self,rules):
+               self.rules=Utils.to_list(rules)
+               for x in self.rules:
+                       f=getattr(self,x)
+                       if not f:self.fatal("No such method '%s'."%x)
+                       try:
+                               f()
+                       except Exception ,e:
+                               ret=self.err_handler(x,e)
+                               if ret==BREAK:
+                                       break
+                               elif ret==CONTINUE:
+                                       continue
+                               else:
+                                       raise
+       def err_handler(self,fun,error):
+               pass
+def conf(f):
+       def fun(*k,**kw):
+               mandatory=True
+               if'mandatory'in kw:
+                       mandatory=kw['mandatory']
+                       del kw['mandatory']
+               try:
+                       return f(*k,**kw)
+               except Errors.ConfigurationError:
+                       if mandatory:
+                               raise
+       setattr(ConfigurationContext,f.__name__,fun)
+       setattr(Build.BuildContext,f.__name__,fun)
+       return f
+@conf
+def add_os_flags(self,var,dest=None):
+       try:self.env.append_value(dest or var,shlex.split(self.environ[var]))
+       except KeyError:pass
+@conf
+def cmd_to_list(self,cmd):
+       if isinstance(cmd,str)and cmd.find(' '):
+               try:
+                       os.stat(cmd)
+               except OSError:
+                       return shlex.split(cmd)
+               else:
+                       return[cmd]
+       return cmd
+@conf
+def check_waf_version(self,mini='1.6.99',maxi='1.8.0'):
+       self.start_msg('Checking for waf version in %s-%s'%(str(mini),str(maxi)))
+       ver=Context.HEXVERSION
+       if Utils.num2ver(mini)>ver:
+               self.fatal('waf version should be at least %r (%r found)'%(Utils.num2ver(mini),ver))
+       if Utils.num2ver(maxi)<ver:
+               self.fatal('waf version should be at most %r (%r found)'%(Utils.num2ver(maxi),ver))
+       self.end_msg('ok')
+@conf
+def find_file(self,filename,path_list=[]):
+       for n in Utils.to_list(filename):
+               for d in Utils.to_list(path_list):
+                       p=os.path.join(d,n)
+                       if os.path.exists(p):
+                               return p
+       self.fatal('Could not find %r'%filename)
+@conf
+def find_program(self,filename,**kw):
+       exts=kw.get('exts',Utils.is_win32 and'.exe,.com,.bat,.cmd'or',.sh,.pl,.py')
+       environ=kw.get('environ',os.environ)
+       ret=''
+       filename=Utils.to_list(filename)
+       var=kw.get('var','')
+       if not var:
+               var=filename[0].upper()
+       if self.env[var]:
+               ret=self.env[var]
+       elif var in environ:
+               ret=environ[var]
+       path_list=kw.get('path_list','')
+       if not ret:
+               if path_list:
+                       path_list=Utils.to_list(path_list)
+               else:
+                       path_list=environ.get('PATH','').split(os.pathsep)
+               if not isinstance(filename,list):
+                       filename=[filename]
+               for a in exts.split(','):
+                       if ret:
+                               break
+                       for b in filename:
+                               if ret:
+                                       break
+                               for c in path_list:
+                                       if ret:
+                                               break
+                                       x=os.path.expanduser(os.path.join(c,b+a))
+                                       if os.path.isfile(x):
+                                               ret=x
+       if not ret and Utils.winreg:
+               ret=Utils.get_registry_app_path(Utils.winreg.HKEY_CURRENT_USER,filename)
+       if not ret and Utils.winreg:
+               ret=Utils.get_registry_app_path(Utils.winreg.HKEY_LOCAL_MACHINE,filename)
+       self.msg('Checking for program '+','.join(filename),ret or False)
+       self.to_log('find program=%r paths=%r var=%r -> %r'%(filename,path_list,var,ret))
+       if not ret:
+               self.fatal(kw.get('errmsg','')or'Could not find the program %s'%','.join(filename))
+       if var:
+               self.env[var]=ret
+       return ret
+@conf
+def find_perl_program(self,filename,path_list=[],var=None,environ=None,exts=''):
+       try:
+               app=self.find_program(filename,path_list=path_list,var=var,environ=environ,exts=exts)
+       except Exception:
+               self.find_program('perl',var='PERL')
+               app=self.find_file(filename,os.environ['PATH'].split(os.pathsep))
+               if not app:
+                       raise
+               if var:
+                       self.env[var]=Utils.to_list(self.env['PERL'])+[app]
+       self.msg('Checking for %r'%filename,app)
diff --git a/waflib/Configure.pyc b/waflib/Configure.pyc
new file mode 100644 (file)
index 0000000..b564532
Binary files /dev/null and b/waflib/Configure.pyc differ
diff --git a/waflib/Context.py b/waflib/Context.py
new file mode 100644 (file)
index 0000000..c789c48
--- /dev/null
@@ -0,0 +1,319 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,imp,sys
+from waflib import Utils,Errors,Logs
+import waflib.Node
+HEXVERSION=0x1070d00
+WAFVERSION="1.7.13"
+WAFREVISION="daa91dba4b881d86bc25eec90a3745ebaeece835"
+ABI=98
+DBFILE='.wafpickle-%s-%d-%d'%(sys.platform,sys.hexversion,ABI)
+APPNAME='APPNAME'
+VERSION='VERSION'
+TOP='top'
+OUT='out'
+WSCRIPT_FILE='wscript'
+launch_dir=''
+run_dir=''
+top_dir=''
+out_dir=''
+waf_dir=''
+local_repo=''
+remote_repo='http://waf.googlecode.com/git/'
+remote_locs=['waflib/extras','waflib/Tools']
+g_module=None
+STDOUT=1
+STDERR=-1
+BOTH=0
+classes=[]
+def create_context(cmd_name,*k,**kw):
+       global classes
+       for x in classes:
+               if x.cmd==cmd_name:
+                       return x(*k,**kw)
+       ctx=Context(*k,**kw)
+       ctx.fun=cmd_name
+       return ctx
+class store_context(type):
+       def __init__(cls,name,bases,dict):
+               super(store_context,cls).__init__(name,bases,dict)
+               name=cls.__name__
+               if name=='ctx'or name=='Context':
+                       return
+               try:
+                       cls.cmd
+               except AttributeError:
+                       raise Errors.WafError('Missing command for the context class %r (cmd)'%name)
+               if not getattr(cls,'fun',None):
+                       cls.fun=cls.cmd
+               global classes
+               classes.insert(0,cls)
+ctx=store_context('ctx',(object,),{})
+class Context(ctx):
+       errors=Errors
+       tools={}
+       def __init__(self,**kw):
+               try:
+                       rd=kw['run_dir']
+               except KeyError:
+                       global run_dir
+                       rd=run_dir
+               class node_class(waflib.Node.Node):
+                       pass
+               self.node_class=node_class
+               self.node_class.__module__="waflib.Node"
+               self.node_class.__name__="Nod3"
+               self.node_class.ctx=self
+               self.root=self.node_class('',None)
+               self.cur_script=None
+               self.path=self.root.find_dir(rd)
+               self.stack_path=[]
+               self.exec_dict={'ctx':self,'conf':self,'bld':self,'opt':self}
+               self.logger=None
+       def __hash__(self):
+               return id(self)
+       def load(self,tool_list,*k,**kw):
+               tools=Utils.to_list(tool_list)
+               path=Utils.to_list(kw.get('tooldir',''))
+               for t in tools:
+                       module=load_tool(t,path)
+                       fun=getattr(module,kw.get('name',self.fun),None)
+                       if fun:
+                               fun(self)
+       def execute(self):
+               global g_module
+               self.recurse([os.path.dirname(g_module.root_path)])
+       def pre_recurse(self,node):
+               self.stack_path.append(self.cur_script)
+               self.cur_script=node
+               self.path=node.parent
+       def post_recurse(self,node):
+               self.cur_script=self.stack_path.pop()
+               if self.cur_script:
+                       self.path=self.cur_script.parent
+       def recurse(self,dirs,name=None,mandatory=True,once=True):
+               try:
+                       cache=self.recurse_cache
+               except AttributeError:
+                       cache=self.recurse_cache={}
+               for d in Utils.to_list(dirs):
+                       if not os.path.isabs(d):
+                               d=os.path.join(self.path.abspath(),d)
+                       WSCRIPT=os.path.join(d,WSCRIPT_FILE)
+                       WSCRIPT_FUN=WSCRIPT+'_'+(name or self.fun)
+                       node=self.root.find_node(WSCRIPT_FUN)
+                       if node and(not once or node not in cache):
+                               cache[node]=True
+                               self.pre_recurse(node)
+                               try:
+                                       function_code=node.read('rU')
+                                       exec(compile(function_code,node.abspath(),'exec'),self.exec_dict)
+                               finally:
+                                       self.post_recurse(node)
+                       elif not node:
+                               node=self.root.find_node(WSCRIPT)
+                               tup=(node,name or self.fun)
+                               if node and(not once or tup not in cache):
+                                       cache[tup]=True
+                                       self.pre_recurse(node)
+                                       try:
+                                               wscript_module=load_module(node.abspath())
+                                               user_function=getattr(wscript_module,(name or self.fun),None)
+                                               if not user_function:
+                                                       if not mandatory:
+                                                               continue
+                                                       raise Errors.WafError('No function %s defined in %s'%(name or self.fun,node.abspath()))
+                                               user_function(self)
+                                       finally:
+                                               self.post_recurse(node)
+                               elif not node:
+                                       if not mandatory:
+                                               continue
+                                       raise Errors.WafError('No wscript file in directory %s'%d)
+       def exec_command(self,cmd,**kw):
+               subprocess=Utils.subprocess
+               kw['shell']=isinstance(cmd,str)
+               Logs.debug('runner: %r'%cmd)
+               Logs.debug('runner_env: kw=%s'%kw)
+               if self.logger:
+                       self.logger.info(cmd)
+               if'stdout'not in kw:
+                       kw['stdout']=subprocess.PIPE
+               if'stderr'not in kw:
+                       kw['stderr']=subprocess.PIPE
+               try:
+                       if kw['stdout']or kw['stderr']:
+                               p=subprocess.Popen(cmd,**kw)
+                               (out,err)=p.communicate()
+                               ret=p.returncode
+                       else:
+                               out,err=(None,None)
+                               ret=subprocess.Popen(cmd,**kw).wait()
+               except Exception ,e:
+                       raise Errors.WafError('Execution failure: %s'%str(e),ex=e)
+               if out:
+                       if not isinstance(out,str):
+                               out=out.decode(sys.stdout.encoding or'iso8859-1')
+                       if self.logger:
+                               self.logger.debug('out: %s'%out)
+                       else:
+                               sys.stdout.write(out)
+               if err:
+                       if not isinstance(err,str):
+                               err=err.decode(sys.stdout.encoding or'iso8859-1')
+                       if self.logger:
+                               self.logger.error('err: %s'%err)
+                       else:
+                               sys.stderr.write(err)
+               return ret
+       def cmd_and_log(self,cmd,**kw):
+               subprocess=Utils.subprocess
+               kw['shell']=isinstance(cmd,str)
+               Logs.debug('runner: %r'%cmd)
+               if'quiet'in kw:
+                       quiet=kw['quiet']
+                       del kw['quiet']
+               else:
+                       quiet=None
+               if'output'in kw:
+                       to_ret=kw['output']
+                       del kw['output']
+               else:
+                       to_ret=STDOUT
+               kw['stdout']=kw['stderr']=subprocess.PIPE
+               if quiet is None:
+                       self.to_log(cmd)
+               try:
+                       p=subprocess.Popen(cmd,**kw)
+                       (out,err)=p.communicate()
+               except Exception ,e:
+                       raise Errors.WafError('Execution failure: %s'%str(e),ex=e)
+               if not isinstance(out,str):
+                       out=out.decode(sys.stdout.encoding or'iso8859-1')
+               if not isinstance(err,str):
+                       err=err.decode(sys.stdout.encoding or'iso8859-1')
+               if out and quiet!=STDOUT and quiet!=BOTH:
+                       self.to_log('out: %s'%out)
+               if err and quiet!=STDERR and quiet!=BOTH:
+                       self.to_log('err: %s'%err)
+               if p.returncode:
+                       e=Errors.WafError('Command %r returned %r'%(cmd,p.returncode))
+                       e.returncode=p.returncode
+                       e.stderr=err
+                       e.stdout=out
+                       raise e
+               if to_ret==BOTH:
+                       return(out,err)
+               elif to_ret==STDERR:
+                       return err
+               return out
+       def fatal(self,msg,ex=None):
+               if self.logger:
+                       self.logger.info('from %s: %s'%(self.path.abspath(),msg))
+               try:
+                       msg='%s\n(complete log in %s)'%(msg,self.logger.handlers[0].baseFilename)
+               except Exception:
+                       pass
+               raise self.errors.ConfigurationError(msg,ex=ex)
+       def to_log(self,msg):
+               if not msg:
+                       return
+               if self.logger:
+                       self.logger.info(msg)
+               else:
+                       sys.stderr.write(str(msg))
+                       sys.stderr.flush()
+       def msg(self,msg,result,color=None):
+               self.start_msg(msg)
+               if not isinstance(color,str):
+                       color=result and'GREEN'or'YELLOW'
+               self.end_msg(result,color)
+       def start_msg(self,msg):
+               try:
+                       if self.in_msg:
+                               self.in_msg+=1
+                               return
+               except AttributeError:
+                       self.in_msg=0
+               self.in_msg+=1
+               try:
+                       self.line_just=max(self.line_just,len(msg))
+               except AttributeError:
+                       self.line_just=max(40,len(msg))
+               for x in(self.line_just*'-',msg):
+                       self.to_log(x)
+               Logs.pprint('NORMAL',"%s :"%msg.ljust(self.line_just),sep='')
+       def end_msg(self,result,color=None):
+               self.in_msg-=1
+               if self.in_msg:
+                       return
+               defcolor='GREEN'
+               if result==True:
+                       msg='ok'
+               elif result==False:
+                       msg='not found'
+                       defcolor='YELLOW'
+               else:
+                       msg=str(result)
+               self.to_log(msg)
+               Logs.pprint(color or defcolor,msg)
+       def load_special_tools(self,var,ban=[]):
+               global waf_dir
+               lst=self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var)
+               for x in lst:
+                       if not x.name in ban:
+                               load_tool(x.name.replace('.py',''))
+cache_modules={}
+def load_module(path):
+       try:
+               return cache_modules[path]
+       except KeyError:
+               pass
+       module=imp.new_module(WSCRIPT_FILE)
+       try:
+               code=Utils.readf(path,m='rU')
+       except(IOError,OSError):
+               raise Errors.WafError('Could not read the file %r'%path)
+       module_dir=os.path.dirname(path)
+       sys.path.insert(0,module_dir)
+       exec(compile(code,path,'exec'),module.__dict__)
+       sys.path.remove(module_dir)
+       cache_modules[path]=module
+       return module
+def load_tool(tool,tooldir=None):
+       if tool=='java':
+               tool='javaw'
+       elif tool=='compiler_cc':
+               tool='compiler_c'
+       else:
+               tool=tool.replace('++','xx')
+       if tooldir:
+               assert isinstance(tooldir,list)
+               sys.path=tooldir+sys.path
+               try:
+                       __import__(tool)
+                       ret=sys.modules[tool]
+                       Context.tools[tool]=ret
+                       return ret
+               finally:
+                       for d in tooldir:
+                               sys.path.remove(d)
+       else:
+               global waf_dir
+               try:
+                       os.stat(os.path.join(waf_dir,'waflib','extras',tool+'.py'))
+               except OSError:
+                       try:
+                               os.stat(os.path.join(waf_dir,'waflib','Tools',tool+'.py'))
+                       except OSError:
+                               d=tool
+                       else:
+                               d='waflib.Tools.%s'%tool
+               else:
+                       d='waflib.extras.%s'%tool
+               __import__(d)
+               ret=sys.modules[d]
+               Context.tools[tool]=ret
+               return ret
diff --git a/waflib/Context.pyc b/waflib/Context.pyc
new file mode 100644 (file)
index 0000000..afbd56a
Binary files /dev/null and b/waflib/Context.pyc differ
diff --git a/waflib/Errors.py b/waflib/Errors.py
new file mode 100644 (file)
index 0000000..aacc1a9
--- /dev/null
@@ -0,0 +1,37 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import traceback,sys
+class WafError(Exception):
+       def __init__(self,msg='',ex=None):
+               self.msg=msg
+               assert not isinstance(msg,Exception)
+               self.stack=[]
+               if ex:
+                       if not msg:
+                               self.msg=str(ex)
+                       if isinstance(ex,WafError):
+                               self.stack=ex.stack
+                       else:
+                               self.stack=traceback.extract_tb(sys.exc_info()[2])
+               self.stack+=traceback.extract_stack()[:-1]
+               self.verbose_msg=''.join(traceback.format_list(self.stack))
+       def __str__(self):
+               return str(self.msg)
+class BuildError(WafError):
+       def __init__(self,error_tasks=[]):
+               self.tasks=error_tasks
+               WafError.__init__(self,self.format_error())
+       def format_error(self):
+               lst=['Build failed']
+               for tsk in self.tasks:
+                       txt=tsk.format_error()
+                       if txt:lst.append(txt)
+               return'\n'.join(lst)
+class ConfigurationError(WafError):
+       pass
+class TaskRescan(WafError):
+       pass
+class TaskNotReady(WafError):
+       pass
diff --git a/waflib/Errors.pyc b/waflib/Errors.pyc
new file mode 100644 (file)
index 0000000..68099d5
Binary files /dev/null and b/waflib/Errors.pyc differ
diff --git a/waflib/Logs.py b/waflib/Logs.py
new file mode 100644 (file)
index 0000000..ef62452
--- /dev/null
@@ -0,0 +1,177 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,re,traceback,sys
+_nocolor=os.environ.get('NOCOLOR','no')not in('no','0','false')
+try:
+       if not _nocolor:
+               import waflib.ansiterm
+except ImportError:
+       pass
+try:
+       import threading
+except ImportError:
+       if not'JOBS'in os.environ:
+               os.environ['JOBS']='1'
+else:
+       wlock=threading.Lock()
+       class sync_stream(object):
+               def __init__(self,stream):
+                       self.stream=stream
+                       self.encoding=self.stream.encoding
+               def write(self,txt):
+                       try:
+                               wlock.acquire()
+                               self.stream.write(txt)
+                               self.stream.flush()
+                       finally:
+                               wlock.release()
+               def fileno(self):
+                       return self.stream.fileno()
+               def flush(self):
+                       self.stream.flush()
+               def isatty(self):
+                       return self.stream.isatty()
+       if not os.environ.get('NOSYNC',False):
+               if id(sys.stdout)==id(sys.__stdout__):
+                       sys.stdout=sync_stream(sys.stdout)
+                       sys.stderr=sync_stream(sys.stderr)
+import logging
+LOG_FORMAT="%(asctime)s %(c1)s%(zone)s%(c2)s %(message)s"
+HOUR_FORMAT="%H:%M:%S"
+zones=''
+verbose=0
+colors_lst={'USE':True,'BOLD':'\x1b[01;1m','RED':'\x1b[01;31m','GREEN':'\x1b[32m','YELLOW':'\x1b[33m','PINK':'\x1b[35m','BLUE':'\x1b[01;34m','CYAN':'\x1b[36m','NORMAL':'\x1b[0m','cursor_on':'\x1b[?25h','cursor_off':'\x1b[?25l',}
+got_tty=not os.environ.get('TERM','dumb')in['dumb','emacs']
+if got_tty:
+       try:
+               got_tty=sys.stderr.isatty()and sys.stdout.isatty()
+       except AttributeError:
+               got_tty=False
+if(not got_tty and os.environ.get('TERM','dumb')!='msys')or _nocolor:
+       colors_lst['USE']=False
+def get_term_cols():
+       return 80
+try:
+       import struct,fcntl,termios
+except ImportError:
+       pass
+else:
+       if got_tty:
+               def get_term_cols_real():
+                       dummy_lines,cols=struct.unpack("HHHH",fcntl.ioctl(sys.stderr.fileno(),termios.TIOCGWINSZ,struct.pack("HHHH",0,0,0,0)))[:2]
+                       return cols
+               try:
+                       get_term_cols_real()
+               except Exception:
+                       pass
+               else:
+                       get_term_cols=get_term_cols_real
+get_term_cols.__doc__="""
+       Get the console width in characters.
+
+       :return: the number of characters per line
+       :rtype: int
+       """
+def get_color(cl):
+       if not colors_lst['USE']:return''
+       return colors_lst.get(cl,'')
+class color_dict(object):
+       def __getattr__(self,a):
+               return get_color(a)
+       def __call__(self,a):
+               return get_color(a)
+colors=color_dict()
+re_log=re.compile(r'(\w+): (.*)',re.M)
+class log_filter(logging.Filter):
+       def __init__(self,name=None):
+               pass
+       def filter(self,rec):
+               rec.c1=colors.PINK
+               rec.c2=colors.NORMAL
+               rec.zone=rec.module
+               if rec.levelno>=logging.INFO:
+                       if rec.levelno>=logging.ERROR:
+                               rec.c1=colors.RED
+                       elif rec.levelno>=logging.WARNING:
+                               rec.c1=colors.YELLOW
+                       else:
+                               rec.c1=colors.GREEN
+                       return True
+               m=re_log.match(rec.msg)
+               if m:
+                       rec.zone=m.group(1)
+                       rec.msg=m.group(2)
+               if zones:
+                       return getattr(rec,'zone','')in zones or'*'in zones
+               elif not verbose>2:
+                       return False
+               return True
+class formatter(logging.Formatter):
+       def __init__(self):
+               logging.Formatter.__init__(self,LOG_FORMAT,HOUR_FORMAT)
+       def format(self,rec):
+               if rec.levelno>=logging.WARNING or rec.levelno==logging.INFO:
+                       try:
+                               msg=rec.msg.decode('utf-8')
+                       except Exception:
+                               msg=rec.msg
+                       return'%s%s%s'%(rec.c1,msg,rec.c2)
+               return logging.Formatter.format(self,rec)
+log=None
+def debug(*k,**kw):
+       if verbose:
+               k=list(k)
+               k[0]=k[0].replace('\n',' ')
+               global log
+               log.debug(*k,**kw)
+def error(*k,**kw):
+       global log
+       log.error(*k,**kw)
+       if verbose>2:
+               st=traceback.extract_stack()
+               if st:
+                       st=st[:-1]
+                       buf=[]
+                       for filename,lineno,name,line in st:
+                               buf.append('  File "%s", line %d, in %s'%(filename,lineno,name))
+                               if line:
+                                       buf.append('    %s'%line.strip())
+                       if buf:log.error("\n".join(buf))
+def warn(*k,**kw):
+       global log
+       log.warn(*k,**kw)
+def info(*k,**kw):
+       global log
+       log.info(*k,**kw)
+def init_log():
+       global log
+       log=logging.getLogger('waflib')
+       log.handlers=[]
+       log.filters=[]
+       hdlr=logging.StreamHandler()
+       hdlr.setFormatter(formatter())
+       log.addHandler(hdlr)
+       log.addFilter(log_filter())
+       log.setLevel(logging.DEBUG)
+def make_logger(path,name):
+       logger=logging.getLogger(name)
+       hdlr=logging.FileHandler(path,'w')
+       formatter=logging.Formatter('%(message)s')
+       hdlr.setFormatter(formatter)
+       logger.addHandler(hdlr)
+       logger.setLevel(logging.DEBUG)
+       return logger
+def make_mem_logger(name,to_log,size=10000):
+       from logging.handlers import MemoryHandler
+       logger=logging.getLogger(name)
+       hdlr=MemoryHandler(size,target=to_log)
+       formatter=logging.Formatter('%(message)s')
+       hdlr.setFormatter(formatter)
+       logger.addHandler(hdlr)
+       logger.memhandler=hdlr
+       logger.setLevel(logging.DEBUG)
+       return logger
+def pprint(col,str,label='',sep='\n'):
+       sys.stderr.write("%s%s%s %s%s"%(colors(col),str,colors.NORMAL,label,sep))
diff --git a/waflib/Logs.pyc b/waflib/Logs.pyc
new file mode 100644 (file)
index 0000000..141b619
Binary files /dev/null and b/waflib/Logs.pyc differ
diff --git a/waflib/Node.py b/waflib/Node.py
new file mode 100644 (file)
index 0000000..7729613
--- /dev/null
@@ -0,0 +1,467 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,re,sys,shutil
+from waflib import Utils,Errors
+exclude_regs='''
+**/*~
+**/#*#
+**/.#*
+**/%*%
+**/._*
+**/CVS
+**/CVS/**
+**/.cvsignore
+**/SCCS
+**/SCCS/**
+**/vssver.scc
+**/.svn
+**/.svn/**
+**/BitKeeper
+**/.git
+**/.git/**
+**/.gitignore
+**/.bzr
+**/.bzrignore
+**/.bzr/**
+**/.hg
+**/.hg/**
+**/_MTN
+**/_MTN/**
+**/.arch-ids
+**/{arch}
+**/_darcs
+**/_darcs/**
+**/.intlcache
+**/.DS_Store'''
+def split_path(path):
+       return path.split('/')
+def split_path_cygwin(path):
+       if path.startswith('//'):
+               ret=path.split('/')[2:]
+               ret[0]='/'+ret[0]
+               return ret
+       return path.split('/')
+re_sp=re.compile('[/\\\\]')
+def split_path_win32(path):
+       if path.startswith('\\\\'):
+               ret=re.split(re_sp,path)[2:]
+               ret[0]='\\'+ret[0]
+               return ret
+       return re.split(re_sp,path)
+if sys.platform=='cygwin':
+       split_path=split_path_cygwin
+elif Utils.is_win32:
+       split_path=split_path_win32
+class Node(object):
+       __slots__=('name','sig','children','parent','cache_abspath','cache_isdir','cache_sig')
+       def __init__(self,name,parent):
+               self.name=name
+               self.parent=parent
+               if parent:
+                       if name in parent.children:
+                               raise Errors.WafError('node %s exists in the parent files %r already'%(name,parent))
+                       parent.children[name]=self
+       def __setstate__(self,data):
+               self.name=data[0]
+               self.parent=data[1]
+               if data[2]is not None:
+                       self.children=data[2]
+               if data[3]is not None:
+                       self.sig=data[3]
+       def __getstate__(self):
+               return(self.name,self.parent,getattr(self,'children',None),getattr(self,'sig',None))
+       def __str__(self):
+               return self.name
+       def __repr__(self):
+               return self.abspath()
+       def __hash__(self):
+               return id(self)
+       def __eq__(self,node):
+               return id(self)==id(node)
+       def __copy__(self):
+               raise Errors.WafError('nodes are not supposed to be copied')
+       def read(self,flags='r',encoding='ISO8859-1'):
+               return Utils.readf(self.abspath(),flags,encoding)
+       def write(self,data,flags='w',encoding='ISO8859-1'):
+               Utils.writef(self.abspath(),data,flags,encoding)
+       def chmod(self,val):
+               os.chmod(self.abspath(),val)
+       def delete(self):
+               try:
+                       if hasattr(self,'children'):
+                               shutil.rmtree(self.abspath())
+                       else:
+                               os.remove(self.abspath())
+               except OSError:
+                       pass
+               self.evict()
+       def evict(self):
+               del self.parent.children[self.name]
+       def suffix(self):
+               k=max(0,self.name.rfind('.'))
+               return self.name[k:]
+       def height(self):
+               d=self
+               val=-1
+               while d:
+                       d=d.parent
+                       val+=1
+               return val
+       def listdir(self):
+               lst=Utils.listdir(self.abspath())
+               lst.sort()
+               return lst
+       def mkdir(self):
+               if getattr(self,'cache_isdir',None):
+                       return
+               try:
+                       self.parent.mkdir()
+               except OSError:
+                       pass
+               if self.name:
+                       try:
+                               os.makedirs(self.abspath())
+                       except OSError:
+                               pass
+                       if not os.path.isdir(self.abspath()):
+                               raise Errors.WafError('Could not create the directory %s'%self.abspath())
+                       try:
+                               self.children
+                       except AttributeError:
+                               self.children={}
+               self.cache_isdir=True
+       def find_node(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               cur=self
+               for x in lst:
+                       if x=='..':
+                               cur=cur.parent or cur
+                               continue
+                       try:
+                               ch=cur.children
+                       except AttributeError:
+                               cur.children={}
+                       else:
+                               try:
+                                       cur=cur.children[x]
+                                       continue
+                               except KeyError:
+                                       pass
+                       cur=self.__class__(x,cur)
+                       try:
+                               os.stat(cur.abspath())
+                       except OSError:
+                               cur.evict()
+                               return None
+               ret=cur
+               try:
+                       os.stat(ret.abspath())
+               except OSError:
+                       ret.evict()
+                       return None
+               try:
+                       while not getattr(cur.parent,'cache_isdir',None):
+                               cur=cur.parent
+                               cur.cache_isdir=True
+               except AttributeError:
+                       pass
+               return ret
+       def make_node(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               cur=self
+               for x in lst:
+                       if x=='..':
+                               cur=cur.parent or cur
+                               continue
+                       if getattr(cur,'children',{}):
+                               if x in cur.children:
+                                       cur=cur.children[x]
+                                       continue
+                       else:
+                               cur.children={}
+                       cur=self.__class__(x,cur)
+               return cur
+       def search_node(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               cur=self
+               for x in lst:
+                       if x=='..':
+                               cur=cur.parent or cur
+                       else:
+                               try:
+                                       cur=cur.children[x]
+                               except(AttributeError,KeyError):
+                                       return None
+               return cur
+       def path_from(self,node):
+               c1=self
+               c2=node
+               c1h=c1.height()
+               c2h=c2.height()
+               lst=[]
+               up=0
+               while c1h>c2h:
+                       lst.append(c1.name)
+                       c1=c1.parent
+                       c1h-=1
+               while c2h>c1h:
+                       up+=1
+                       c2=c2.parent
+                       c2h-=1
+               while id(c1)!=id(c2):
+                       lst.append(c1.name)
+                       up+=1
+                       c1=c1.parent
+                       c2=c2.parent
+               for i in range(up):
+                       lst.append('..')
+               lst.reverse()
+               return os.sep.join(lst)or'.'
+       def abspath(self):
+               try:
+                       return self.cache_abspath
+               except AttributeError:
+                       pass
+               if os.sep=='/':
+                       if not self.parent:
+                               val=os.sep
+                       elif not self.parent.name:
+                               val=os.sep+self.name
+                       else:
+                               val=self.parent.abspath()+os.sep+self.name
+               else:
+                       if not self.parent:
+                               val=''
+                       elif not self.parent.name:
+                               val=self.name+os.sep
+                       else:
+                               val=self.parent.abspath().rstrip(os.sep)+os.sep+self.name
+               self.cache_abspath=val
+               return val
+       def is_child_of(self,node):
+               p=self
+               diff=self.height()-node.height()
+               while diff>0:
+                       diff-=1
+                       p=p.parent
+               return id(p)==id(node)
+       def ant_iter(self,accept=None,maxdepth=25,pats=[],dir=False,src=True,remove=True):
+               dircont=self.listdir()
+               dircont.sort()
+               try:
+                       lst=set(self.children.keys())
+               except AttributeError:
+                       self.children={}
+               else:
+                       if remove:
+                               for x in lst-set(dircont):
+                                       self.children[x].evict()
+               for name in dircont:
+                       npats=accept(name,pats)
+                       if npats and npats[0]:
+                               accepted=[]in npats[0]
+                               node=self.make_node([name])
+                               isdir=os.path.isdir(node.abspath())
+                               if accepted:
+                                       if isdir:
+                                               if dir:
+                                                       yield node
+                                       else:
+                                               if src:
+                                                       yield node
+                               if getattr(node,'cache_isdir',None)or isdir:
+                                       node.cache_isdir=True
+                                       if maxdepth:
+                                               for k in node.ant_iter(accept=accept,maxdepth=maxdepth-1,pats=npats,dir=dir,src=src,remove=remove):
+                                                       yield k
+               raise StopIteration
+       def ant_glob(self,*k,**kw):
+               src=kw.get('src',True)
+               dir=kw.get('dir',False)
+               excl=kw.get('excl',exclude_regs)
+               incl=k and k[0]or kw.get('incl','**')
+               reflags=kw.get('ignorecase',0)and re.I
+               def to_pat(s):
+                       lst=Utils.to_list(s)
+                       ret=[]
+                       for x in lst:
+                               x=x.replace('\\','/').replace('//','/')
+                               if x.endswith('/'):
+                                       x+='**'
+                               lst2=x.split('/')
+                               accu=[]
+                               for k in lst2:
+                                       if k=='**':
+                                               accu.append(k)
+                                       else:
+                                               k=k.replace('.','[.]').replace('*','.*').replace('?','.').replace('+','\\+')
+                                               k='^%s$'%k
+                                               try:
+                                                       accu.append(re.compile(k,flags=reflags))
+                                               except Exception ,e:
+                                                       raise Errors.WafError("Invalid pattern: %s"%k,e)
+                               ret.append(accu)
+                       return ret
+               def filtre(name,nn):
+                       ret=[]
+                       for lst in nn:
+                               if not lst:
+                                       pass
+                               elif lst[0]=='**':
+                                       ret.append(lst)
+                                       if len(lst)>1:
+                                               if lst[1].match(name):
+                                                       ret.append(lst[2:])
+                                       else:
+                                               ret.append([])
+                               elif lst[0].match(name):
+                                       ret.append(lst[1:])
+                       return ret
+               def accept(name,pats):
+                       nacc=filtre(name,pats[0])
+                       nrej=filtre(name,pats[1])
+                       if[]in nrej:
+                               nacc=[]
+                       return[nacc,nrej]
+               ret=[x for x in self.ant_iter(accept=accept,pats=[to_pat(incl),to_pat(excl)],maxdepth=kw.get('maxdepth',25),dir=dir,src=src,remove=kw.get('remove',True))]
+               if kw.get('flat',False):
+                       return' '.join([x.path_from(self)for x in ret])
+               return ret
+       def is_src(self):
+               cur=self
+               x=id(self.ctx.srcnode)
+               y=id(self.ctx.bldnode)
+               while cur.parent:
+                       if id(cur)==y:
+                               return False
+                       if id(cur)==x:
+                               return True
+                       cur=cur.parent
+               return False
+       def is_bld(self):
+               cur=self
+               y=id(self.ctx.bldnode)
+               while cur.parent:
+                       if id(cur)==y:
+                               return True
+                       cur=cur.parent
+               return False
+       def get_src(self):
+               cur=self
+               x=id(self.ctx.srcnode)
+               y=id(self.ctx.bldnode)
+               lst=[]
+               while cur.parent:
+                       if id(cur)==y:
+                               lst.reverse()
+                               return self.ctx.srcnode.make_node(lst)
+                       if id(cur)==x:
+                               return self
+                       lst.append(cur.name)
+                       cur=cur.parent
+               return self
+       def get_bld(self):
+               cur=self
+               x=id(self.ctx.srcnode)
+               y=id(self.ctx.bldnode)
+               lst=[]
+               while cur.parent:
+                       if id(cur)==y:
+                               return self
+                       if id(cur)==x:
+                               lst.reverse()
+                               return self.ctx.bldnode.make_node(lst)
+                       lst.append(cur.name)
+                       cur=cur.parent
+               lst.reverse()
+               if lst and Utils.is_win32 and len(lst[0])==2 and lst[0].endswith(':'):
+                       lst[0]=lst[0][0]
+               return self.ctx.bldnode.make_node(['__root__']+lst)
+       def find_resource(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               node=self.get_bld().search_node(lst)
+               if not node:
+                       self=self.get_src()
+                       node=self.find_node(lst)
+               if node:
+                       if os.path.isdir(node.abspath()):
+                               return None
+               return node
+       def find_or_declare(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               node=self.get_bld().search_node(lst)
+               if node:
+                       if not os.path.isfile(node.abspath()):
+                               node.sig=None
+                               node.parent.mkdir()
+                       return node
+               self=self.get_src()
+               node=self.find_node(lst)
+               if node:
+                       if not os.path.isfile(node.abspath()):
+                               node.sig=None
+                               node.parent.mkdir()
+                       return node
+               node=self.get_bld().make_node(lst)
+               node.parent.mkdir()
+               return node
+       def find_dir(self,lst):
+               if isinstance(lst,str):
+                       lst=[x for x in split_path(lst)if x and x!='.']
+               node=self.find_node(lst)
+               try:
+                       if not os.path.isdir(node.abspath()):
+                               return None
+               except(OSError,AttributeError):
+                       return None
+               return node
+       def change_ext(self,ext,ext_in=None):
+               name=self.name
+               if ext_in is None:
+                       k=name.rfind('.')
+                       if k>=0:
+                               name=name[:k]+ext
+                       else:
+                               name=name+ext
+               else:
+                       name=name[:-len(ext_in)]+ext
+               return self.parent.find_or_declare([name])
+       def nice_path(self,env=None):
+               return self.path_from(self.ctx.launch_node())
+       def bldpath(self):
+               return self.path_from(self.ctx.bldnode)
+       def srcpath(self):
+               return self.path_from(self.ctx.srcnode)
+       def relpath(self):
+               cur=self
+               x=id(self.ctx.bldnode)
+               while cur.parent:
+                       if id(cur)==x:
+                               return self.bldpath()
+                       cur=cur.parent
+               return self.srcpath()
+       def bld_dir(self):
+               return self.parent.bldpath()
+       def bld_base(self):
+               s=os.path.splitext(self.name)[0]
+               return self.bld_dir()+os.sep+s
+       def get_bld_sig(self):
+               try:
+                       return self.cache_sig
+               except AttributeError:
+                       pass
+               if not self.is_bld()or self.ctx.bldnode is self.ctx.srcnode:
+                       self.sig=Utils.h_file(self.abspath())
+               self.cache_sig=ret=self.sig
+               return ret
+       search=search_node
+pickle_lock=Utils.threading.Lock()
+class Nod3(Node):
+       pass
diff --git a/waflib/Node.pyc b/waflib/Node.pyc
new file mode 100644 (file)
index 0000000..8a2fadc
Binary files /dev/null and b/waflib/Node.pyc differ
diff --git a/waflib/Options.py b/waflib/Options.py
new file mode 100644 (file)
index 0000000..21f4254
--- /dev/null
@@ -0,0 +1,135 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,tempfile,optparse,sys,re
+from waflib import Logs,Utils,Context
+cmds='distclean configure build install clean uninstall check dist distcheck'.split()
+options={}
+commands=[]
+lockfile=os.environ.get('WAFLOCK','.lock-waf_%s_build'%sys.platform)
+try:cache_global=os.path.abspath(os.environ['WAFCACHE'])
+except KeyError:cache_global=''
+platform=Utils.unversioned_sys_platform()
+class opt_parser(optparse.OptionParser):
+       def __init__(self,ctx):
+               optparse.OptionParser.__init__(self,conflict_handler="resolve",version='waf %s (%s)'%(Context.WAFVERSION,Context.WAFREVISION))
+               self.formatter.width=Logs.get_term_cols()
+               p=self.add_option
+               self.ctx=ctx
+               jobs=ctx.jobs()
+               p('-j','--jobs',dest='jobs',default=jobs,type='int',help='amount of parallel jobs (%r)'%jobs)
+               p('-k','--keep',dest='keep',default=0,action='count',help='keep running happily even if errors are found')
+               p('-v','--verbose',dest='verbose',default=0,action='count',help='verbosity level -v -vv or -vvv [default: 0]')
+               p('--nocache',dest='nocache',default=False,action='store_true',help='ignore the WAFCACHE (if set)')
+               p('--zones',dest='zones',default='',action='store',help='debugging zones (task_gen, deps, tasks, etc)')
+               gr=optparse.OptionGroup(self,'configure options')
+               self.add_option_group(gr)
+               gr.add_option('-o','--out',action='store',default='',help='build dir for the project',dest='out')
+               gr.add_option('-t','--top',action='store',default='',help='src dir for the project',dest='top')
+               default_prefix=os.environ.get('PREFIX')
+               if not default_prefix:
+                       if platform=='win32':
+                               d=tempfile.gettempdir()
+                               default_prefix=d[0].upper()+d[1:]
+                       else:
+                               default_prefix='/usr/local/'
+               gr.add_option('--prefix',dest='prefix',default=default_prefix,help='installation prefix [default: %r]'%default_prefix)
+               gr.add_option('--download',dest='download',default=False,action='store_true',help='try to download the tools if missing')
+               gr=optparse.OptionGroup(self,'build and install options')
+               self.add_option_group(gr)
+               gr.add_option('-p','--progress',dest='progress_bar',default=0,action='count',help='-p: progress bar; -pp: ide output')
+               gr.add_option('--targets',dest='targets',default='',action='store',help='task generators, e.g. "target1,target2"')
+               gr=optparse.OptionGroup(self,'step options')
+               self.add_option_group(gr)
+               gr.add_option('--files',dest='files',default='',action='store',help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"')
+               default_destdir=os.environ.get('DESTDIR','')
+               gr=optparse.OptionGroup(self,'install/uninstall options')
+               self.add_option_group(gr)
+               gr.add_option('--destdir',help='installation root [default: %r]'%default_destdir,default=default_destdir,dest='destdir')
+               gr.add_option('-f','--force',dest='force',default=False,action='store_true',help='force file installation')
+               gr.add_option('--distcheck-args',help='arguments to pass to distcheck',default=None,action='store')
+       def get_usage(self):
+               cmds_str={}
+               for cls in Context.classes:
+                       if not cls.cmd or cls.cmd=='options':
+                               continue
+                       s=cls.__doc__ or''
+                       cmds_str[cls.cmd]=s
+               if Context.g_module:
+                       for(k,v)in Context.g_module.__dict__.items():
+                               if k in['options','init','shutdown']:
+                                       continue
+                               if type(v)is type(Context.create_context):
+                                       if v.__doc__ and not k.startswith('_'):
+                                               cmds_str[k]=v.__doc__
+               just=0
+               for k in cmds_str:
+                       just=max(just,len(k))
+               lst=['  %s: %s'%(k.ljust(just),v)for(k,v)in cmds_str.items()]
+               lst.sort()
+               ret='\n'.join(lst)
+               return'''waf [commands] [options]
+
+Main commands (example: ./waf build -j4)
+%s
+'''%ret
+class OptionsContext(Context.Context):
+       cmd='options'
+       fun='options'
+       def __init__(self,**kw):
+               super(OptionsContext,self).__init__(**kw)
+               self.parser=opt_parser(self)
+               self.option_groups={}
+       def jobs(self):
+               count=int(os.environ.get('JOBS',0))
+               if count<1:
+                       if'NUMBER_OF_PROCESSORS'in os.environ:
+                               count=int(os.environ.get('NUMBER_OF_PROCESSORS',1))
+                       else:
+                               if hasattr(os,'sysconf_names'):
+                                       if'SC_NPROCESSORS_ONLN'in os.sysconf_names:
+                                               count=int(os.sysconf('SC_NPROCESSORS_ONLN'))
+                                       elif'SC_NPROCESSORS_CONF'in os.sysconf_names:
+                                               count=int(os.sysconf('SC_NPROCESSORS_CONF'))
+                               if not count and os.name not in('nt','java'):
+                                       try:
+                                               tmp=self.cmd_and_log(['sysctl','-n','hw.ncpu'],quiet=0)
+                                       except Exception:
+                                               pass
+                                       else:
+                                               if re.match('^[0-9]+$',tmp):
+                                                       count=int(tmp)
+               if count<1:
+                       count=1
+               elif count>1024:
+                       count=1024
+               return count
+       def add_option(self,*k,**kw):
+               return self.parser.add_option(*k,**kw)
+       def add_option_group(self,*k,**kw):
+               try:
+                       gr=self.option_groups[k[0]]
+               except KeyError:
+                       gr=self.parser.add_option_group(*k,**kw)
+               self.option_groups[k[0]]=gr
+               return gr
+       def get_option_group(self,opt_str):
+               try:
+                       return self.option_groups[opt_str]
+               except KeyError:
+                       for group in self.parser.option_groups:
+                               if group.title==opt_str:
+                                       return group
+                       return None
+       def parse_args(self,_args=None):
+               global options,commands
+               (options,leftover_args)=self.parser.parse_args(args=_args)
+               commands=leftover_args
+               if options.destdir:
+                       options.destdir=os.path.abspath(os.path.expanduser(options.destdir))
+               if options.verbose>=1:
+                       self.load('errcheck')
+       def execute(self):
+               super(OptionsContext,self).execute()
+               self.parse_args()
diff --git a/waflib/Options.pyc b/waflib/Options.pyc
new file mode 100644 (file)
index 0000000..35466fc
Binary files /dev/null and b/waflib/Options.pyc differ
diff --git a/waflib/Runner.py b/waflib/Runner.py
new file mode 100644 (file)
index 0000000..15b6a27
--- /dev/null
@@ -0,0 +1,197 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import random,atexit
+try:
+       from queue import Queue
+except ImportError:
+       from Queue import Queue
+from waflib import Utils,Task,Errors,Logs
+GAP=10
+class TaskConsumer(Utils.threading.Thread):
+       def __init__(self):
+               Utils.threading.Thread.__init__(self)
+               self.ready=Queue()
+               self.setDaemon(1)
+               self.start()
+       def run(self):
+               try:
+                       self.loop()
+               except Exception:
+                       pass
+       def loop(self):
+               while 1:
+                       tsk=self.ready.get()
+                       if not isinstance(tsk,Task.TaskBase):
+                               tsk(self)
+                       else:
+                               tsk.process()
+pool=Queue()
+def get_pool():
+       try:
+               return pool.get(False)
+       except Exception:
+               return TaskConsumer()
+def put_pool(x):
+       pool.put(x)
+def _free_resources():
+       global pool
+       lst=[]
+       while pool.qsize():
+               lst.append(pool.get())
+       for x in lst:
+               x.ready.put(None)
+       for x in lst:
+               x.join()
+       pool=None
+atexit.register(_free_resources)
+class Parallel(object):
+       def __init__(self,bld,j=2):
+               self.numjobs=j
+               self.bld=bld
+               self.outstanding=[]
+               self.frozen=[]
+               self.out=Queue(0)
+               self.count=0
+               self.processed=1
+               self.stop=False
+               self.error=[]
+               self.biter=None
+               self.dirty=False
+       def get_next_task(self):
+               if not self.outstanding:
+                       return None
+               return self.outstanding.pop(0)
+       def postpone(self,tsk):
+               if random.randint(0,1):
+                       self.frozen.insert(0,tsk)
+               else:
+                       self.frozen.append(tsk)
+       def refill_task_list(self):
+               while self.count>self.numjobs*GAP:
+                       self.get_out()
+               while not self.outstanding:
+                       if self.count:
+                               self.get_out()
+                       elif self.frozen:
+                               try:
+                                       cond=self.deadlock==self.processed
+                               except AttributeError:
+                                       pass
+                               else:
+                                       if cond:
+                                               msg='check the build order for the tasks'
+                                               for tsk in self.frozen:
+                                                       if not tsk.run_after:
+                                                               msg='check the methods runnable_status'
+                                                               break
+                                               lst=[]
+                                               for tsk in self.frozen:
+                                                       lst.append('%s\t-> %r'%(repr(tsk),[id(x)for x in tsk.run_after]))
+                                               raise Errors.WafError('Deadlock detected: %s%s'%(msg,''.join(lst)))
+                               self.deadlock=self.processed
+                       if self.frozen:
+                               self.outstanding+=self.frozen
+                               self.frozen=[]
+                       elif not self.count:
+                               self.outstanding.extend(self.biter.next())
+                               self.total=self.bld.total()
+                               break
+       def add_more_tasks(self,tsk):
+               if getattr(tsk,'more_tasks',None):
+                       self.outstanding+=tsk.more_tasks
+                       self.total+=len(tsk.more_tasks)
+       def get_out(self):
+               tsk=self.out.get()
+               if not self.stop:
+                       self.add_more_tasks(tsk)
+               self.count-=1
+               self.dirty=True
+               return tsk
+       def error_handler(self,tsk):
+               if not self.bld.keep:
+                       self.stop=True
+               self.error.append(tsk)
+       def add_task(self,tsk):
+               try:
+                       self.pool
+               except AttributeError:
+                       self.init_task_pool()
+               self.ready.put(tsk)
+       def init_task_pool(self):
+               pool=self.pool=[get_pool()for i in range(self.numjobs)]
+               self.ready=Queue(0)
+               def setq(consumer):
+                       consumer.ready=self.ready
+               for x in pool:
+                       x.ready.put(setq)
+               return pool
+       def free_task_pool(self):
+               def setq(consumer):
+                       consumer.ready=Queue(0)
+                       self.out.put(self)
+               try:
+                       pool=self.pool
+               except AttributeError:
+                       pass
+               else:
+                       for x in pool:
+                               self.ready.put(setq)
+                       for x in pool:
+                               self.get_out()
+                       for x in pool:
+                               put_pool(x)
+                       self.pool=[]
+       def start(self):
+               self.total=self.bld.total()
+               while not self.stop:
+                       self.refill_task_list()
+                       tsk=self.get_next_task()
+                       if not tsk:
+                               if self.count:
+                                       continue
+                               else:
+                                       break
+                       if tsk.hasrun:
+                               self.processed+=1
+                               continue
+                       if self.stop:
+                               break
+                       try:
+                               st=tsk.runnable_status()
+                       except Exception:
+                               self.processed+=1
+                               tsk.err_msg=Utils.ex_stack()
+                               if not self.stop and self.bld.keep:
+                                       tsk.hasrun=Task.SKIPPED
+                                       if self.bld.keep==1:
+                                               if Logs.verbose>1 or not self.error:
+                                                       self.error.append(tsk)
+                                               self.stop=True
+                                       else:
+                                               if Logs.verbose>1:
+                                                       self.error.append(tsk)
+                                       continue
+                               tsk.hasrun=Task.EXCEPTION
+                               self.error_handler(tsk)
+                               continue
+                       if st==Task.ASK_LATER:
+                               self.postpone(tsk)
+                       elif st==Task.SKIP_ME:
+                               self.processed+=1
+                               tsk.hasrun=Task.SKIPPED
+                               self.add_more_tasks(tsk)
+                       else:
+                               tsk.position=(self.processed,self.total)
+                               self.count+=1
+                               tsk.master=self
+                               self.processed+=1
+                               if self.numjobs==1:
+                                       tsk.process()
+                               else:
+                                       self.add_task(tsk)
+               while self.error and self.count:
+                       self.get_out()
+               assert(self.count==0 or self.stop)
+               self.free_task_pool()
diff --git a/waflib/Runner.pyc b/waflib/Runner.pyc
new file mode 100644 (file)
index 0000000..90218c3
Binary files /dev/null and b/waflib/Runner.pyc differ
diff --git a/waflib/Scripting.py b/waflib/Scripting.py
new file mode 100644 (file)
index 0000000..fe5c30c
--- /dev/null
@@ -0,0 +1,373 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,shlex,shutil,traceback,errno,sys,stat
+from waflib import Utils,Configure,Logs,Options,ConfigSet,Context,Errors,Build,Node
+build_dir_override=None
+no_climb_commands=['configure']
+default_cmd="build"
+def waf_entry_point(current_directory,version,wafdir):
+       Logs.init_log()
+       if Context.WAFVERSION!=version:
+               Logs.error('Waf script %r and library %r do not match (directory %r)'%(version,Context.WAFVERSION,wafdir))
+               sys.exit(1)
+       if'--version'in sys.argv:
+               Context.run_dir=current_directory
+               ctx=Context.create_context('options')
+               ctx.curdir=current_directory
+               ctx.parse_args()
+               sys.exit(0)
+       Context.waf_dir=wafdir
+       Context.launch_dir=current_directory
+       no_climb=os.environ.get('NOCLIMB',None)
+       if not no_climb:
+               for k in no_climb_commands:
+                       if k in sys.argv:
+                               no_climb=True
+                               break
+       cur=current_directory
+       while cur:
+               lst=os.listdir(cur)
+               if Options.lockfile in lst:
+                       env=ConfigSet.ConfigSet()
+                       try:
+                               env.load(os.path.join(cur,Options.lockfile))
+                               ino=os.stat(cur)[stat.ST_INO]
+                       except Exception:
+                               pass
+                       else:
+                               for x in[env.run_dir,env.top_dir,env.out_dir]:
+                                       if Utils.is_win32:
+                                               if cur==x:
+                                                       load=True
+                                                       break
+                                       else:
+                                               try:
+                                                       ino2=os.stat(x)[stat.ST_INO]
+                                               except OSError:
+                                                       pass
+                                               else:
+                                                       if ino==ino2:
+                                                               load=True
+                                                               break
+                               else:
+                                       Logs.warn('invalid lock file in %s'%cur)
+                                       load=False
+                               if load:
+                                       Context.run_dir=env.run_dir
+                                       Context.top_dir=env.top_dir
+                                       Context.out_dir=env.out_dir
+                                       break
+               if not Context.run_dir:
+                       if Context.WSCRIPT_FILE in lst:
+                               Context.run_dir=cur
+               next=os.path.dirname(cur)
+               if next==cur:
+                       break
+               cur=next
+               if no_climb:
+                       break
+       if not Context.run_dir:
+               if'-h'in sys.argv or'--help'in sys.argv:
+                       Logs.warn('No wscript file found: the help message may be incomplete')
+                       Context.run_dir=current_directory
+                       ctx=Context.create_context('options')
+                       ctx.curdir=current_directory
+                       ctx.parse_args()
+                       sys.exit(0)
+               Logs.error('Waf: Run from a directory containing a file named %r'%Context.WSCRIPT_FILE)
+               sys.exit(1)
+       try:
+               os.chdir(Context.run_dir)
+       except OSError:
+               Logs.error('Waf: The folder %r is unreadable'%Context.run_dir)
+               sys.exit(1)
+       try:
+               set_main_module(Context.run_dir+os.sep+Context.WSCRIPT_FILE)
+       except Errors.WafError ,e:
+               Logs.pprint('RED',e.verbose_msg)
+               Logs.error(str(e))
+               sys.exit(1)
+       except Exception ,e:
+               Logs.error('Waf: The wscript in %r is unreadable'%Context.run_dir,e)
+               traceback.print_exc(file=sys.stdout)
+               sys.exit(2)
+       try:
+               run_commands()
+       except Errors.WafError ,e:
+               if Logs.verbose>1:
+                       Logs.pprint('RED',e.verbose_msg)
+               Logs.error(e.msg)
+               sys.exit(1)
+       except SystemExit:
+               raise
+       except Exception ,e:
+               traceback.print_exc(file=sys.stdout)
+               sys.exit(2)
+       except KeyboardInterrupt:
+               Logs.pprint('RED','Interrupted')
+               sys.exit(68)
+def set_main_module(file_path):
+       Context.g_module=Context.load_module(file_path)
+       Context.g_module.root_path=file_path
+       def set_def(obj):
+               name=obj.__name__
+               if not name in Context.g_module.__dict__:
+                       setattr(Context.g_module,name,obj)
+       for k in[update,dist,distclean,distcheck,update]:
+               set_def(k)
+       if not'init'in Context.g_module.__dict__:
+               Context.g_module.init=Utils.nada
+       if not'shutdown'in Context.g_module.__dict__:
+               Context.g_module.shutdown=Utils.nada
+       if not'options'in Context.g_module.__dict__:
+               Context.g_module.options=Utils.nada
+def parse_options():
+       Context.create_context('options').execute()
+       if not Options.commands:
+               Options.commands=[default_cmd]
+       Options.commands=[x for x in Options.commands if x!='options']
+       Logs.verbose=Options.options.verbose
+       Logs.init_log()
+       if Options.options.zones:
+               Logs.zones=Options.options.zones.split(',')
+               if not Logs.verbose:
+                       Logs.verbose=1
+       elif Logs.verbose>0:
+               Logs.zones=['runner']
+       if Logs.verbose>2:
+               Logs.zones=['*']
+def run_command(cmd_name):
+       ctx=Context.create_context(cmd_name)
+       ctx.log_timer=Utils.Timer()
+       ctx.options=Options.options
+       ctx.cmd=cmd_name
+       ctx.execute()
+       return ctx
+def run_commands():
+       parse_options()
+       run_command('init')
+       while Options.commands:
+               cmd_name=Options.commands.pop(0)
+               ctx=run_command(cmd_name)
+               Logs.info('%r finished successfully (%s)'%(cmd_name,str(ctx.log_timer)))
+       run_command('shutdown')
+def _can_distclean(name):
+       for k in'.o .moc .exe'.split():
+               if name.endswith(k):
+                       return True
+       return False
+def distclean_dir(dirname):
+       for(root,dirs,files)in os.walk(dirname):
+               for f in files:
+                       if _can_distclean(f):
+                               fname=root+os.sep+f
+                               try:
+                                       os.remove(fname)
+                               except OSError:
+                                       Logs.warn('Could not remove %r'%fname)
+       for x in[Context.DBFILE,'config.log']:
+               try:
+                       os.remove(x)
+               except OSError:
+                       pass
+       try:
+               shutil.rmtree('c4che')
+       except OSError:
+               pass
+def distclean(ctx):
+       '''removes the build directory'''
+       lst=os.listdir('.')
+       for f in lst:
+               if f==Options.lockfile:
+                       try:
+                               proj=ConfigSet.ConfigSet(f)
+                       except IOError:
+                               Logs.warn('Could not read %r'%f)
+                               continue
+                       if proj['out_dir']!=proj['top_dir']:
+                               try:
+                                       shutil.rmtree(proj['out_dir'])
+                               except IOError:
+                                       pass
+                               except OSError ,e:
+                                       if e.errno!=errno.ENOENT:
+                                               Logs.warn('project %r cannot be removed'%proj[Context.OUT])
+                       else:
+                               distclean_dir(proj['out_dir'])
+                       for k in(proj['out_dir'],proj['top_dir'],proj['run_dir']):
+                               try:
+                                       os.remove(os.path.join(k,Options.lockfile))
+                               except OSError ,e:
+                                       if e.errno!=errno.ENOENT:
+                                               Logs.warn('file %r cannot be removed'%f)
+               if f.startswith('.waf')and not Options.commands:
+                       shutil.rmtree(f,ignore_errors=True)
+class Dist(Context.Context):
+       '''creates an archive containing the project source code'''
+       cmd='dist'
+       fun='dist'
+       algo='tar.bz2'
+       ext_algo={}
+       def execute(self):
+               self.recurse([os.path.dirname(Context.g_module.root_path)])
+               self.archive()
+       def archive(self):
+               import tarfile
+               arch_name=self.get_arch_name()
+               try:
+                       self.base_path
+               except AttributeError:
+                       self.base_path=self.path
+               node=self.base_path.make_node(arch_name)
+               try:
+                       node.delete()
+               except Exception:
+                       pass
+               files=self.get_files()
+               if self.algo.startswith('tar.'):
+                       tar=tarfile.open(arch_name,'w:'+self.algo.replace('tar.',''))
+                       for x in files:
+                               self.add_tar_file(x,tar)
+                       tar.close()
+               elif self.algo=='zip':
+                       import zipfile
+                       zip=zipfile.ZipFile(arch_name,'w',compression=zipfile.ZIP_DEFLATED)
+                       for x in files:
+                               archive_name=self.get_base_name()+'/'+x.path_from(self.base_path)
+                               zip.write(x.abspath(),archive_name,zipfile.ZIP_DEFLATED)
+                       zip.close()
+               else:
+                       self.fatal('Valid algo types are tar.bz2, tar.gz or zip')
+               try:
+                       from hashlib import sha1 as sha
+               except ImportError:
+                       from sha import sha
+               try:
+                       digest=" (sha=%r)"%sha(node.read()).hexdigest()
+               except Exception:
+                       digest=''
+               Logs.info('New archive created: %s%s'%(self.arch_name,digest))
+       def get_tar_path(self,node):
+               return node.abspath()
+       def add_tar_file(self,x,tar):
+               p=self.get_tar_path(x)
+               tinfo=tar.gettarinfo(name=p,arcname=self.get_tar_prefix()+'/'+x.path_from(self.base_path))
+               tinfo.uid=0
+               tinfo.gid=0
+               tinfo.uname='root'
+               tinfo.gname='root'
+               fu=None
+               try:
+                       fu=open(p,'rb')
+                       tar.addfile(tinfo,fileobj=fu)
+               finally:
+                       if fu:
+                               fu.close()
+       def get_tar_prefix(self):
+               try:
+                       return self.tar_prefix
+               except AttributeError:
+                       return self.get_base_name()
+       def get_arch_name(self):
+               try:
+                       self.arch_name
+               except AttributeError:
+                       self.arch_name=self.get_base_name()+'.'+self.ext_algo.get(self.algo,self.algo)
+               return self.arch_name
+       def get_base_name(self):
+               try:
+                       self.base_name
+               except AttributeError:
+                       appname=getattr(Context.g_module,Context.APPNAME,'noname')
+                       version=getattr(Context.g_module,Context.VERSION,'1.0')
+                       self.base_name=appname+'-'+version
+               return self.base_name
+       def get_excl(self):
+               try:
+                       return self.excl
+               except AttributeError:
+                       self.excl=Node.exclude_regs+' **/waf-1.7.* **/.waf-1.7* **/waf3-1.7.* **/.waf3-1.7* **/*~ **/*.rej **/*.orig **/*.pyc **/*.pyo **/*.bak **/*.swp **/.lock-w*'
+                       nd=self.root.find_node(Context.out_dir)
+                       if nd:
+                               self.excl+=' '+nd.path_from(self.base_path)
+                       return self.excl
+       def get_files(self):
+               try:
+                       files=self.files
+               except AttributeError:
+                       files=self.base_path.ant_glob('**/*',excl=self.get_excl())
+               return files
+def dist(ctx):
+       '''makes a tarball for redistributing the sources'''
+       pass
+class DistCheck(Dist):
+       fun='distcheck'
+       cmd='distcheck'
+       def execute(self):
+               self.recurse([os.path.dirname(Context.g_module.root_path)])
+               self.archive()
+               self.check()
+       def check(self):
+               import tempfile,tarfile
+               t=None
+               try:
+                       t=tarfile.open(self.get_arch_name())
+                       for x in t:
+                               t.extract(x)
+               finally:
+                       if t:
+                               t.close()
+               cfg=[]
+               if Options.options.distcheck_args:
+                       cfg=shlex.split(Options.options.distcheck_args)
+               else:
+                       cfg=[x for x in sys.argv if x.startswith('-')]
+               instdir=tempfile.mkdtemp('.inst',self.get_base_name())
+               ret=Utils.subprocess.Popen([sys.executable,sys.argv[0],'configure','install','uninstall','--destdir='+instdir]+cfg,cwd=self.get_base_name()).wait()
+               if ret:
+                       raise Errors.WafError('distcheck failed with code %i'%ret)
+               if os.path.exists(instdir):
+                       raise Errors.WafError('distcheck succeeded, but files were left in %s'%instdir)
+               shutil.rmtree(self.get_base_name())
+def distcheck(ctx):
+       '''checks if the project compiles (tarball from 'dist')'''
+       pass
+def update(ctx):
+       '''updates the plugins from the *waflib/extras* directory'''
+       lst=Options.options.files.split(',')
+       if not lst:
+               lst=[x for x in Utils.listdir(Context.waf_dir+'/waflib/extras')if x.endswith('.py')]
+       for x in lst:
+               tool=x.replace('.py','')
+               try:
+                       Configure.download_tool(tool,force=True,ctx=ctx)
+               except Errors.WafError:
+                       Logs.error('Could not find the tool %s in the remote repository'%x)
+def autoconfigure(execute_method):
+       def execute(self):
+               if not Configure.autoconfig:
+                       return execute_method(self)
+               env=ConfigSet.ConfigSet()
+               do_config=False
+               try:
+                       env.load(os.path.join(Context.top_dir,Options.lockfile))
+               except Exception:
+                       Logs.warn('Configuring the project')
+                       do_config=True
+               else:
+                       if env.run_dir!=Context.run_dir:
+                               do_config=True
+                       else:
+                               h=0
+                               for f in env['files']:
+                                       h=hash((h,Utils.readf(f,'rb')))
+                               do_config=h!=env.hash
+               if do_config:
+                       Options.commands.insert(0,self.cmd)
+                       Options.commands.insert(0,'configure')
+                       return
+               return execute_method(self)
+       return execute
+Build.BuildContext.execute=autoconfigure(Build.BuildContext.execute)
diff --git a/waflib/Scripting.pyc b/waflib/Scripting.pyc
new file mode 100644 (file)
index 0000000..5ed5b89
Binary files /dev/null and b/waflib/Scripting.pyc differ
diff --git a/waflib/Task.py b/waflib/Task.py
new file mode 100644 (file)
index 0000000..1b54a54
--- /dev/null
@@ -0,0 +1,677 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,shutil,re,tempfile
+from waflib import Utils,Logs,Errors
+NOT_RUN=0
+MISSING=1
+CRASHED=2
+EXCEPTION=3
+SKIPPED=8
+SUCCESS=9
+ASK_LATER=-1
+SKIP_ME=-2
+RUN_ME=-3
+COMPILE_TEMPLATE_SHELL='''
+def f(tsk):
+       env = tsk.env
+       gen = tsk.generator
+       bld = gen.bld
+       wd = getattr(tsk, 'cwd', None)
+       p = env.get_flat
+       tsk.last_cmd = cmd = \'\'\' %s \'\'\' % s
+       return tsk.exec_command(cmd, cwd=wd, env=env.env or None)
+'''
+COMPILE_TEMPLATE_NOSHELL='''
+def f(tsk):
+       env = tsk.env
+       gen = tsk.generator
+       bld = gen.bld
+       wd = getattr(tsk, 'cwd', None)
+       def to_list(xx):
+               if isinstance(xx, str): return [xx]
+               return xx
+       tsk.last_cmd = lst = []
+       %s
+       lst = [x for x in lst if x]
+       return tsk.exec_command(lst, cwd=wd, env=env.env or None)
+'''
+def cache_outputs(cls):
+       m1=cls.run
+       def run(self):
+               bld=self.generator.bld
+               if bld.cache_global and not bld.nocache:
+                       if self.can_retrieve_cache():
+                               return 0
+               return m1(self)
+       cls.run=run
+       m2=cls.post_run
+       def post_run(self):
+               bld=self.generator.bld
+               ret=m2(self)
+               if bld.cache_global and not bld.nocache:
+                       self.put_files_cache()
+               return ret
+       cls.post_run=post_run
+       return cls
+classes={}
+class store_task_type(type):
+       def __init__(cls,name,bases,dict):
+               super(store_task_type,cls).__init__(name,bases,dict)
+               name=cls.__name__
+               if name.endswith('_task'):
+                       name=name.replace('_task','')
+               if name!='evil'and name!='TaskBase':
+                       global classes
+                       if getattr(cls,'run_str',None):
+                               (f,dvars)=compile_fun(cls.run_str,cls.shell)
+                               cls.hcode=cls.run_str
+                               cls.run_str=None
+                               cls.run=f
+                               cls.vars=list(set(cls.vars+dvars))
+                               cls.vars.sort()
+                       elif getattr(cls,'run',None)and not'hcode'in cls.__dict__:
+                               cls.hcode=Utils.h_fun(cls.run)
+                       if not getattr(cls,'nocache',None):
+                               cls=cache_outputs(cls)
+                       getattr(cls,'register',classes)[name]=cls
+evil=store_task_type('evil',(object,),{})
+class TaskBase(evil):
+       color='GREEN'
+       ext_in=[]
+       ext_out=[]
+       before=[]
+       after=[]
+       hcode=''
+       def __init__(self,*k,**kw):
+               self.hasrun=NOT_RUN
+               try:
+                       self.generator=kw['generator']
+               except KeyError:
+                       self.generator=self
+       def __repr__(self):
+               return'\n\t{task %r: %s %s}'%(self.__class__.__name__,id(self),str(getattr(self,'fun','')))
+       def __str__(self):
+               if hasattr(self,'fun'):
+                       return'executing: %s\n'%self.fun.__name__
+               return self.__class__.__name__+'\n'
+       def __hash__(self):
+               return id(self)
+       def exec_command(self,cmd,**kw):
+               bld=self.generator.bld
+               try:
+                       if not kw.get('cwd',None):
+                               kw['cwd']=bld.cwd
+               except AttributeError:
+                       bld.cwd=kw['cwd']=bld.variant_dir
+               return bld.exec_command(cmd,**kw)
+       def runnable_status(self):
+               return RUN_ME
+       def process(self):
+               m=self.master
+               if m.stop:
+                       m.out.put(self)
+                       return
+               try:
+                       del self.generator.bld.task_sigs[self.uid()]
+               except KeyError:
+                       pass
+               try:
+                       self.generator.bld.returned_tasks.append(self)
+                       self.log_display(self.generator.bld)
+                       ret=self.run()
+               except Exception:
+                       self.err_msg=Utils.ex_stack()
+                       self.hasrun=EXCEPTION
+                       m.error_handler(self)
+                       m.out.put(self)
+                       return
+               if ret:
+                       self.err_code=ret
+                       self.hasrun=CRASHED
+               else:
+                       try:
+                               self.post_run()
+                       except Errors.WafError:
+                               pass
+                       except Exception:
+                               self.err_msg=Utils.ex_stack()
+                               self.hasrun=EXCEPTION
+                       else:
+                               self.hasrun=SUCCESS
+               if self.hasrun!=SUCCESS:
+                       m.error_handler(self)
+               m.out.put(self)
+       def run(self):
+               if hasattr(self,'fun'):
+                       return self.fun(self)
+               return 0
+       def post_run(self):
+               pass
+       def log_display(self,bld):
+               bld.to_log(self.display())
+       def display(self):
+               col1=Logs.colors(self.color)
+               col2=Logs.colors.NORMAL
+               master=self.master
+               def cur():
+                       tmp=-1
+                       if hasattr(master,'ready'):
+                               tmp-=master.ready.qsize()
+                       return master.processed+tmp
+               if self.generator.bld.progress_bar==1:
+                       return self.generator.bld.progress_line(cur(),master.total,col1,col2)
+               if self.generator.bld.progress_bar==2:
+                       ela=str(self.generator.bld.timer)
+                       try:
+                               ins=','.join([n.name for n in self.inputs])
+                       except AttributeError:
+                               ins=''
+                       try:
+                               outs=','.join([n.name for n in self.outputs])
+                       except AttributeError:
+                               outs=''
+                       return'|Total %s|Current %s|Inputs %s|Outputs %s|Time %s|\n'%(master.total,cur(),ins,outs,ela)
+               s=str(self)
+               if not s:
+                       return None
+               total=master.total
+               n=len(str(total))
+               fs='[%%%dd/%%%dd] %%s%%s%%s'%(n,n)
+               return fs%(cur(),total,col1,s,col2)
+       def attr(self,att,default=None):
+               ret=getattr(self,att,self)
+               if ret is self:return getattr(self.__class__,att,default)
+               return ret
+       def hash_constraints(self):
+               cls=self.__class__
+               tup=(str(cls.before),str(cls.after),str(cls.ext_in),str(cls.ext_out),cls.__name__,cls.hcode)
+               h=hash(tup)
+               return h
+       def format_error(self):
+               msg=getattr(self,'last_cmd','')
+               name=getattr(self.generator,'name','')
+               if getattr(self,"err_msg",None):
+                       return self.err_msg
+               elif not self.hasrun:
+                       return'task in %r was not executed for some reason: %r'%(name,self)
+               elif self.hasrun==CRASHED:
+                       try:
+                               return' -> task in %r failed (exit status %r): %r\n%r'%(name,self.err_code,self,msg)
+                       except AttributeError:
+                               return' -> task in %r failed: %r\n%r'%(name,self,msg)
+               elif self.hasrun==MISSING:
+                       return' -> missing files in %r: %r\n%r'%(name,self,msg)
+               else:
+                       return'invalid status for task in %r: %r'%(name,self.hasrun)
+       def colon(self,var1,var2):
+               tmp=self.env[var1]
+               if isinstance(var2,str):
+                       it=self.env[var2]
+               else:
+                       it=var2
+               if isinstance(tmp,str):
+                       return[tmp%x for x in it]
+               else:
+                       if Logs.verbose and not tmp and it:
+                               Logs.warn('Missing env variable %r for task %r (generator %r)'%(var1,self,self.generator))
+                       lst=[]
+                       for y in it:
+                               lst.extend(tmp)
+                               lst.append(y)
+                       return lst
+class Task(TaskBase):
+       vars=[]
+       shell=False
+       def __init__(self,*k,**kw):
+               TaskBase.__init__(self,*k,**kw)
+               self.env=kw['env']
+               self.inputs=[]
+               self.outputs=[]
+               self.dep_nodes=[]
+               self.run_after=set([])
+       def __str__(self):
+               env=self.env
+               src_str=' '.join([a.nice_path()for a in self.inputs])
+               tgt_str=' '.join([a.nice_path()for a in self.outputs])
+               if self.outputs:sep=' -> '
+               else:sep=''
+               return'%s: %s%s%s\n'%(self.__class__.__name__.replace('_task',''),src_str,sep,tgt_str)
+       def __repr__(self):
+               try:
+                       ins=",".join([x.name for x in self.inputs])
+                       outs=",".join([x.name for x in self.outputs])
+               except AttributeError:
+                       ins=",".join([str(x)for x in self.inputs])
+                       outs=",".join([str(x)for x in self.outputs])
+               return"".join(['\n\t{task %r: '%id(self),self.__class__.__name__," ",ins," -> ",outs,'}'])
+       def uid(self):
+               try:
+                       return self.uid_
+               except AttributeError:
+                       m=Utils.md5()
+                       up=m.update
+                       up(self.__class__.__name__)
+                       for x in self.inputs+self.outputs:
+                               up(x.abspath())
+                       self.uid_=m.digest()
+                       return self.uid_
+       def set_inputs(self,inp):
+               if isinstance(inp,list):self.inputs+=inp
+               else:self.inputs.append(inp)
+       def set_outputs(self,out):
+               if isinstance(out,list):self.outputs+=out
+               else:self.outputs.append(out)
+       def set_run_after(self,task):
+               assert isinstance(task,TaskBase)
+               self.run_after.add(task)
+       def signature(self):
+               try:return self.cache_sig
+               except AttributeError:pass
+               self.m=Utils.md5()
+               self.m.update(self.hcode)
+               self.sig_explicit_deps()
+               self.sig_vars()
+               if self.scan:
+                       try:
+                               self.sig_implicit_deps()
+                       except Errors.TaskRescan:
+                               return self.signature()
+               ret=self.cache_sig=self.m.digest()
+               return ret
+       def runnable_status(self):
+               for t in self.run_after:
+                       if not t.hasrun:
+                               return ASK_LATER
+               bld=self.generator.bld
+               try:
+                       new_sig=self.signature()
+               except Errors.TaskNotReady:
+                       return ASK_LATER
+               key=self.uid()
+               try:
+                       prev_sig=bld.task_sigs[key]
+               except KeyError:
+                       Logs.debug("task: task %r must run as it was never run before or the task code changed"%self)
+                       return RUN_ME
+               for node in self.outputs:
+                       try:
+                               if node.sig!=new_sig:
+                                       return RUN_ME
+                       except AttributeError:
+                               Logs.debug("task: task %r must run as the output nodes do not exist"%self)
+                               return RUN_ME
+               if new_sig!=prev_sig:
+                       return RUN_ME
+               return SKIP_ME
+       def post_run(self):
+               bld=self.generator.bld
+               sig=self.signature()
+               for node in self.outputs:
+                       try:
+                               os.stat(node.abspath())
+                       except OSError:
+                               self.hasrun=MISSING
+                               self.err_msg='-> missing file: %r'%node.abspath()
+                               raise Errors.WafError(self.err_msg)
+                       node.sig=sig
+               bld.task_sigs[self.uid()]=self.cache_sig
+       def sig_explicit_deps(self):
+               bld=self.generator.bld
+               upd=self.m.update
+               for x in self.inputs+self.dep_nodes:
+                       try:
+                               upd(x.get_bld_sig())
+                       except(AttributeError,TypeError):
+                               raise Errors.WafError('Missing node signature for %r (required by %r)'%(x,self))
+               if bld.deps_man:
+                       additional_deps=bld.deps_man
+                       for x in self.inputs+self.outputs:
+                               try:
+                                       d=additional_deps[id(x)]
+                               except KeyError:
+                                       continue
+                               for v in d:
+                                       if isinstance(v,bld.root.__class__):
+                                               try:
+                                                       v=v.get_bld_sig()
+                                               except AttributeError:
+                                                       raise Errors.WafError('Missing node signature for %r (required by %r)'%(v,self))
+                                       elif hasattr(v,'__call__'):
+                                               v=v()
+                                       upd(v)
+               return self.m.digest()
+       def sig_vars(self):
+               bld=self.generator.bld
+               env=self.env
+               upd=self.m.update
+               act_sig=bld.hash_env_vars(env,self.__class__.vars)
+               upd(act_sig)
+               dep_vars=getattr(self,'dep_vars',None)
+               if dep_vars:
+                       upd(bld.hash_env_vars(env,dep_vars))
+               return self.m.digest()
+       scan=None
+       def sig_implicit_deps(self):
+               bld=self.generator.bld
+               key=self.uid()
+               prev=bld.task_sigs.get((key,'imp'),[])
+               if prev:
+                       try:
+                               if prev==self.compute_sig_implicit_deps():
+                                       return prev
+                       except Exception:
+                               for x in bld.node_deps.get(self.uid(),[]):
+                                       if x.is_child_of(bld.srcnode):
+                                               try:
+                                                       os.stat(x.abspath())
+                                               except OSError:
+                                                       try:
+                                                               del x.parent.children[x.name]
+                                                       except KeyError:
+                                                               pass
+                       del bld.task_sigs[(key,'imp')]
+                       raise Errors.TaskRescan('rescan')
+               (nodes,names)=self.scan()
+               if Logs.verbose:
+                       Logs.debug('deps: scanner for %s returned %s %s'%(str(self),str(nodes),str(names)))
+               bld.node_deps[key]=nodes
+               bld.raw_deps[key]=names
+               self.are_implicit_nodes_ready()
+               try:
+                       bld.task_sigs[(key,'imp')]=sig=self.compute_sig_implicit_deps()
+               except Exception:
+                       if Logs.verbose:
+                               for k in bld.node_deps.get(self.uid(),[]):
+                                       try:
+                                               k.get_bld_sig()
+                                       except Exception:
+                                               Logs.warn('Missing signature for node %r (may cause rebuilds)'%k)
+               else:
+                       return sig
+       def compute_sig_implicit_deps(self):
+               upd=self.m.update
+               bld=self.generator.bld
+               self.are_implicit_nodes_ready()
+               for k in bld.node_deps.get(self.uid(),[]):
+                       upd(k.get_bld_sig())
+               return self.m.digest()
+       def are_implicit_nodes_ready(self):
+               bld=self.generator.bld
+               try:
+                       cache=bld.dct_implicit_nodes
+               except AttributeError:
+                       bld.dct_implicit_nodes=cache={}
+               try:
+                       dct=cache[bld.cur]
+               except KeyError:
+                       dct=cache[bld.cur]={}
+                       for tsk in bld.cur_tasks:
+                               for x in tsk.outputs:
+                                       dct[x]=tsk
+               modified=False
+               for x in bld.node_deps.get(self.uid(),[]):
+                       if x in dct:
+                               self.run_after.add(dct[x])
+                               modified=True
+               if modified:
+                       for tsk in self.run_after:
+                               if not tsk.hasrun:
+                                       raise Errors.TaskNotReady('not ready')
+       def can_retrieve_cache(self):
+               if not getattr(self,'outputs',None):
+                       return None
+               sig=self.signature()
+               ssig=Utils.to_hex(self.uid())+Utils.to_hex(sig)
+               dname=os.path.join(self.generator.bld.cache_global,ssig)
+               try:
+                       t1=os.stat(dname).st_mtime
+               except OSError:
+                       return None
+               for node in self.outputs:
+                       orig=os.path.join(dname,node.name)
+                       try:
+                               shutil.copy2(orig,node.abspath())
+                               os.utime(orig,None)
+                       except(OSError,IOError):
+                               Logs.debug('task: failed retrieving file')
+                               return None
+               try:
+                       t2=os.stat(dname).st_mtime
+               except OSError:
+                       return None
+               if t1!=t2:
+                       return None
+               for node in self.outputs:
+                       node.sig=sig
+                       if self.generator.bld.progress_bar<1:
+                               self.generator.bld.to_log('restoring from cache %r\n'%node.abspath())
+               self.cached=True
+               return True
+       def put_files_cache(self):
+               if getattr(self,'cached',None):
+                       return None
+               if not getattr(self,'outputs',None):
+                       return None
+               sig=self.signature()
+               ssig=Utils.to_hex(self.uid())+Utils.to_hex(sig)
+               dname=os.path.join(self.generator.bld.cache_global,ssig)
+               tmpdir=tempfile.mkdtemp(prefix=self.generator.bld.cache_global+os.sep+'waf')
+               try:
+                       shutil.rmtree(dname)
+               except Exception:
+                       pass
+               try:
+                       for node in self.outputs:
+                               dest=os.path.join(tmpdir,node.name)
+                               shutil.copy2(node.abspath(),dest)
+               except(OSError,IOError):
+                       try:
+                               shutil.rmtree(tmpdir)
+                       except Exception:
+                               pass
+               else:
+                       try:
+                               os.rename(tmpdir,dname)
+                       except OSError:
+                               try:
+                                       shutil.rmtree(tmpdir)
+                               except Exception:
+                                       pass
+                       else:
+                               try:
+                                       os.chmod(dname,Utils.O755)
+                               except Exception:
+                                       pass
+def is_before(t1,t2):
+       to_list=Utils.to_list
+       for k in to_list(t2.ext_in):
+               if k in to_list(t1.ext_out):
+                       return 1
+       if t1.__class__.__name__ in to_list(t2.after):
+               return 1
+       if t2.__class__.__name__ in to_list(t1.before):
+               return 1
+       return 0
+def set_file_constraints(tasks):
+       ins=Utils.defaultdict(set)
+       outs=Utils.defaultdict(set)
+       for x in tasks:
+               for a in getattr(x,'inputs',[])+getattr(x,'dep_nodes',[]):
+                       ins[id(a)].add(x)
+               for a in getattr(x,'outputs',[]):
+                       outs[id(a)].add(x)
+       links=set(ins.keys()).intersection(outs.keys())
+       for k in links:
+               for a in ins[k]:
+                       a.run_after.update(outs[k])
+def set_precedence_constraints(tasks):
+       cstr_groups=Utils.defaultdict(list)
+       for x in tasks:
+               h=x.hash_constraints()
+               cstr_groups[h].append(x)
+       keys=list(cstr_groups.keys())
+       maxi=len(keys)
+       for i in range(maxi):
+               t1=cstr_groups[keys[i]][0]
+               for j in range(i+1,maxi):
+                       t2=cstr_groups[keys[j]][0]
+                       if is_before(t1,t2):
+                               a=i
+                               b=j
+                       elif is_before(t2,t1):
+                               a=j
+                               b=i
+                       else:
+                               continue
+                       aval=set(cstr_groups[keys[a]])
+                       for x in cstr_groups[keys[b]]:
+                               x.run_after.update(aval)
+def funex(c):
+       dc={}
+       exec(c,dc)
+       return dc['f']
+reg_act=re.compile(r"(?P<backslash>\\)|(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})",re.M)
+def compile_fun_shell(line):
+       extr=[]
+       def repl(match):
+               g=match.group
+               if g('dollar'):return"$"
+               elif g('backslash'):return'\\\\'
+               elif g('subst'):extr.append((g('var'),g('code')));return"%s"
+               return None
+       line=reg_act.sub(repl,line)or line
+       parm=[]
+       dvars=[]
+       app=parm.append
+       for(var,meth)in extr:
+               if var=='SRC':
+                       if meth:app('tsk.inputs%s'%meth)
+                       else:app('" ".join([a.path_from(bld.bldnode) for a in tsk.inputs])')
+               elif var=='TGT':
+                       if meth:app('tsk.outputs%s'%meth)
+                       else:app('" ".join([a.path_from(bld.bldnode) for a in tsk.outputs])')
+               elif meth:
+                       if meth.startswith(':'):
+                               m=meth[1:]
+                               if m=='SRC':
+                                       m='[a.path_from(bld.bldnode) for a in tsk.inputs]'
+                               elif m=='TGT':
+                                       m='[a.path_from(bld.bldnode) for a in tsk.outputs]'
+                               elif m[:3]not in('tsk','gen','bld'):
+                                       dvars.extend([var,meth[1:]])
+                                       m='%r'%m
+                               app('" ".join(tsk.colon(%r, %s))'%(var,m))
+                       else:
+                               app('%s%s'%(var,meth))
+               else:
+                       if not var in dvars:dvars.append(var)
+                       app("p('%s')"%var)
+       if parm:parm="%% (%s) "%(',\n\t\t'.join(parm))
+       else:parm=''
+       c=COMPILE_TEMPLATE_SHELL%(line,parm)
+       Logs.debug('action: %s'%c.strip().splitlines())
+       return(funex(c),dvars)
+def compile_fun_noshell(line):
+       extr=[]
+       def repl(match):
+               g=match.group
+               if g('dollar'):return"$"
+               elif g('subst'):extr.append((g('var'),g('code')));return"<<|@|>>"
+               return None
+       line2=reg_act.sub(repl,line)
+       params=line2.split('<<|@|>>')
+       assert(extr)
+       buf=[]
+       dvars=[]
+       app=buf.append
+       for x in range(len(extr)):
+               params[x]=params[x].strip()
+               if params[x]:
+                       app("lst.extend(%r)"%params[x].split())
+               (var,meth)=extr[x]
+               if var=='SRC':
+                       if meth:app('lst.append(tsk.inputs%s)'%meth)
+                       else:app("lst.extend([a.path_from(bld.bldnode) for a in tsk.inputs])")
+               elif var=='TGT':
+                       if meth:app('lst.append(tsk.outputs%s)'%meth)
+                       else:app("lst.extend([a.path_from(bld.bldnode) for a in tsk.outputs])")
+               elif meth:
+                       if meth.startswith(':'):
+                               m=meth[1:]
+                               if m=='SRC':
+                                       m='[a.path_from(bld.bldnode) for a in tsk.inputs]'
+                               elif m=='TGT':
+                                       m='[a.path_from(bld.bldnode) for a in tsk.outputs]'
+                               elif m[:3]not in('tsk','gen','bld'):
+                                       dvars.extend([var,m])
+                                       m='%r'%m
+                               app('lst.extend(tsk.colon(%r, %s))'%(var,m))
+                       else:
+                               app('lst.extend(gen.to_list(%s%s))'%(var,meth))
+               else:
+                       app('lst.extend(to_list(env[%r]))'%var)
+                       if not var in dvars:dvars.append(var)
+       if extr:
+               if params[-1]:
+                       app("lst.extend(%r)"%params[-1].split())
+       fun=COMPILE_TEMPLATE_NOSHELL%"\n\t".join(buf)
+       Logs.debug('action: %s'%fun.strip().splitlines())
+       return(funex(fun),dvars)
+def compile_fun(line,shell=False):
+       if line.find('<')>0 or line.find('>')>0 or line.find('&&')>0:
+               shell=True
+       if shell:
+               return compile_fun_shell(line)
+       else:
+               return compile_fun_noshell(line)
+def task_factory(name,func=None,vars=None,color='GREEN',ext_in=[],ext_out=[],before=[],after=[],shell=False,scan=None):
+       params={'vars':vars or[],'color':color,'name':name,'ext_in':Utils.to_list(ext_in),'ext_out':Utils.to_list(ext_out),'before':Utils.to_list(before),'after':Utils.to_list(after),'shell':shell,'scan':scan,}
+       if isinstance(func,str):
+               params['run_str']=func
+       else:
+               params['run']=func
+       cls=type(Task)(name,(Task,),params)
+       global classes
+       classes[name]=cls
+       return cls
+def always_run(cls):
+       old=cls.runnable_status
+       def always(self):
+               ret=old(self)
+               if ret==SKIP_ME:
+                       ret=RUN_ME
+               return ret
+       cls.runnable_status=always
+       return cls
+def update_outputs(cls):
+       old_post_run=cls.post_run
+       def post_run(self):
+               old_post_run(self)
+               for node in self.outputs:
+                       node.sig=Utils.h_file(node.abspath())
+                       self.generator.bld.task_sigs[node.abspath()]=self.uid()
+       cls.post_run=post_run
+       old_runnable_status=cls.runnable_status
+       def runnable_status(self):
+               status=old_runnable_status(self)
+               if status!=RUN_ME:
+                       return status
+               try:
+                       bld=self.generator.bld
+                       prev_sig=bld.task_sigs[self.uid()]
+                       if prev_sig==self.signature():
+                               for x in self.outputs:
+                                       if not x.sig or bld.task_sigs[x.abspath()]!=self.uid():
+                                               return RUN_ME
+                               return SKIP_ME
+               except KeyError:
+                       pass
+               except IndexError:
+                       pass
+               except AttributeError:
+                       pass
+               return RUN_ME
+       cls.runnable_status=runnable_status
+       return cls
diff --git a/waflib/Task.pyc b/waflib/Task.pyc
new file mode 100644 (file)
index 0000000..1cb8899
Binary files /dev/null and b/waflib/Task.pyc differ
diff --git a/waflib/TaskGen.py b/waflib/TaskGen.py
new file mode 100644 (file)
index 0000000..4e04239
--- /dev/null
@@ -0,0 +1,404 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import copy,re,os
+from waflib import Task,Utils,Logs,Errors,ConfigSet,Node
+feats=Utils.defaultdict(set)
+class task_gen(object):
+       mappings={}
+       prec=Utils.defaultdict(list)
+       def __init__(self,*k,**kw):
+               self.source=''
+               self.target=''
+               self.meths=[]
+               self.prec=Utils.defaultdict(list)
+               self.mappings={}
+               self.features=[]
+               self.tasks=[]
+               if not'bld'in kw:
+                       self.env=ConfigSet.ConfigSet()
+                       self.idx=0
+                       self.path=None
+               else:
+                       self.bld=kw['bld']
+                       self.env=self.bld.env.derive()
+                       self.path=self.bld.path
+                       try:
+                               self.idx=self.bld.idx[id(self.path)]=self.bld.idx.get(id(self.path),0)+1
+                       except AttributeError:
+                               self.bld.idx={}
+                               self.idx=self.bld.idx[id(self.path)]=1
+               for key,val in kw.items():
+                       setattr(self,key,val)
+       def __str__(self):
+               return"<task_gen %r declared in %s>"%(self.name,self.path.abspath())
+       def __repr__(self):
+               lst=[]
+               for x in self.__dict__.keys():
+                       if x not in['env','bld','compiled_tasks','tasks']:
+                               lst.append("%s=%s"%(x,repr(getattr(self,x))))
+               return"bld(%s) in %s"%(", ".join(lst),self.path.abspath())
+       def get_name(self):
+               try:
+                       return self._name
+               except AttributeError:
+                       if isinstance(self.target,list):
+                               lst=[str(x)for x in self.target]
+                               name=self._name=','.join(lst)
+                       else:
+                               name=self._name=str(self.target)
+                       return name
+       def set_name(self,name):
+               self._name=name
+       name=property(get_name,set_name)
+       def to_list(self,val):
+               if isinstance(val,str):return val.split()
+               else:return val
+       def post(self):
+               if getattr(self,'posted',None):
+                       return False
+               self.posted=True
+               keys=set(self.meths)
+               self.features=Utils.to_list(self.features)
+               for x in self.features+['*']:
+                       st=feats[x]
+                       if not st:
+                               if not x in Task.classes:
+                                       Logs.warn('feature %r does not exist - bind at least one method to it'%x)
+                       keys.update(list(st))
+               prec={}
+               prec_tbl=self.prec or task_gen.prec
+               for x in prec_tbl:
+                       if x in keys:
+                               prec[x]=prec_tbl[x]
+               tmp=[]
+               for a in keys:
+                       for x in prec.values():
+                               if a in x:break
+                       else:
+                               tmp.append(a)
+               tmp.sort()
+               out=[]
+               while tmp:
+                       e=tmp.pop()
+                       if e in keys:out.append(e)
+                       try:
+                               nlst=prec[e]
+                       except KeyError:
+                               pass
+                       else:
+                               del prec[e]
+                               for x in nlst:
+                                       for y in prec:
+                                               if x in prec[y]:
+                                                       break
+                                       else:
+                                               tmp.append(x)
+               if prec:
+                       raise Errors.WafError('Cycle detected in the method execution %r'%prec)
+               out.reverse()
+               self.meths=out
+               Logs.debug('task_gen: posting %s %d'%(self,id(self)))
+               for x in out:
+                       try:
+                               v=getattr(self,x)
+                       except AttributeError:
+                               raise Errors.WafError('%r is not a valid task generator method'%x)
+                       Logs.debug('task_gen: -> %s (%d)'%(x,id(self)))
+                       v()
+               Logs.debug('task_gen: posted %s'%self.name)
+               return True
+       def get_hook(self,node):
+               name=node.name
+               for k in self.mappings:
+                       if name.endswith(k):
+                               return self.mappings[k]
+               for k in task_gen.mappings:
+                       if name.endswith(k):
+                               return task_gen.mappings[k]
+               raise Errors.WafError("File %r has no mapping in %r (did you forget to load a waf tool?)"%(node,task_gen.mappings.keys()))
+       def create_task(self,name,src=None,tgt=None):
+               task=Task.classes[name](env=self.env.derive(),generator=self)
+               if src:
+                       task.set_inputs(src)
+               if tgt:
+                       task.set_outputs(tgt)
+               self.tasks.append(task)
+               return task
+       def clone(self,env):
+               newobj=self.bld()
+               for x in self.__dict__:
+                       if x in['env','bld']:
+                               continue
+                       elif x in['path','features']:
+                               setattr(newobj,x,getattr(self,x))
+                       else:
+                               setattr(newobj,x,copy.copy(getattr(self,x)))
+               newobj.posted=False
+               if isinstance(env,str):
+                       newobj.env=self.bld.all_envs[env].derive()
+               else:
+                       newobj.env=env.derive()
+               return newobj
+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):
+       ext_in=Utils.to_list(ext_in)
+       ext_out=Utils.to_list(ext_out)
+       if not name:
+               name=rule
+       cls=Task.task_factory(name,rule,color=color,ext_in=ext_in,ext_out=ext_out,before=before,after=after,scan=scan,shell=shell)
+       def x_file(self,node):
+               ext=decider and decider(self,node)or cls.ext_out
+               if ext_in:
+                       _ext_in=ext_in[0]
+               tsk=self.create_task(name,node)
+               cnt=0
+               keys=list(self.mappings.keys())+list(self.__class__.mappings.keys())
+               for x in ext:
+                       k=node.change_ext(x,ext_in=_ext_in)
+                       tsk.outputs.append(k)
+                       if reentrant!=None:
+                               if cnt<int(reentrant):
+                                       self.source.append(k)
+                       else:
+                               for y in keys:
+                                       if k.name.endswith(y):
+                                               self.source.append(k)
+                                               break
+                       cnt+=1
+               if install_path:
+                       self.bld.install_files(install_path,tsk.outputs)
+               return tsk
+       for x in cls.ext_in:
+               task_gen.mappings[x]=x_file
+       return x_file
+def taskgen_method(func):
+       setattr(task_gen,func.__name__,func)
+       return func
+def feature(*k):
+       def deco(func):
+               setattr(task_gen,func.__name__,func)
+               for name in k:
+                       feats[name].update([func.__name__])
+               return func
+       return deco
+def before_method(*k):
+       def deco(func):
+               setattr(task_gen,func.__name__,func)
+               for fun_name in k:
+                       if not func.__name__ in task_gen.prec[fun_name]:
+                               task_gen.prec[fun_name].append(func.__name__)
+               return func
+       return deco
+before=before_method
+def after_method(*k):
+       def deco(func):
+               setattr(task_gen,func.__name__,func)
+               for fun_name in k:
+                       if not fun_name in task_gen.prec[func.__name__]:
+                               task_gen.prec[func.__name__].append(fun_name)
+               return func
+       return deco
+after=after_method
+def extension(*k):
+       def deco(func):
+               setattr(task_gen,func.__name__,func)
+               for x in k:
+                       task_gen.mappings[x]=func
+               return func
+       return deco
+@taskgen_method
+def to_nodes(self,lst,path=None):
+       tmp=[]
+       path=path or self.path
+       find=path.find_resource
+       if isinstance(lst,self.path.__class__):
+               lst=[lst]
+       for x in Utils.to_list(lst):
+               if isinstance(x,str):
+                       node=find(x)
+               else:
+                       node=x
+               if not node:
+                       raise Errors.WafError("source not found: %r in %r"%(x,self))
+               tmp.append(node)
+       return tmp
+@feature('*')
+def process_source(self):
+       self.source=self.to_nodes(getattr(self,'source',[]))
+       for node in self.source:
+               self.get_hook(node)(self,node)
+@feature('*')
+@before_method('process_source')
+def process_rule(self):
+       if not getattr(self,'rule',None):
+               return
+       name=str(getattr(self,'name',None)or self.target or getattr(self.rule,'__name__',self.rule))
+       try:
+               cache=self.bld.cache_rule_attr
+       except AttributeError:
+               cache=self.bld.cache_rule_attr={}
+       cls=None
+       if getattr(self,'cache_rule','True'):
+               try:
+                       cls=cache[(name,self.rule)]
+               except KeyError:
+                       pass
+       if not cls:
+               cls=Task.task_factory(name,self.rule,getattr(self,'vars',[]),shell=getattr(self,'shell',True),color=getattr(self,'color','BLUE'),scan=getattr(self,'scan',None))
+               if getattr(self,'scan',None):
+                       cls.scan=self.scan
+               elif getattr(self,'deps',None):
+                       def scan(self):
+                               nodes=[]
+                               for x in self.generator.to_list(getattr(self.generator,'deps',None)):
+                                       node=self.generator.path.find_resource(x)
+                                       if not node:
+                                               self.generator.bld.fatal('Could not find %r (was it declared?)'%x)
+                                       nodes.append(node)
+                               return[nodes,[]]
+                       cls.scan=scan
+               if getattr(self,'update_outputs',None):
+                       Task.update_outputs(cls)
+               if getattr(self,'always',None):
+                       Task.always_run(cls)
+               for x in['after','before','ext_in','ext_out']:
+                       setattr(cls,x,getattr(self,x,[]))
+               if getattr(self,'cache_rule','True'):
+                       cache[(name,self.rule)]=cls
+       tsk=self.create_task(name)
+       if getattr(self,'target',None):
+               if isinstance(self.target,str):
+                       self.target=self.target.split()
+               if not isinstance(self.target,list):
+                       self.target=[self.target]
+               for x in self.target:
+                       if isinstance(x,str):
+                               tsk.outputs.append(self.path.find_or_declare(x))
+                       else:
+                               x.parent.mkdir()
+                               tsk.outputs.append(x)
+               if getattr(self,'install_path',None):
+                       self.bld.install_files(self.install_path,tsk.outputs)
+       if getattr(self,'source',None):
+               tsk.inputs=self.to_nodes(self.source)
+               self.source=[]
+       if getattr(self,'cwd',None):
+               tsk.cwd=self.cwd
+@feature('seq')
+def sequence_order(self):
+       if self.meths and self.meths[-1]!='sequence_order':
+               self.meths.append('sequence_order')
+               return
+       if getattr(self,'seq_start',None):
+               return
+       if getattr(self.bld,'prev',None):
+               self.bld.prev.post()
+               for x in self.bld.prev.tasks:
+                       for y in self.tasks:
+                               y.set_run_after(x)
+       self.bld.prev=self
+re_m4=re.compile('@(\w+)@',re.M)
+class subst_pc(Task.Task):
+       def run(self):
+               if getattr(self.generator,'is_copy',None):
+                       self.outputs[0].write(self.inputs[0].read('rb'),'wb')
+                       if getattr(self.generator,'chmod',None):
+                               os.chmod(self.outputs[0].abspath(),self.generator.chmod)
+                       return None
+               if getattr(self.generator,'fun',None):
+                       self.generator.fun(self)
+               code=self.inputs[0].read(encoding=getattr(self.generator,'encoding','ISO8859-1'))
+               if getattr(self.generator,'subst_fun',None):
+                       code=self.generator.subst_fun(self,code)
+                       if code:
+                               self.outputs[0].write(code,encoding=getattr(self.generator,'encoding','ISO8859-1'))
+                       return
+               code=code.replace('%','%%')
+               lst=[]
+               def repl(match):
+                       g=match.group
+                       if g(1):
+                               lst.append(g(1))
+                               return"%%(%s)s"%g(1)
+                       return''
+               code=re_m4.sub(repl,code)
+               try:
+                       d=self.generator.dct
+               except AttributeError:
+                       d={}
+                       for x in lst:
+                               tmp=getattr(self.generator,x,'')or self.env.get_flat(x)or self.env.get_flat(x.upper())
+                               d[x]=str(tmp)
+               code=code%d
+               self.outputs[0].write(code,encoding=getattr(self.generator,'encoding','ISO8859-1'))
+               self.generator.bld.raw_deps[self.uid()]=self.dep_vars=lst
+               try:delattr(self,'cache_sig')
+               except AttributeError:pass
+               if getattr(self.generator,'chmod',None):
+                       os.chmod(self.outputs[0].abspath(),self.generator.chmod)
+       def sig_vars(self):
+               bld=self.generator.bld
+               env=self.env
+               upd=self.m.update
+               if getattr(self.generator,'fun',None):
+                       upd(Utils.h_fun(self.generator.fun))
+               if getattr(self.generator,'subst_fun',None):
+                       upd(Utils.h_fun(self.generator.subst_fun))
+               vars=self.generator.bld.raw_deps.get(self.uid(),[])
+               act_sig=bld.hash_env_vars(env,vars)
+               upd(act_sig)
+               lst=[getattr(self.generator,x,'')for x in vars]
+               upd(Utils.h_list(lst))
+               return self.m.digest()
+@extension('.pc.in')
+def add_pcfile(self,node):
+       tsk=self.create_task('subst_pc',node,node.change_ext('.pc','.pc.in'))
+       self.bld.install_files(getattr(self,'install_path','${LIBDIR}/pkgconfig/'),tsk.outputs)
+class subst(subst_pc):
+       pass
+@feature('subst')
+@before_method('process_source','process_rule')
+def process_subst(self):
+       src=Utils.to_list(getattr(self,'source',[]))
+       if isinstance(src,Node.Node):
+               src=[src]
+       tgt=Utils.to_list(getattr(self,'target',[]))
+       if isinstance(tgt,Node.Node):
+               tgt=[tgt]
+       if len(src)!=len(tgt):
+               raise Errors.WafError('invalid number of source/target for %r'%self)
+       for x,y in zip(src,tgt):
+               if not x or not y:
+                       raise Errors.WafError('null source or target for %r'%self)
+               a,b=None,None
+               if isinstance(x,str)and isinstance(y,str)and x==y:
+                       a=self.path.find_node(x)
+                       b=self.path.get_bld().make_node(y)
+                       if not os.path.isfile(b.abspath()):
+                               b.sig=None
+                               b.parent.mkdir()
+               else:
+                       if isinstance(x,str):
+                               a=self.path.find_resource(x)
+                       elif isinstance(x,Node.Node):
+                               a=x
+                       if isinstance(y,str):
+                               b=self.path.find_or_declare(y)
+                       elif isinstance(y,Node.Node):
+                               b=y
+               if not a:
+                       raise Errors.WafError('cound not find %r for %r'%(x,self))
+               has_constraints=False
+               tsk=self.create_task('subst',a,b)
+               for k in('after','before','ext_in','ext_out'):
+                       val=getattr(self,k,None)
+                       if val:
+                               has_constraints=True
+                               setattr(tsk,k,val)
+               if not has_constraints and b.name.endswith('.h'):
+                       tsk.before=[k for k in('c','cxx')if k in Task.classes]
+               inst_to=getattr(self,'install_path',None)
+               if inst_to:
+                       self.bld.install_files(inst_to,b,chmod=getattr(self,'chmod',Utils.O644))
+       self.source=[]
diff --git a/waflib/TaskGen.pyc b/waflib/TaskGen.pyc
new file mode 100644 (file)
index 0000000..d624722
Binary files /dev/null and b/waflib/TaskGen.pyc differ
diff --git a/waflib/Tools/__init__.py b/waflib/Tools/__init__.py
new file mode 100644 (file)
index 0000000..efeed79
--- /dev/null
@@ -0,0 +1,4 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
diff --git a/waflib/Tools/__init__.pyc b/waflib/Tools/__init__.pyc
new file mode 100644 (file)
index 0000000..1b79881
Binary files /dev/null and b/waflib/Tools/__init__.pyc differ
diff --git a/waflib/Tools/ar.py b/waflib/Tools/ar.py
new file mode 100644 (file)
index 0000000..7a16dfe
--- /dev/null
@@ -0,0 +1,11 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+from waflib.Configure import conf
+@conf
+def find_ar(conf):
+       conf.load('ar')
+def configure(conf):
+       conf.find_program('ar',var='AR')
+       conf.env.ARFLAGS='rcs'
diff --git a/waflib/Tools/ar.pyc b/waflib/Tools/ar.pyc
new file mode 100644 (file)
index 0000000..0c65e5d
Binary files /dev/null and b/waflib/Tools/ar.pyc differ
diff --git a/waflib/Tools/asm.py b/waflib/Tools/asm.py
new file mode 100644 (file)
index 0000000..b9ed5f4
--- /dev/null
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,sys
+from waflib import Task,Utils
+import waflib.Task
+from waflib.Tools.ccroot import link_task,stlink_task
+from waflib.TaskGen import extension,feature
+class asm(Task.Task):
+       color='BLUE'
+       run_str='${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
+@extension('.s','.S','.asm','.ASM','.spp','.SPP')
+def asm_hook(self,node):
+       return self.create_compiled_task('asm',node)
+class asmprogram(link_task):
+       run_str='${ASLINK} ${ASLINKFLAGS} ${ASLNK_TGT_F}${TGT} ${ASLNK_SRC_F}${SRC}'
+       ext_out=['.bin']
+       inst_to='${BINDIR}'
+class asmshlib(asmprogram):
+       inst_to='${LIBDIR}'
+class asmstlib(stlink_task):
+       pass
+def configure(conf):
+       conf.env['ASMPATH_ST']='-I%s'
diff --git a/waflib/Tools/bison.py b/waflib/Tools/bison.py
new file mode 100644 (file)
index 0000000..6ae7898
--- /dev/null
@@ -0,0 +1,28 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+from waflib import Task
+from waflib.TaskGen import extension
+class bison(Task.Task):
+       color='BLUE'
+       run_str='${BISON} ${BISONFLAGS} ${SRC[0].abspath()} -o ${TGT[0].name}'
+       ext_out=['.h']
+@extension('.y','.yc','.yy')
+def big_bison(self,node):
+       has_h='-d'in self.env['BISONFLAGS']
+       outs=[]
+       if node.name.endswith('.yc'):
+               outs.append(node.change_ext('.tab.cc'))
+               if has_h:
+                       outs.append(node.change_ext('.tab.hh'))
+       else:
+               outs.append(node.change_ext('.tab.c'))
+               if has_h:
+                       outs.append(node.change_ext('.tab.h'))
+       tsk=self.create_task('bison',node,outs)
+       tsk.cwd=node.parent.get_bld().abspath()
+       self.source.append(outs[0])
+def configure(conf):
+       conf.find_program('bison',var='BISON')
+       conf.env.BISONFLAGS=['-d']
diff --git a/waflib/Tools/c.py b/waflib/Tools/c.py
new file mode 100644 (file)
index 0000000..4d8cbd5
--- /dev/null
@@ -0,0 +1,24 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+from waflib import TaskGen,Task,Utils
+from waflib.Tools import c_preproc
+from waflib.Tools.ccroot import link_task,stlink_task
+@TaskGen.extension('.c')
+def c_hook(self,node):
+       return self.create_compiled_task('c',node)
+class c(Task.Task):
+       run_str='${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${CPPFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
+       vars=['CCDEPS']
+       ext_in=['.h']
+       scan=c_preproc.scan
+class cprogram(link_task):
+       run_str='${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_TGT_F}${TGT[0].abspath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB}'
+       ext_out=['.bin']
+       vars=['LINKDEPS']
+       inst_to='${BINDIR}'
+class cshlib(cprogram):
+       inst_to='${LIBDIR}'
+class cstlib(stlink_task):
+       pass
diff --git a/waflib/Tools/c.pyc b/waflib/Tools/c.pyc
new file mode 100644 (file)
index 0000000..394d1e0
Binary files /dev/null and b/waflib/Tools/c.pyc differ
diff --git a/waflib/Tools/c_aliases.py b/waflib/Tools/c_aliases.py
new file mode 100644 (file)
index 0000000..a3a2bb9
--- /dev/null
@@ -0,0 +1,55 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,sys,re
+from waflib import Utils,Build
+from waflib.Configure import conf
+def get_extensions(lst):
+       ret=[]
+       for x in Utils.to_list(lst):
+               try:
+                       if not isinstance(x,str):
+                               x=x.name
+                       ret.append(x[x.rfind('.')+1:])
+               except Exception:
+                       pass
+       return ret
+def sniff_features(**kw):
+       exts=get_extensions(kw['source'])
+       type=kw['_type']
+       feats=[]
+       if'cxx'in exts or'cpp'in exts or'c++'in exts or'cc'in exts or'C'in exts:
+               feats.append('cxx')
+       if'c'in exts or'vala'in exts:
+               feats.append('c')
+       if'd'in exts:
+               feats.append('d')
+       if'java'in exts:
+               feats.append('java')
+       if'java'in exts:
+               return'java'
+       if type in['program','shlib','stlib']:
+               for x in feats:
+                       if x in['cxx','d','c']:
+                               feats.append(x+type)
+       return feats
+def set_features(kw,_type):
+       kw['_type']=_type
+       kw['features']=Utils.to_list(kw.get('features',[]))+Utils.to_list(sniff_features(**kw))
+@conf
+def program(bld,*k,**kw):
+       set_features(kw,'program')
+       return bld(*k,**kw)
+@conf
+def shlib(bld,*k,**kw):
+       set_features(kw,'shlib')
+       return bld(*k,**kw)
+@conf
+def stlib(bld,*k,**kw):
+       set_features(kw,'stlib')
+       return bld(*k,**kw)
+@conf
+def objects(bld,*k,**kw):
+       set_features(kw,'objects')
+       return bld(*k,**kw)
diff --git a/waflib/Tools/c_aliases.pyc b/waflib/Tools/c_aliases.pyc
new file mode 100644 (file)
index 0000000..4dff739
Binary files /dev/null and b/waflib/Tools/c_aliases.pyc differ
diff --git a/waflib/Tools/c_config.py b/waflib/Tools/c_config.py
new file mode 100755 (executable)
index 0000000..9f29b49
--- /dev/null
@@ -0,0 +1,744 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,re,shlex,sys
+from waflib import Build,Utils,Task,Options,Logs,Errors,ConfigSet,Runner
+from waflib.TaskGen import after_method,feature
+from waflib.Configure import conf
+WAF_CONFIG_H='config.h'
+DEFKEYS='define_key'
+INCKEYS='include_key'
+cfg_ver={'atleast-version':'>=','exact-version':'==','max-version':'<=',}
+SNIP_FUNCTION='''
+int main(int argc, char **argv) {
+       void *p;
+       (void)argc; (void)argv;
+       p=(void*)(%s);
+       return 0;
+}
+'''
+SNIP_TYPE='''
+int main(int argc, char **argv) {
+       (void)argc; (void)argv;
+       if ((%(type_name)s *) 0) return 0;
+       if (sizeof (%(type_name)s)) return 0;
+       return 1;
+}
+'''
+SNIP_EMPTY_PROGRAM='''
+int main(int argc, char **argv) {
+       (void)argc; (void)argv;
+       return 0;
+}
+'''
+SNIP_FIELD='''
+int main(int argc, char **argv) {
+       char *off;
+       (void)argc; (void)argv;
+       off = (char*) &((%(type_name)s*)0)->%(field_name)s;
+       return (size_t) off < sizeof(%(type_name)s);
+}
+'''
+MACRO_TO_DESTOS={'__linux__':'linux','__GNU__':'gnu','__FreeBSD__':'freebsd','__NetBSD__':'netbsd','__OpenBSD__':'openbsd','__sun':'sunos','__hpux':'hpux','__sgi':'irix','_AIX':'aix','__CYGWIN__':'cygwin','__MSYS__':'msys','_UWIN':'uwin','_WIN64':'win32','_WIN32':'win32','__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__':'darwin','__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__':'darwin','__QNX__':'qnx','__native_client__':'nacl'}
+MACRO_TO_DEST_CPU={'__x86_64__':'x86_64','__amd64__':'x86_64','__i386__':'x86','__ia64__':'ia','__mips__':'mips','__sparc__':'sparc','__alpha__':'alpha','__aarch64__':'aarch64','__thumb__':'thumb','__arm__':'arm','__hppa__':'hppa','__powerpc__':'powerpc','__ppc__':'powerpc','__convex__':'convex','__m68k__':'m68k','__s390x__':'s390x','__s390__':'s390','__sh__':'sh',}
+@conf
+def parse_flags(self,line,uselib_store,env=None,force_static=False):
+       assert(isinstance(line,str))
+       env=env or self.env
+       app=env.append_value
+       appu=env.append_unique
+       lex=shlex.shlex(line,posix=False)
+       lex.whitespace_split=True
+       lex.commenters=''
+       lst=list(lex)
+       uselib=uselib_store
+       while lst:
+               x=lst.pop(0)
+               st=x[:2]
+               ot=x[2:]
+               if st=='-I'or st=='/I':
+                       if not ot:ot=lst.pop(0)
+                       appu('INCLUDES_'+uselib,[ot])
+               elif st=='-include':
+                       tmp=[x,lst.pop(0)]
+                       app('CFLAGS',tmp)
+                       app('CXXFLAGS',tmp)
+               elif st=='-D'or(env.CXX_NAME=='msvc'and st=='/D'):
+                       if not ot:ot=lst.pop(0)
+                       app('DEFINES_'+uselib,[ot])
+               elif st=='-l':
+                       if not ot:ot=lst.pop(0)
+                       prefix=force_static and'STLIB_'or'LIB_'
+                       appu(prefix+uselib,[ot])
+               elif st=='-L':
+                       if not ot:ot=lst.pop(0)
+                       appu('LIBPATH_'+uselib,[ot])
+               elif x.startswith('/LIBPATH:'):
+                       appu('LIBPATH_'+uselib,[x.replace('/LIBPATH:','')])
+               elif x=='-pthread'or x.startswith('+')or x.startswith('-std'):
+                       app('CFLAGS_'+uselib,[x])
+                       app('CXXFLAGS_'+uselib,[x])
+                       app('LINKFLAGS_'+uselib,[x])
+               elif x=='-framework':
+                       appu('FRAMEWORK_'+uselib,[lst.pop(0)])
+               elif x.startswith('-F'):
+                       appu('FRAMEWORKPATH_'+uselib,[x[2:]])
+               elif x.startswith('-Wl'):
+                       app('LINKFLAGS_'+uselib,[x])
+               elif x.startswith('-m')or x.startswith('-f')or x.startswith('-dynamic'):
+                       app('CFLAGS_'+uselib,[x])
+                       app('CXXFLAGS_'+uselib,[x])
+               elif x.startswith('-bundle'):
+                       app('LINKFLAGS_'+uselib,[x])
+               elif x.startswith('-undefined'):
+                       arg=lst.pop(0)
+                       app('LINKFLAGS_'+uselib,[x,arg])
+               elif x.startswith('-arch')or x.startswith('-isysroot'):
+                       tmp=[x,lst.pop(0)]
+                       app('CFLAGS_'+uselib,tmp)
+                       app('CXXFLAGS_'+uselib,tmp)
+                       app('LINKFLAGS_'+uselib,tmp)
+               elif x.endswith('.a')or x.endswith('.so')or x.endswith('.dylib')or x.endswith('.lib'):
+                       appu('LINKFLAGS_'+uselib,[x])
+@conf
+def ret_msg(self,f,kw):
+       if isinstance(f,str):
+               return f
+       return f(kw)
+@conf
+def validate_cfg(self,kw):
+       if not'path'in kw:
+               if not self.env.PKGCONFIG:
+                       self.find_program('pkg-config',var='PKGCONFIG')
+               kw['path']=self.env.PKGCONFIG
+       if'atleast_pkgconfig_version'in kw:
+               if not'msg'in kw:
+                       kw['msg']='Checking for pkg-config version >= %r'%kw['atleast_pkgconfig_version']
+               return
+       if not'okmsg'in kw:
+               kw['okmsg']='yes'
+       if not'errmsg'in kw:
+               kw['errmsg']='not found'
+       if'modversion'in kw:
+               if not'msg'in kw:
+                       kw['msg']='Checking for %r version'%kw['modversion']
+               return
+       for x in cfg_ver.keys():
+               y=x.replace('-','_')
+               if y in kw:
+                       if not'package'in kw:
+                               raise ValueError('%s requires a package'%x)
+                       if not'msg'in kw:
+                               kw['msg']='Checking for %r %s %s'%(kw['package'],cfg_ver[x],kw[y])
+                       return
+       if not'msg'in kw:
+               kw['msg']='Checking for %r'%(kw['package']or kw['path'])
+@conf
+def exec_cfg(self,kw):
+       def define_it():
+               self.define(self.have_define(kw.get('uselib_store',kw['package'])),1,0)
+       if'atleast_pkgconfig_version'in kw:
+               cmd=[kw['path'],'--atleast-pkgconfig-version=%s'%kw['atleast_pkgconfig_version']]
+               self.cmd_and_log(cmd)
+               if not'okmsg'in kw:
+                       kw['okmsg']='yes'
+               return
+       for x in cfg_ver:
+               y=x.replace('-','_')
+               if y in kw:
+                       self.cmd_and_log([kw['path'],'--%s=%s'%(x,kw[y]),kw['package']])
+                       if not'okmsg'in kw:
+                               kw['okmsg']='yes'
+                       define_it()
+                       break
+       if'modversion'in kw:
+               version=self.cmd_and_log([kw['path'],'--modversion',kw['modversion']]).strip()
+               self.define('%s_VERSION'%Utils.quote_define_name(kw.get('uselib_store',kw['modversion'])),version)
+               return version
+       lst=[kw['path']]
+       defi=kw.get('define_variable',None)
+       if not defi:
+               defi=self.env.PKG_CONFIG_DEFINES or{}
+       for key,val in defi.items():
+               lst.append('--define-variable=%s=%s'%(key,val))
+       if'variables'in kw:
+               env=kw.get('env',self.env)
+               uselib=kw.get('uselib_store',kw['package'].upper())
+               vars=Utils.to_list(kw['variables'])
+               for v in vars:
+                       val=self.cmd_and_log(lst+['--variable='+v]).strip()
+                       var='%s_%s'%(uselib,v)
+                       env[var]=val
+               if not'okmsg'in kw:
+                       kw['okmsg']='yes'
+               return
+       static=False
+       if'args'in kw:
+               args=Utils.to_list(kw['args'])
+               if'--static'in args or'--static-libs'in args:
+                       static=True
+               lst+=args
+       lst.extend(Utils.to_list(kw['package']))
+       ret=self.cmd_and_log(lst)
+       if not'okmsg'in kw:
+               kw['okmsg']='yes'
+       define_it()
+       self.parse_flags(ret,kw.get('uselib_store',kw['package'].upper()),kw.get('env',self.env),force_static=static)
+       return ret
+@conf
+def check_cfg(self,*k,**kw):
+       if k:
+               lst=k[0].split()
+               kw['package']=lst[0]
+               kw['args']=' '.join(lst[1:])
+       self.validate_cfg(kw)
+       if'msg'in kw:
+               self.start_msg(kw['msg'])
+       ret=None
+       try:
+               ret=self.exec_cfg(kw)
+       except self.errors.WafError:
+               if'errmsg'in kw:
+                       self.end_msg(kw['errmsg'],'YELLOW')
+               if Logs.verbose>1:
+                       raise
+               else:
+                       self.fatal('The configuration failed')
+       else:
+               kw['success']=ret
+               if'okmsg'in kw:
+                       self.end_msg(self.ret_msg(kw['okmsg'],kw))
+       return ret
+@conf
+def validate_c(self,kw):
+       if not'env'in kw:
+               kw['env']=self.env.derive()
+       env=kw['env']
+       if not'compiler'in kw and not'features'in kw:
+               kw['compiler']='c'
+               if env['CXX_NAME']and Task.classes.get('cxx',None):
+                       kw['compiler']='cxx'
+                       if not self.env['CXX']:
+                               self.fatal('a c++ compiler is required')
+               else:
+                       if not self.env['CC']:
+                               self.fatal('a c compiler is required')
+       if not'compile_mode'in kw:
+               kw['compile_mode']='c'
+               if'cxx'in Utils.to_list(kw.get('features',[]))or kw.get('compiler','')=='cxx':
+                       kw['compile_mode']='cxx'
+       if not'type'in kw:
+               kw['type']='cprogram'
+       if not'features'in kw:
+               kw['features']=[kw['compile_mode'],kw['type']]
+       else:
+               kw['features']=Utils.to_list(kw['features'])
+       if not'compile_filename'in kw:
+               kw['compile_filename']='test.c'+((kw['compile_mode']=='cxx')and'pp'or'')
+       def to_header(dct):
+               if'header_name'in dct:
+                       dct=Utils.to_list(dct['header_name'])
+                       return''.join(['#include <%s>\n'%x for x in dct])
+               return''
+       if'framework_name'in kw:
+               fwkname=kw['framework_name']
+               if not'uselib_store'in kw:
+                       kw['uselib_store']=fwkname.upper()
+               if not kw.get('no_header',False):
+                       if not'header_name'in kw:
+                               kw['header_name']=[]
+                       fwk='%s/%s.h'%(fwkname,fwkname)
+                       if kw.get('remove_dot_h',None):
+                               fwk=fwk[:-2]
+                       kw['header_name']=Utils.to_list(kw['header_name'])+[fwk]
+               kw['msg']='Checking for framework %s'%fwkname
+               kw['framework']=fwkname
+       if'function_name'in kw:
+               fu=kw['function_name']
+               if not'msg'in kw:
+                       kw['msg']='Checking for function %s'%fu
+               kw['code']=to_header(kw)+SNIP_FUNCTION%fu
+               if not'uselib_store'in kw:
+                       kw['uselib_store']=fu.upper()
+               if not'define_name'in kw:
+                       kw['define_name']=self.have_define(fu)
+       elif'type_name'in kw:
+               tu=kw['type_name']
+               if not'header_name'in kw:
+                       kw['header_name']='stdint.h'
+               if'field_name'in kw:
+                       field=kw['field_name']
+                       kw['code']=to_header(kw)+SNIP_FIELD%{'type_name':tu,'field_name':field}
+                       if not'msg'in kw:
+                               kw['msg']='Checking for field %s in %s'%(field,tu)
+                       if not'define_name'in kw:
+                               kw['define_name']=self.have_define((tu+'_'+field).upper())
+               else:
+                       kw['code']=to_header(kw)+SNIP_TYPE%{'type_name':tu}
+                       if not'msg'in kw:
+                               kw['msg']='Checking for type %s'%tu
+                       if not'define_name'in kw:
+                               kw['define_name']=self.have_define(tu.upper())
+       elif'header_name'in kw:
+               if not'msg'in kw:
+                       kw['msg']='Checking for header %s'%kw['header_name']
+               l=Utils.to_list(kw['header_name'])
+               assert len(l)>0,'list of headers in header_name is empty'
+               kw['code']=to_header(kw)+SNIP_EMPTY_PROGRAM
+               if not'uselib_store'in kw:
+                       kw['uselib_store']=l[0].upper()
+               if not'define_name'in kw:
+                       kw['define_name']=self.have_define(l[0])
+       if'lib'in kw:
+               if not'msg'in kw:
+                       kw['msg']='Checking for library %s'%kw['lib']
+               if not'uselib_store'in kw:
+                       kw['uselib_store']=kw['lib'].upper()
+       if'stlib'in kw:
+               if not'msg'in kw:
+                       kw['msg']='Checking for static library %s'%kw['stlib']
+               if not'uselib_store'in kw:
+                       kw['uselib_store']=kw['stlib'].upper()
+       if'fragment'in kw:
+               kw['code']=kw['fragment']
+               if not'msg'in kw:
+                       kw['msg']='Checking for code snippet'
+               if not'errmsg'in kw:
+                       kw['errmsg']='no'
+       for(flagsname,flagstype)in[('cxxflags','compiler'),('cflags','compiler'),('linkflags','linker')]:
+               if flagsname in kw:
+                       if not'msg'in kw:
+                               kw['msg']='Checking for %s flags %s'%(flagstype,kw[flagsname])
+                       if not'errmsg'in kw:
+                               kw['errmsg']='no'
+       if not'execute'in kw:
+               kw['execute']=False
+       if kw['execute']:
+               kw['features'].append('test_exec')
+       if not'errmsg'in kw:
+               kw['errmsg']='not found'
+       if not'okmsg'in kw:
+               kw['okmsg']='yes'
+       if not'code'in kw:
+               kw['code']=SNIP_EMPTY_PROGRAM
+       if self.env[INCKEYS]:
+               kw['code']='\n'.join(['#include <%s>'%x for x in self.env[INCKEYS]])+'\n'+kw['code']
+       if not kw.get('success'):kw['success']=None
+       if'define_name'in kw:
+               self.undefine(kw['define_name'])
+       assert'msg'in kw,'invalid parameters, read http://freehackers.org/~tnagy/wafbook/single.html#config_helpers_c'
+@conf
+def post_check(self,*k,**kw):
+       is_success=0
+       if kw['execute']:
+               if kw['success']is not None:
+                       if kw.get('define_ret',False):
+                               is_success=kw['success']
+                       else:
+                               is_success=(kw['success']==0)
+       else:
+               is_success=(kw['success']==0)
+       if'define_name'in kw:
+               if'header_name'in kw or'function_name'in kw or'type_name'in kw or'fragment'in kw:
+                       if kw['execute']and kw.get('define_ret',None)and isinstance(is_success,str):
+                               self.define(kw['define_name'],is_success,quote=kw.get('quote',1))
+                       else:
+                               self.define_cond(kw['define_name'],is_success)
+               else:
+                       self.define_cond(kw['define_name'],is_success)
+       if'header_name'in kw:
+               if kw.get('auto_add_header_name',False):
+                       self.env.append_value(INCKEYS,Utils.to_list(kw['header_name']))
+       if is_success and'uselib_store'in kw:
+               from waflib.Tools import ccroot
+               _vars=set([])
+               for x in kw['features']:
+                       if x in ccroot.USELIB_VARS:
+                               _vars|=ccroot.USELIB_VARS[x]
+               for k in _vars:
+                       lk=k.lower()
+                       if k=='INCLUDES':lk='includes'
+                       if k=='DEFINES':lk='defines'
+                       if lk in kw:
+                               val=kw[lk]
+                               if isinstance(val,str):
+                                       val=val.rstrip(os.path.sep)
+                               self.env.append_unique(k+'_'+kw['uselib_store'],val)
+       return is_success
+@conf
+def check(self,*k,**kw):
+       self.validate_c(kw)
+       self.start_msg(kw['msg'])
+       ret=None
+       try:
+               ret=self.run_c_code(*k,**kw)
+       except self.errors.ConfigurationError:
+               self.end_msg(kw['errmsg'],'YELLOW')
+               if Logs.verbose>1:
+                       raise
+               else:
+                       self.fatal('The configuration failed')
+       else:
+               kw['success']=ret
+       ret=self.post_check(*k,**kw)
+       if not ret:
+               self.end_msg(kw['errmsg'],'YELLOW')
+               self.fatal('The configuration failed %r'%ret)
+       else:
+               self.end_msg(self.ret_msg(kw['okmsg'],kw))
+       return ret
+class test_exec(Task.Task):
+       color='PINK'
+       def run(self):
+               if getattr(self.generator,'rpath',None):
+                       if getattr(self.generator,'define_ret',False):
+                               self.generator.bld.retval=self.generator.bld.cmd_and_log([self.inputs[0].abspath()])
+                       else:
+                               self.generator.bld.retval=self.generator.bld.exec_command([self.inputs[0].abspath()])
+               else:
+                       env=self.env.env or{}
+                       env.update(dict(os.environ))
+                       for var in('LD_LIBRARY_PATH','DYLD_LIBRARY_PATH','PATH'):
+                               env[var]=self.inputs[0].parent.abspath()+os.path.pathsep+env.get(var,'')
+                       if getattr(self.generator,'define_ret',False):
+                               self.generator.bld.retval=self.generator.bld.cmd_and_log([self.inputs[0].abspath()],env=env)
+                       else:
+                               self.generator.bld.retval=self.generator.bld.exec_command([self.inputs[0].abspath()],env=env)
+@feature('test_exec')
+@after_method('apply_link')
+def test_exec_fun(self):
+       self.create_task('test_exec',self.link_task.outputs[0])
+CACHE_RESULTS=1
+COMPILE_ERRORS=2
+@conf
+def run_c_code(self,*k,**kw):
+       lst=[str(v)for(p,v)in kw.items()if p!='env']
+       h=Utils.h_list(lst)
+       dir=self.bldnode.abspath()+os.sep+(not Utils.is_win32 and'.'or'')+'conf_check_'+Utils.to_hex(h)
+       try:
+               os.makedirs(dir)
+       except OSError:
+               pass
+       try:
+               os.stat(dir)
+       except OSError:
+               self.fatal('cannot use the configuration test folder %r'%dir)
+       cachemode=getattr(Options.options,'confcache',None)
+       if cachemode==CACHE_RESULTS:
+               try:
+                       proj=ConfigSet.ConfigSet(os.path.join(dir,'cache_run_c_code'))
+               except OSError:
+                       pass
+               else:
+                       ret=proj['cache_run_c_code']
+                       if isinstance(ret,str)and ret.startswith('Test does not build'):
+                               self.fatal(ret)
+                       return ret
+       bdir=os.path.join(dir,'testbuild')
+       if not os.path.exists(bdir):
+               os.makedirs(bdir)
+       self.test_bld=bld=Build.BuildContext(top_dir=dir,out_dir=bdir)
+       bld.init_dirs()
+       bld.progress_bar=0
+       bld.targets='*'
+       if kw['compile_filename']:
+               node=bld.srcnode.make_node(kw['compile_filename'])
+               node.write(kw['code'])
+       bld.logger=self.logger
+       bld.all_envs.update(self.all_envs)
+       bld.env=kw['env']
+       o=bld(features=kw['features'],source=kw['compile_filename'],target='testprog')
+       for k,v in kw.items():
+               setattr(o,k,v)
+       self.to_log("==>\n%s\n<=="%kw['code'])
+       bld.targets='*'
+       ret=-1
+       try:
+               try:
+                       bld.compile()
+               except Errors.WafError:
+                       ret='Test does not build: %s'%Utils.ex_stack()
+                       self.fatal(ret)
+               else:
+                       ret=getattr(bld,'retval',0)
+       finally:
+               proj=ConfigSet.ConfigSet()
+               proj['cache_run_c_code']=ret
+               proj.store(os.path.join(dir,'cache_run_c_code'))
+       return ret
+@conf
+def check_cxx(self,*k,**kw):
+       kw['compiler']='cxx'
+       return self.check(*k,**kw)
+@conf
+def check_cc(self,*k,**kw):
+       kw['compiler']='c'
+       return self.check(*k,**kw)
+@conf
+def define(self,key,val,quote=True):
+       assert key and isinstance(key,str)
+       if val is True:
+               val=1
+       elif val in(False,None):
+               val=0
+       if isinstance(val,int)or isinstance(val,float):
+               s='%s=%s'
+       else:
+               s=quote and'%s="%s"'or'%s=%s'
+       app=s%(key,str(val))
+       ban=key+'='
+       lst=self.env['DEFINES']
+       for x in lst:
+               if x.startswith(ban):
+                       lst[lst.index(x)]=app
+                       break
+       else:
+               self.env.append_value('DEFINES',app)
+       self.env.append_unique(DEFKEYS,key)
+@conf
+def undefine(self,key):
+       assert key and isinstance(key,str)
+       ban=key+'='
+       lst=[x for x in self.env['DEFINES']if not x.startswith(ban)]
+       self.env['DEFINES']=lst
+       self.env.append_unique(DEFKEYS,key)
+@conf
+def define_cond(self,key,val):
+       assert key and isinstance(key,str)
+       if val:
+               self.define(key,1)
+       else:
+               self.undefine(key)
+@conf
+def is_defined(self,key):
+       assert key and isinstance(key,str)
+       ban=key+'='
+       for x in self.env['DEFINES']:
+               if x.startswith(ban):
+                       return True
+       return False
+@conf
+def get_define(self,key):
+       assert key and isinstance(key,str)
+       ban=key+'='
+       for x in self.env['DEFINES']:
+               if x.startswith(ban):
+                       return x[len(ban):]
+       return None
+@conf
+def have_define(self,key):
+       return(self.env.HAVE_PAT or'HAVE_%s')%Utils.quote_define_name(key)
+@conf
+def write_config_header(self,configfile='',guard='',top=False,env=None,defines=True,headers=False,remove=True,define_prefix=''):
+       if env:
+               Logs.warn('Cannot pass env to write_config_header')
+       if not configfile:configfile=WAF_CONFIG_H
+       waf_guard=guard or'W_%s_WAF'%Utils.quote_define_name(configfile)
+       node=top and self.bldnode or self.path.get_bld()
+       node=node.make_node(configfile)
+       node.parent.mkdir()
+       lst=['/* WARNING! All changes made to this file will be lost! */\n']
+       lst.append('#ifndef %s\n#define %s\n'%(waf_guard,waf_guard))
+       lst.append(self.get_config_header(defines,headers,define_prefix=define_prefix))
+       lst.append('\n#endif /* %s */\n'%waf_guard)
+       node.write('\n'.join(lst))
+       self.env.append_unique(Build.CFG_FILES,[node.abspath()])
+       if remove:
+               for key in self.env[DEFKEYS]:
+                       self.undefine(key)
+               self.env[DEFKEYS]=[]
+@conf
+def get_config_header(self,defines=True,headers=False,define_prefix=''):
+       lst=[]
+       if headers:
+               for x in self.env[INCKEYS]:
+                       lst.append('#include <%s>'%x)
+       if defines:
+               for x in self.env[DEFKEYS]:
+                       if self.is_defined(x):
+                               val=self.get_define(x)
+                               lst.append('#define %s %s'%(define_prefix+x,val))
+                       else:
+                               lst.append('/* #undef %s */'%(define_prefix+x))
+       return"\n".join(lst)
+@conf
+def cc_add_flags(conf):
+       conf.add_os_flags('CPPFLAGS','CFLAGS')
+       conf.add_os_flags('CFLAGS')
+@conf
+def cxx_add_flags(conf):
+       conf.add_os_flags('CPPFLAGS','CXXFLAGS')
+       conf.add_os_flags('CXXFLAGS')
+@conf
+def link_add_flags(conf):
+       conf.add_os_flags('LINKFLAGS')
+       conf.add_os_flags('LDFLAGS','LINKFLAGS')
+@conf
+def cc_load_tools(conf):
+       if not conf.env.DEST_OS:
+               conf.env.DEST_OS=Utils.unversioned_sys_platform()
+       conf.load('c')
+@conf
+def cxx_load_tools(conf):
+       if not conf.env.DEST_OS:
+               conf.env.DEST_OS=Utils.unversioned_sys_platform()
+       conf.load('cxx')
+@conf
+def get_cc_version(conf,cc,gcc=False,icc=False):
+       cmd=cc+['-dM','-E','-']
+       env=conf.env.env or None
+       try:
+               p=Utils.subprocess.Popen(cmd,stdin=Utils.subprocess.PIPE,stdout=Utils.subprocess.PIPE,stderr=Utils.subprocess.PIPE,env=env)
+               p.stdin.write('\n')
+               out=p.communicate()[0]
+       except Exception:
+               conf.fatal('Could not determine the compiler version %r'%cmd)
+       if not isinstance(out,str):
+               out=out.decode(sys.stdout.encoding or'iso8859-1')
+       if gcc:
+               if out.find('__INTEL_COMPILER')>=0:
+                       conf.fatal('The intel compiler pretends to be gcc')
+               if out.find('__GNUC__')<0 and out.find('__clang__')<0:
+                       conf.fatal('Could not determine the compiler type')
+       if icc and out.find('__INTEL_COMPILER')<0:
+               conf.fatal('Not icc/icpc')
+       k={}
+       if icc or gcc:
+               out=out.splitlines()
+               for line in out:
+                       lst=shlex.split(line)
+                       if len(lst)>2:
+                               key=lst[1]
+                               val=lst[2]
+                               k[key]=val
+               def isD(var):
+                       return var in k
+               def isT(var):
+                       return var in k and k[var]!='0'
+               if not conf.env.DEST_OS:
+                       conf.env.DEST_OS=''
+               for i in MACRO_TO_DESTOS:
+                       if isD(i):
+                               conf.env.DEST_OS=MACRO_TO_DESTOS[i]
+                               break
+               else:
+                       if isD('__APPLE__')and isD('__MACH__'):
+                               conf.env.DEST_OS='darwin'
+                       elif isD('__unix__'):
+                               conf.env.DEST_OS='generic'
+               if isD('__ELF__'):
+                       conf.env.DEST_BINFMT='elf'
+               elif isD('__WINNT__')or isD('__CYGWIN__')or isD('_WIN32'):
+                       conf.env.DEST_BINFMT='pe'
+                       conf.env.LIBDIR=conf.env.BINDIR
+               elif isD('__APPLE__'):
+                       conf.env.DEST_BINFMT='mac-o'
+               if not conf.env.DEST_BINFMT:
+                       conf.env.DEST_BINFMT=Utils.destos_to_binfmt(conf.env.DEST_OS)
+               for i in MACRO_TO_DEST_CPU:
+                       if isD(i):
+                               conf.env.DEST_CPU=MACRO_TO_DEST_CPU[i]
+                               break
+               Logs.debug('ccroot: dest platform: '+' '.join([conf.env[x]or'?'for x in('DEST_OS','DEST_BINFMT','DEST_CPU')]))
+               if icc:
+                       ver=k['__INTEL_COMPILER']
+                       conf.env['CC_VERSION']=(ver[:-2],ver[-2],ver[-1])
+               else:
+                       if isD('__clang__'):
+                               conf.env['CC_VERSION']=(k['__clang_major__'],k['__clang_minor__'],k['__clang_patchlevel__'])
+                       else:
+                               conf.env['CC_VERSION']=(k['__GNUC__'],k['__GNUC_MINOR__'],k['__GNUC_PATCHLEVEL__'])
+       return k
+@conf
+def get_xlc_version(conf,cc):
+       cmd=cc+['-qversion']
+       try:
+               out,err=conf.cmd_and_log(cmd,output=0)
+       except Errors.WafError:
+               conf.fatal('Could not find xlc %r'%cmd)
+       for v in(r"IBM XL C/C\+\+.* V(?P<major>\d*)\.(?P<minor>\d*)",):
+               version_re=re.compile(v,re.I).search
+               match=version_re(out or err)
+               if match:
+                       k=match.groupdict()
+                       conf.env['CC_VERSION']=(k['major'],k['minor'])
+                       break
+       else:
+               conf.fatal('Could not determine the XLC version.')
+@conf
+def get_suncc_version(conf,cc):
+       cmd=cc+['-V']
+       try:
+               out,err=conf.cmd_and_log(cmd,output=0)
+       except Errors.WafError:
+               conf.fatal('Could not find suncc %r'%cmd)
+       version=(out or err)
+       version=version.split('\n')[0]
+       version_re=re.compile(r'cc:\s+sun\s+(c\+\+|c)\s+(?P<major>\d*)\.(?P<minor>\d*)',re.I).search
+       match=version_re(version)
+       if match:
+               k=match.groupdict()
+               conf.env['CC_VERSION']=(k['major'],k['minor'])
+       else:
+               conf.fatal('Could not determine the suncc version.')
+@conf
+def add_as_needed(self):
+       if self.env.DEST_BINFMT=='elf'and'gcc'in(self.env.CXX_NAME,self.env.CC_NAME):
+               self.env.append_unique('LINKFLAGS','--as-needed')
+class cfgtask(Task.TaskBase):
+       def display(self):
+               return''
+       def runnable_status(self):
+               return Task.RUN_ME
+       def uid(self):
+               return Utils.SIG_NIL
+       def run(self):
+               conf=self.conf
+               bld=Build.BuildContext(top_dir=conf.srcnode.abspath(),out_dir=conf.bldnode.abspath())
+               bld.env=conf.env
+               bld.init_dirs()
+               bld.in_msg=1
+               bld.logger=self.logger
+               try:
+                       bld.check(**self.args)
+               except Exception:
+                       return 1
+@conf
+def multicheck(self,*k,**kw):
+       self.start_msg(kw.get('msg','Executing %d configuration tests'%len(k)))
+       class par(object):
+               def __init__(self):
+                       self.keep=False
+                       self.cache_global=Options.cache_global
+                       self.nocache=Options.options.nocache
+                       self.returned_tasks=[]
+                       self.task_sigs={}
+               def total(self):
+                       return len(tasks)
+               def to_log(self,*k,**kw):
+                       return
+       bld=par()
+       tasks=[]
+       for dct in k:
+               x=cfgtask(bld=bld)
+               tasks.append(x)
+               x.args=dct
+               x.bld=bld
+               x.conf=self
+               x.args=dct
+               x.logger=Logs.make_mem_logger(str(id(x)),self.logger)
+       def it():
+               yield tasks
+               while 1:
+                       yield[]
+       p=Runner.Parallel(bld,Options.options.jobs)
+       p.biter=it()
+       p.start()
+       for x in tasks:
+               x.logger.memhandler.flush()
+       for x in tasks:
+               if x.hasrun!=Task.SUCCESS:
+                       self.end_msg(kw.get('errmsg','no'),color='YELLOW')
+                       self.fatal(kw.get('fatalmsg',None)or'One of the tests has failed, see the config.log for more information')
+       self.end_msg('ok')
diff --git a/waflib/Tools/c_config.pyc b/waflib/Tools/c_config.pyc
new file mode 100644 (file)
index 0000000..2d100b2
Binary files /dev/null and b/waflib/Tools/c_config.pyc differ
diff --git a/waflib/Tools/c_osx.py b/waflib/Tools/c_osx.py
new file mode 100644 (file)
index 0000000..579b2a7
--- /dev/null
@@ -0,0 +1,120 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import os,shutil,sys,platform
+from waflib import TaskGen,Task,Build,Options,Utils,Errors
+from waflib.TaskGen import taskgen_method,feature,after_method,before_method
+app_info='''
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>CFBundlePackageType</key>
+       <string>APPL</string>
+       <key>CFBundleGetInfoString</key>
+       <string>Created by Waf</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>NOTE</key>
+       <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
+       <key>CFBundleExecutable</key>
+       <string>%s</string>
+</dict>
+</plist>
+'''
+@feature('c','cxx')
+def set_macosx_deployment_target(self):
+       if self.env['MACOSX_DEPLOYMENT_TARGET']:
+               os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env['MACOSX_DEPLOYMENT_TARGET']
+       elif'MACOSX_DEPLOYMENT_TARGET'not in os.environ:
+               if Utils.unversioned_sys_platform()=='darwin':
+                       os.environ['MACOSX_DEPLOYMENT_TARGET']='.'.join(platform.mac_ver()[0].split('.')[:2])
+@taskgen_method
+def create_bundle_dirs(self,name,out):
+       bld=self.bld
+       dir=out.parent.find_or_declare(name)
+       dir.mkdir()
+       macos=dir.find_or_declare(['Contents','MacOS'])
+       macos.mkdir()
+       return dir
+def bundle_name_for_output(out):
+       name=out.name
+       k=name.rfind('.')
+       if k>=0:
+               name=name[:k]+'.app'
+       else:
+               name=name+'.app'
+       return name
+@feature('cprogram','cxxprogram')
+@after_method('apply_link')
+def create_task_macapp(self):
+       if self.env['MACAPP']or getattr(self,'mac_app',False):
+               out=self.link_task.outputs[0]
+               name=bundle_name_for_output(out)
+               dir=self.create_bundle_dirs(name,out)
+               n1=dir.find_or_declare(['Contents','MacOS',out.name])
+               self.apptask=self.create_task('macapp',self.link_task.outputs,n1)
+               inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/MacOS/'%name
+               self.bld.install_files(inst_to,n1,chmod=Utils.O755)
+               if getattr(self,'mac_resources',None):
+                       res_dir=n1.parent.parent.make_node('Resources')
+                       inst_to=getattr(self,'install_path','/Applications')+'/%s/Resources'%name
+                       for x in self.to_list(self.mac_resources):
+                               node=self.path.find_node(x)
+                               if not node:
+                                       raise Errors.WafError('Missing mac_resource %r in %r'%(x,self))
+                               parent=node.parent
+                               if os.path.isdir(node.abspath()):
+                                       nodes=node.ant_glob('**')
+                               else:
+                                       nodes=[node]
+                               for node in nodes:
+                                       rel=node.path_from(parent)
+                                       tsk=self.create_task('macapp',node,res_dir.make_node(rel))
+                                       self.bld.install_as(inst_to+'/%s'%rel,node)
+               if getattr(self.bld,'is_install',None):
+                       self.install_task.hasrun=Task.SKIP_ME
+@feature('cprogram','cxxprogram')
+@after_method('apply_link')
+def create_task_macplist(self):
+       if self.env['MACAPP']or getattr(self,'mac_app',False):
+               out=self.link_task.outputs[0]
+               name=bundle_name_for_output(out)
+               dir=self.create_bundle_dirs(name,out)
+               n1=dir.find_or_declare(['Contents','Info.plist'])
+               self.plisttask=plisttask=self.create_task('macplist',[],n1)
+               if getattr(self,'mac_plist',False):
+                       node=self.path.find_resource(self.mac_plist)
+                       if node:
+                               plisttask.inputs.append(node)
+                       else:
+                               plisttask.code=self.mac_plist
+               else:
+                       plisttask.code=app_info%self.link_task.outputs[0].name
+               inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/'%name
+               self.bld.install_files(inst_to,n1)
+@feature('cshlib','cxxshlib')
+@before_method('apply_link','propagate_uselib_vars')
+def apply_bundle(self):
+       if self.env['MACBUNDLE']or getattr(self,'mac_bundle',False):
+               self.env['LINKFLAGS_cshlib']=self.env['LINKFLAGS_cxxshlib']=[]
+               self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN']
+               use=self.use=self.to_list(getattr(self,'use',[]))
+               if not'MACBUNDLE'in use:
+                       use.append('MACBUNDLE')
+app_dirs=['Contents','Contents/MacOS','Contents/Resources']
+class macapp(Task.Task):
+       color='PINK'
+       def run(self):
+               self.outputs[0].parent.mkdir()
+               shutil.copy2(self.inputs[0].srcpath(),self.outputs[0].abspath())
+class macplist(Task.Task):
+       color='PINK'
+       ext_in=['.bin']
+       def run(self):
+               if getattr(self,'code',None):
+                       txt=self.code
+               else:
+                       txt=self.inputs[0].read()
+               self.outputs[0].write(txt)
diff --git a/waflib/Tools/c_osx.pyc b/waflib/Tools/c_osx.pyc
new file mode 100644 (file)
index 0000000..7a2f361
Binary files /dev/null and b/waflib/Tools/c_osx.pyc differ
diff --git a/waflib/Tools/c_preproc.py b/waflib/Tools/c_preproc.py
new file mode 100644 (file)
index 0000000..dc6453b
--- /dev/null
@@ -0,0 +1,604 @@
+#! /usr/bin/env python
+# encoding: utf-8
+# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
+
+import re,string,traceback
+from waflib import Logs,Utils,Errors
+from waflib.Logs import debug,error
+class PreprocError(Errors.WafError):
+       pass
+POPFILE='-'
+recursion_limit=150
+go_absolute=False
+standard_includes=['/usr/include']
+if Utils.is_win32:
+       standard_includes=[]
+use_trigraphs=0
+strict_quotes=0
+g_optrans={'not':'!','and':'&&','bitand':'&','and_eq':'&=','or':'||','bitor':'|','or_eq':'|=','xor':'^','xor_eq':'^=','compl':'~',}
+re_lines=re.compile('^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*)\r*$',re.IGNORECASE|re.MULTILINE)
+re_mac=re.compile("^[a-zA-Z_]\w*")
+re_fun=re.compile('^[a-zA-Z_][a-zA-Z0-9_]*[(]')
+re_pragma_once=re.compile('^\s*once\s*',re.IGNORECASE)
+re_nl=re.compile('\\\\\r*\n',re.MULTILINE)
+re_cpp=re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',re.DOTALL|re.MULTILINE)
+trig_def=[('??'+a,b)for a,b in zip("=-/!'()<>",r'#~\|^[]{}')]
+chr_esc={'0':0,'a':7,'b':8,'t':9,'n':10,'f':11,'v':12,'r':13,'\\':92,"'":39}
+NUM='i'
+OP='O'
+IDENT='T'
+STR='s'
+CHAR='c'
+tok_types=[NUM,STR,IDENT,OP]
+exp_types=[r"""0[xX](?P<hex>[a-fA-F0-9]+)(?P<qual1>[uUlL]*)|L*?'(?P<char>(\\.|[^\\'])+)'|(?P<n1>\d+)[Ee](?P<exp0>[+-]*?\d+)(?P<float0>[fFlL]*)|(?P<n2>\d*\.\d+)([Ee](?P<exp1>[+-]*?\d+))?(?P<float1>[fFlL]*)|(?P<n4>\d+\.\d*)([Ee](?P<exp2>[+-]*?\d+))?(?P<float2>[fFlL]*)|(?P<oct>0*)(?P<n0>\d+)(?P<qual2>[uUlL]*)""",r'L?"([^"\\]|\\.)*"',r'[a-zA-Z_]\w*',r'%:%:|<<=|>>=|\.\.\.|<<|<%|<:|<=|>>|>=|\+\+|\+=|--|->|-=|\*=|/=|%:|%=|%>|==|&&|&=|\|\||\|=|\^=|:>|!=|##|[\(\)\{\}\[\]<>\?\|\^\*\+&=:!#;,%/\-\?\~\.]',]
+re_clexer=re.compile('|'.join(["(?P<%s>%s)"%(name,part)for name,part in zip(tok_types,exp_types)]),re.M)
+accepted='a'
+ignored='i'
+undefined='u'
+skipped='s'
+def repl(m):
+       s=m.group(0)
+       if s.startswith('/'):
+               return' '
+       return s
+def filter_comments(filename):
+       code=Utils.readf(filename)
+       if use_trigraphs:
+               for(a,b)in trig_def:code=code.split(a).join(b)
+       code=re_nl.sub('',code)
+       code=re_cpp.sub(repl,code)
+       return[(m.group(2),m.group(3))for m in re.finditer(re_lines,code)]
+prec={}
+ops=['* / %','+ -','<< >>','< <= >= >','== !=','& | ^','&& ||',',']
+for x in range(len(ops)):
+       syms=ops[x]
+       for u in syms.split():
+               prec[u]=x
+def trimquotes(s):
+       if not s:return''
+       s=s.rstrip()
+       if s[0]=="'"and s[-1]=="'":return s[1:-1]
+       return s
+def reduce_nums(val_1,val_2,val_op):
+       try:a=0+val_1
+       except TypeError:a=int(val_1)
+       try:b=0+val_2
+       except TypeError:b=int(val_2)
+       d=val_op
+       if d=='%':c=a%b
+       elif d=='+':c=a+b
+       elif d=='-':c=a-b
+       elif d=='*':c=a*b
+       elif d=='/':c=a/b
+       elif d=='^':c=a^b
+       elif d=='|':c=a|b
+       elif d=='||':c=int(a or b)
+       elif d=='&':c=a&b
+       elif d=='&&':c=int(a and b)
+       elif d=='==':c=int(a==b)
+       elif d=='!=':c=int(a!=b)
+       elif d=='<=':c=int(a<=b)
+       elif d=='<':c=int(a<b)
+       elif d=='>':c=int(a>b)
+       elif d=='>=':c=int(a>=b)
+       elif d=='^':c=int(a^b)
+       elif d=='<<':c=a<<b
+       elif d=='>>':c=a>>b
+       else:c=0
+       return c
+def get_num(lst):
+       if not lst:raise PreprocError("empty list for get_num")
+       (p,v)=lst[0]
+       if p==OP:
+               if v=='(':
+                       count_par=1
+                       i=1
+                       while i<len(lst):
+                               (p,v)=lst[i]
+                               if p==OP:
+                                       if v==')':
+                                               count_par-=1
+                                               if count_par==0:
+                                                       break
+                                       elif v=='(':
+                                               count_par+=1
+                               i+=1
+                       else:
+                               raise PreprocError("rparen expected %r"%lst)
+                       (num,_)=get_term(lst[1:i])
+                       return(num,lst[i+1:])
+               elif v=='+':
+                       return get_num(lst[1:])
+               elif v=='-':
+                       num,lst=get_num(lst[1:])
+                       return(reduce_nums('-1',num,'*'),lst)
+               elif v=='!':
+                       num,lst=get_num(lst[1:])
+                       return(int(not int(num)),lst)
+               elif v=='~':
+                       num,lst=get_num(lst[1:])
+                       return(~int(num),lst)
+               else:
+                       raise PreprocError("Invalid op token %r for get_num"%lst)
+       elif p==NUM:
+               return v,lst[1:]
+       elif p==IDENT:
+               return 0,lst[1:]
+       else:
+               raise PreprocError("Invalid token %r for get_num"%lst)
+def get_term(lst):
+       if not lst:raise PreprocError("empty list for get_term")
+       num,lst=get_num(lst)
+       if not lst:
+               return(num,[])
+       (p,v)=lst[0]
+       if p==OP:
+               if v==',':
+                       return get_term(lst[1:])
+               elif v=='?':
+                       count_par=0
+                       i=1
+                       while i<len(lst):
+                               (p,v)=lst[i]
+                               if p==OP:
+                                       if v==')':
+                                               count_par-=1
+                                       elif v=='(':
+                                               count_par+=1
+                                       elif v==':':
+                                               if count_par==0:
+                                                       break
+                               i+=1
+                       else:
+                               raise PreprocError("rparen expected %r"%lst)
+                       if int(num):
+                               return get_term(lst[1:i])
+                       else:
+                               return get_term(lst[i+1:])
+               else:
+                       num2,lst=get_num(lst[1:])
+                       if not lst:
+                               num2=reduce_nums(num,num2,v)
+                               return get_term([(NUM,num2)]+lst)
+                       p2,v2=lst[0]
+                       if p2!=OP:
+                               raise PreprocError("op expected %r"%lst)
+                       if prec[v2]>=prec[v]:
+                               num2=reduce_nums(num,num2,v)
+                               return get_term([(NUM,num2)]+lst)
+                       else:
+                               num3,lst=get_num(lst[1:])
+                               num3=reduce_nums(num2,num3,v2)
+                               return get_term([(NUM,num),(p,v),(NUM,num3)]+lst)
+       raise PreprocError("cannot reduce %r"%lst)
+def reduce_eval(lst):
+       num,lst=get_term(lst)
+       return(NUM,num)
+def stringize(lst):
+       lst=[str(v2)for(p2,v2)in lst]
+       return"".join(lst)
+def paste_tokens(t1,t2):
+       p1=None
+       if t1[0]==OP and t2[0]==OP:
+               p1=OP
+       elif t1[0]==IDENT and(t2[0]==IDENT or t2[0]==NUM):
+               p1=IDENT
+       elif t1[0]==NUM and t2[0]==NUM:
+               p1=NUM
+       if not p1:
+               raise PreprocError('tokens do not make a valid paste %r and %r'%(t1,t2))
+       return(p1,t1[1]+t2[1])
+def reduce_tokens(lst,defs,ban=[]):
+       i=0
+       while i<len(lst):
+               (p,v)=lst[i]
+               if p==IDENT and v=="defined":
+                       del lst[i]
+                       if i<len(lst):
+                               (p2,v2)=lst[i]
+                               if p2==IDENT:
+                                       if v2 in defs:
+                                               lst[i]=(NUM,1)
+                                       else:
+                                               lst[i]=(NUM,0)
+                               elif p2==OP and v2=='(':
+                                       del lst[i]
+                                       (p2,v2)=lst[i]
+                                       del lst[i]
+                                       if v2 in defs:
+                                               lst[i]=(NUM,1)
+                                       else:
+                                               lst[i]=(NUM,0)
+                               else:
+                                       raise PreprocError("Invalid define expression %r"%lst)
+               elif p==IDENT and v in defs:
+                       if isinstance(defs[v],str):
+                               a,b=extract_macro(defs[v])
+                               defs[v]=b
+                       macro_def=defs[v]
+                       to_add=macro_def[1]
+                       if isinstance(macro_def[0],list):
+                               del lst[i]
+                               accu=to_add[:]
+                               reduce_tokens(accu,defs,ban+[v])
+                               for x in range(len(accu)):
+                                       lst.insert(i,accu[x])
+                                       i+=1
+                       else:
+                               args=[]
+                               del lst[i]
+                               if i>=len(lst):
+                                       raise PreprocError("expected '(' after %r (got nothing)"%v)
+                               (p2,v2)=lst[i]
+                               if p2!=OP or v2!='(':
+                                       raise PreprocError("expected '(' after %r"%v)
+                               del lst[i]
+                               one_param=[]
+                               count_paren=0
+                               while i<len(lst):
+                                       p2,v2=lst[i]
+                                       del lst[i]
+                                       if p2==OP and count_paren==0:
+                                               if v2=='(':
+                                                       one_param.append((p2,v2))
+                                                       count_paren+=1
+                                               elif v2==')':
+                                                       if one_param:args.append(one_param)
+                                                       break
+                                               elif v2==',':
+                                                       if not one_param:raise PreprocError("empty param in funcall %s"%p)
+                                                       args.append(one_param)
+                                                       one_param=[]
+                                               else:
+                                                       one_param.append((p2,v2))
+                                       else:
+                                               one_param.append((p2,v2))
+                                               if v2=='(':count_paren+=1
+                                               elif v2==')':count_paren-=1
+                               else:
+                                       raise PreprocError('malformed macro')
+                               accu=[]
+                               arg_table=macro_def[0]
+                               j=0
+                               while j<len(to_add):
+                                       (p2,v2)=to_add[j]
+                                       if p2==OP and v2=='#':
+                                               if j+1<len(to_add)and to_add[j+1][0]==IDENT and to_add[j+1][1]in arg_table:
+                                                       toks=args[arg_table[to_add[j+1][1]]]
+                                                       accu.append((STR,stringize(toks)))
+                                                       j+=1
+                                               else:
+                                                       accu.append((p2,v2))
+                                       elif p2==OP and v2=='##':
+                                               if accu and j+1<len(to_add):
+                                                       t1=accu[-1]
+                                                       if to_add[j+1][0]==IDENT and to_add[j+1][1]in arg_table:
+                                                               toks=args[arg_table[to_add[j+1][1]]]
+                                                               if toks:
+                                                                       accu[-1]=paste_tokens(t1,toks[0])
+                                                                       accu.extend(toks[1:])
+                                                               else:
+                                                                       accu.append((p2,v2))
+                                                                       accu.extend(toks)
+                                                       elif to_add[j+1][0]==IDENT and to_add[j+1][1]=='__VA_ARGS__':
+                                                               va_toks=[]
+                                                               st=len(macro_def[0])
+                                                               pt=len(args)
+                                                               for x in args[pt-st+1:]:
+                                                                       va_toks.extend(x)
+                                                                       va_toks.append((OP,','))
+                                                               if va_toks:va_toks.pop()
+                                                               if len(accu)>1:
+                                                                       (p3,v3)=accu[-1]
+                                                                       (p4,v4)=accu[-2]
+                                                                       if v3=='##':
+                                                                               accu.pop()
+                                                                               if v4==','and pt<st:
+                                                                                       accu.pop()
+                                                               accu+=va_toks
+                                                       else:
+                                                               accu[-1]=paste_tokens(t1,to_add[j+1])
+                                                       j+=1
+                                               else:
+                                                       accu.append((p2,v2))
+                                       elif p2==IDENT and v2 in arg_table:
+                                               toks=args[arg_table[v2]]
+                                               reduce_tokens(toks,defs,ban+[v])
+                                               accu.extend(toks)
+                                       else:
+                                               accu.append((p2,v2))
+                                       j+=1
+                               reduce_tokens(accu,defs,ban+[v])
+                               for x in range(len(accu)-1,-1,-1):
+                                       lst.insert(i,accu[x])
+               i+=1
+def eval_macro(lst,defs):
+       reduce_tokens(lst,defs,[])
+       if not lst:raise PreprocError("missing tokens to evaluate")
+       (p,v)=reduce_eval(lst)
+       return int(v)!=0
+def extract_macro(txt):
+       t=tokenize(txt)
+       if re_fun.search(txt):
+               p,name=t[0]
+               p,v=t[1]
+               if p!=OP:raise PreprocError("expected open parenthesis")
+               i=1
+               pindex=0
+               params={}
+               prev='('
+               while 1:
+                       i+=1
+                       p,v=t[i]
+                       if prev=='(':
+                               if p==IDENT:
+                                       params[v]=pindex
+                                       pindex+=1
+                                       prev=p
+                               elif p==OP and v==')':
+                                       break
+                               else:
+                                       raise PreprocError("unexpected token (3)")
+                       elif prev==IDENT:
+                               if p==OP and v==',':
+                                       prev=v
+                               elif p==OP and v==')':
+                                       break
+                               else:
+                                       raise PreprocError("comma or ... expected")
+                       elif prev==',':
+                               if p==IDENT:
+                                       params[v]=pindex
+                                       pindex+=1
+                                       prev=p
+                               elif p==OP and v=='...':
+                                       raise PreprocError("not implemented (1)")
+                               else:
+                                       raise PreprocError("comma or ... expected (2)")
+                       elif prev=='...':
+                               raise PreprocError("not implemented (2)")
+                       else:
+                               raise PreprocError("unexpected else")
+               return(name,[params,t[i+1:]])
+       else:
+               (p,v)=t[0]
+               return(v,[[],t[1:]])
+re_include=re.compile('^\s*(<(?P<a>.*)>|"(?P<b>.*)")')
+def extract_include(txt,defs):
+       m=re_include.search(txt)
+       if m:
+               if m.group('a'):return'<',m.group('a')
+               if m.group('b'):return'"',m.group('b')
+       toks=tokenize(txt)
+       reduce_tokens(toks,defs,['waf_include'])
+       if not toks:
+               raise PreprocError("could not parse include %s"%txt)
+       if len(toks)==1:
+               if toks[0][0]==STR:
+                       return'"',toks[0][1]
+       else:
+               if toks[0][1]=='<'and toks[-1][1]=='>':
+                       return stringize(toks).lstrip('<').rstrip('>')
+       raise PreprocError("could not parse include %s."%txt)
+def parse_char(txt):
+       if not txt:raise PreprocError("attempted to parse a null char")
+       if txt[0]!='\\':
+               return ord(txt)
+       c=txt[1]
+       if c=='x':
+               if len(txt)==4 and txt[3]in string.hexdigits:return int(txt[2:],16)
+               return int(txt[2:],16)
+       elif c.isdigit():
+               if c=='0'and len(txt)==2:return 0
+               for i in 3,2,1:
+                       if len(txt)>i and txt[1:1+i].isdigit():
+                               return(1+i,int(txt[1:1+i],8))
+       else:
+               try:return chr_esc[c]
+               except KeyError:raise PreprocError("could not parse char literal '%s'"%txt)
+def tokenize(s):
+       return tokenize_private(s)[:]
+@Utils.run_once
+def tokenize_private(s):
+       ret=[]
+       for match in re_clexer.finditer(s):
+               m=match.group
+               for name in tok_types:
+                       v=m(name)
+                       if v:
+                               if name==IDENT:
+                                       try:v=g_optrans[v];name=OP
+                                       except KeyError:
+                                               if v.lower()=="true":
+                                                       v=1
+                                                       name=NUM
+                                               elif v.lower()=="false":
+                                                       v=0
+                                                       name=NUM
+                               elif name==NUM:
+                                       if m('oct'):v=int(v,8)
+                                       elif m('hex'):v=int(m('hex'),16)
+                                       elif m('n0'):v=m('n0')
+                                       else:
+                                               v=m('char')
+                                               if v:v=parse_char(v)
+                                               else:v=m('n2')or m('n4')
+                               elif name==OP:
+                                       if v=='%:':v='#'
+                                       elif v=='%:%:':v='##'
+                               elif name==STR:
+                                       v=v[1:-1]
+                               ret.append((name,v))
+                               break
+       return ret
+@Utils.run_once
+def define_name(line):
+       return re_mac.match(line).group(0)
+class c_parser(object):
+       def __init__(self,nodepaths=None,defines=None):
+               self.lines=[]
+               if defines is None:
+                       self.defs={}
+               else:
+                       self.defs=dict(defines)
+               self.state=[]
+               self.count_files=0
+               self.currentnode_stack=[]
+               self.nodepaths=nodepaths or[]
+               self.nodes=[]
+               self.names=[]
+               self.curfile=''
+               self.ban_includes=set([])
+       def cached_find_resource(self,node,filename):
+               try:
+                       nd=node.ctx.cache_nd
+               except AttributeError:
+                       nd=node.ctx.cache_nd={}
+               tup=(node,filename)
+               try:
+                       return nd[tup]
+               except KeyError:
+                       ret=node.find_resource(filename)
+                       if ret:
+                               if getattr(ret,'children',None):
+                                       ret=None
+                               elif ret.is_child_of(node.ctx.bldnode):
+                                       tmp=node.ctx.srcnode.search_node(ret.path_from(node.ctx.bldnode))
+                                       if tmp and getattr(tmp,'children',None):
+                                               ret=None
+                       nd[tup]=ret
+                       return ret
+       def tryfind(self,filename):
+               self.curfile=filename
+               found=self.cached_find_resource(self.currentnode_stack[-1],filename)
+               for n in self.nodepaths:
+                       if found:
+                               break
+                       found=self.cached_find_resource(n,filename)
+               if found and not found in self.ban_includes:
+                       self.nodes.append(found)
+                       if filename[-4:]!='.moc':
+                               self.addlines(found)
+               else:
+                       if not filename in self.names:
+                               self.names.append(filename)
+               return found
+       def addlines(self,node):
+               self.currentnode_stack.append(node.parent)
+               filepath=node.abspath()
+               self.count_files+=1
+               if self.count_files>recursion_limit:
+                       raise PreprocError("recursion limit exceeded")
+               pc=self.parse_cache
+               debug('preproc: reading file %r',filepath)
+               try:
+                       lns=pc[filepath]
+               except KeyError:
+                       pass
+               else:
+                       self.lines.extend(lns)
+                       return
+               try:
+                       lines=filter_comments(filepath)
+                       lines.append((POPFILE,''))
+                       lines.reverse()
+                       pc[filepath]=lines
+                       self.lines.extend(lines)
+               except IOError:
+                       raise PreprocError("could not read the file %s"%filepath)
+               except Exception:
+                       if Logs.verbose>0:
+                               error("parsing %s failed"%filepath)
+                               traceback.print_exc()
+       def start(self,node,env):
+               debug('preproc: scanning %s (in %s)',node.name,node.parent.name)
+               bld=node.ctx
+               try:
+                       self.parse_cache=bld.parse_cache
+               except AttributeError:
+                       bld.parse_cache={}
+                       self.parse_cache=bld.parse_cache
+               self.current_file=node
+               self.addlines(node)
+               if env['DEFINES']:
+                       try:
+                               lst=['%s %s'%(x[0],trimquotes('='.join(x[1:])))for x in[y.split('=')for y in env['DEFINES']]]
+                               lst.reverse()
+                               self.lines.extend([('define',x)for x in lst])
+                       except AttributeError:
+                               pass
+               while self.lines:
+