3
# WARNING! Do not edit! http://waf.googlecode.com/svn/docs/wafbook/single.html#_obtaining_the_waf_file
5
import os,sys,errno,traceback,inspect,re,shutil,datetime,gc
10
import waflib.extras.subprocess as subprocess
12
print("The subprocess module is missing (python2.3?):\n try calling 'waf update --files=subprocess'\n or add a copy of subprocess.py to the python libraries")
14
from collections import deque
20
import _winreg as winreg
26
from waflib import Errors
28
from collections import UserDict
30
from UserDict import UserDict
32
from hashlib import md5
41
class threading(object):
48
threading.Lock=threading.Thread=Lock
50
run_old=threading.Thread.run
51
def run(*args,**kwargs):
53
run_old(*args,**kwargs)
54
except(KeyboardInterrupt,SystemExit):
57
sys.excepthook(*sys.exc_info())
58
threading.Thread.run=run
59
SIG_NIL='iluvcuteoverload'
62
rot_chr=['\\','|','/','-']
65
from collections import defaultdict
67
class defaultdict(dict):
68
def __init__(self,default_factory):
69
super(defaultdict,self).__init__()
70
self.default_factory=default_factory
71
def __getitem__(self,key):
73
return super(defaultdict,self).__getitem__(key)
75
value=self.default_factory()
78
is_win32=sys.platform in('win32','cli')
79
indicator='\x1b[K%s%s%s\r'
80
if is_win32 and'NOCOLOR'in os.environ:
82
def readf(fname,m='r'):
94
filename=f.read(100000)
104
ret=binascii.hexlify(s)
105
if not isinstance(ret,str):
106
ret=ret.decode('utf-8')
110
return s.encode('hex')
112
Return the hexadecimal representation of a string
114
:param s: string to convert
119
def listdir_win32(s):
124
return[x+':\\'for x in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')]
128
buf=ctypes.create_string_buffer(maxdrives*dlen)
129
ndrives=ctypes.windll.kernel32.GetLogicalDriveStringsA(maxdrives,ctypes.byref(buf))
130
return[buf.raw[4*i:4*i+3].decode('ascii')for i in range(int(ndrives/dlen))]
131
if len(s)==2 and s[1]==":":
133
if not os.path.isdir(s):
138
listdir=listdir_win32
140
if isinstance(ver,str):
141
ver=tuple(ver.split('.'))
142
if isinstance(ver,tuple):
146
ret+=256**(3-i)*int(ver[i])
150
exc_type,exc_value,tb=sys.exc_info()
151
exc_lines=traceback.format_exception(exc_type,exc_value,tb)
152
return''.join(exc_lines)
154
if isinstance(sth,str):
158
re_nl=re.compile('\r*\n',re.M)
159
def str_to_dict(txt):
161
lines=re_nl.split(txt)
164
if not x or x.startswith('#')or x.find('=')<0:
167
tbl[tmp[0].strip()]='='.join(tmp[1:]).strip()
169
def split_path(path):
170
return path.split('/')
171
def split_path_cygwin(path):
172
if path.startswith('//'):
173
ret=path.split('/')[2:]
176
return path.split('/')
177
re_sp=re.compile('[/\\\\]')
178
def split_path_win32(path):
179
if path.startswith('\\\\'):
180
ret=re.split(re_sp,path)[2:]
183
return re.split(re_sp,path)
184
if sys.platform=='cygwin':
185
split_path=split_path_cygwin
187
split_path=split_path_win32
188
split_path.__doc__="""
189
Split a path by / or \\. This function is not like os.path.split
192
:param path: path to split
193
:return: list of strings
196
if not os.path.isdir(path):
200
if not os.path.isdir(path):
201
raise Errors.WafError('Cannot create the folder %r'%path,ex=e)
202
def def_attrs(cls,**kw):
203
for k,v in kw.items():
204
if not hasattr(cls,k):
206
def quote_define_name(s):
207
fu=re.compile("[^a-zA-Z0-9]").sub("_",s)
217
except AttributeError:
219
h=inspect.getsource(fun)
224
except AttributeError:
227
reg_subst=re.compile(r"(\\\\)|(\$\$)|\$\{([^}]+)\}")
228
def subst_vars(expr,params):
235
return params.get_flat(m.group(3))
236
except AttributeError:
237
return params[m.group(3)]
238
return reg_subst.sub(repl_var,expr)
239
def destos_to_binfmt(key):
242
elif key in('win32','cygwin','uwin','msys'):
245
def unversioned_sys_platform():
248
from java.lang import System
249
s=System.getProperty('os.name')
252
elif s.startswith('Windows '):
258
elif s in('SunOS','Solaris'):
261
if s=='win32'or s.endswith('os2')and s!='sunos2':return s
262
return re.split('\d+$',s)[0]
267
self.start_time=datetime.datetime.utcnow()
269
delta=datetime.datetime.utcnow()-self.start_time
271
hours=delta.seconds//3600
272
minutes=(delta.seconds-hours*3600)//60
273
seconds=delta.seconds-hours*3600-minutes*60+float(delta.microseconds)/1000/1000
279
if days or hours or minutes:
280
result+='%dm'%minutes
281
return'%s%.3fs'%(result,seconds)
286
shutil.copystat(src,src)
287
setattr(shutil,'copy2',copy2)
292
except NotImplementedError:
294
def read_la_file(path):
295
sp=re.compile(r'^([^=]+)=\'(.*)\'$')
297
for line in readf(path).splitlines():
299
_,left,right,_=sp.split(line.strip())
312
f.__doc__=fun.__doc__
325
def get_registry_app_path(key,filename):
329
result=winreg.QueryValue(key,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe"%filename[0])
333
if os.path.isfile(result):