icfp11/waf

146 lines
132 KiB
Plaintext
Raw Permalink Normal View History

2008-07-11 20:38:17 +00:00
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2005-2008
"""
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
if sys.hexversion<0x203000f: raise "Waf requires Python >= 2.3"
if 'PSYCOWAF' in os.environ:
try:import psyco;psyco.full()
except:pass
2008-07-11 22:20:05 +00:00
VERSION="1.4.2"
REVISION="6fc051971db49c83aab5565673e789bc"
2008-07-11 20:38:17 +00:00
INSTALL=sys.platform=='win32' and 'c:/temp' or '/usr/local'
cwd = os.getcwd()
join = os.path.join
2008-07-11 22:20:05 +00:00
def decode(s):
p1 = len(s)
s += '!!!!!'
w1 = [256**(3-u) for u in xrange(4)]
w2 = [(u, 85**(4-u)) for u in xrange(5)]
tot = [sum([(ord(s[i+m])-33) * n for (m, n) in w2]) for i in xrange(0, p1, 5)]
return ''.join([chr((y/x) & 255) for y in tot for x in w1])
2008-07-11 20:38:17 +00:00
def err(m):
print '\033[91mError: %s\033[0m' % m
sys.exit(1)
def unpack_wafdir(dir):
f = open(sys.argv[0],'rb')
c = "corrupted waf (%d)"
while 1:
line = f.readline()
if not line: err("run waf-light from a folder containing wafadmin")
if line == '#==>\n':
txt = f.readline()
if not txt: err(c % 1)
if f.readline()!='#<==\n': err(c % 2)
break
if not txt: err(c % 3)
2008-07-11 22:20:05 +00:00
try: txt = decode(txt[1:-1].replace('z', '!!!!!'))
except: err(c % 4)
2008-07-11 20:38:17 +00:00
import shutil, tarfile
try: shutil.rmtree(dir)
except OSError: pass
try: os.makedirs(join(dir, 'wafadmin', 'Tools'))
except OSError: err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
os.chdir(dir)
tmp = 't.tbz2'
t = open(tmp,'wb')
t.write(txt)
t.close()
t = tarfile.open(tmp)
for x in t: t.extract(x)
t.close()
os.chmod(join('wafadmin','Tools'), 0755)
os.unlink(tmp)
os.chdir(cwd)
def test(dir):
try: os.stat(join(dir, 'wafadmin')); 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 wafadmin -> export WAFDIR=/folder")
dir = "/lib/waf-%s-%s/" % (VERSION, REVISION)
for i in [INSTALL,'/usr','/usr/local','/opt']:
w = test(i+dir)
if w: return w
#waf-local
s = '.waf-%s-%s'
if sys.platform == 'win32': s = s[1:]
dir = join(base, s % (VERSION, REVISION))
w = test(dir)
if w: return w
#unpack
unpack_wafdir(dir)
return dir
wafdir = find_lib()
2008-07-11 22:20:05 +00:00
if "-vv" in sys.argv: print "wafdir is %s" % wafdir
2008-07-11 20:38:17 +00:00
w = join(wafdir, 'wafadmin')
t = join(w, 'Tools')
sys.path = [w, t] + sys.path
2008-07-11 22:20:05 +00:00
import Scripting, Params
Params.g_tooldir = [t]
Params.g_cwd_launch = cwd
if Params.g_version != VERSION:
err('Version mismatch: waf %s <> wafadmin %s (wafdir %s)' % (VERSION, Params.g_version, wafdir))
Scripting.prepare()
2008-07-11 20:38:17 +00:00
#==>
2008-07-11 22:20:05 +00:00
#6<\%_0gSqh;ct1=O)>%tZ2ak(p?^f=s8W-!s8W-!s8W+L:rj=c!%e2,!e:h)!"gVg2Epj&mBE=`zz!!N?&z!!!!P^@b03ZX6pT^"i>J%OF3-G&qY/Cp4'/.n)3n+r$P:='*$pj:,k4H>[ijFgkm>_.DDuQW_&Z.%p=4g"uJ[HbIb>B4$)AY;^W$X*N;7n!*^g*R?C@!f$O@p1ISfJF>tk&0O<Rad=MDTW'>2TJ8Xc](b)gqfdJU5&U8Gf4e-5/Rj->4(;E%YH8A!:_<<%AI2G56`h_aDP=KeU4Gl;R_hIV4kp'ZBOur^miC?9F4YR#8P'VXm>C%`oP0Fjo0k$DH[D@Ofk,c1Q#2[FbI;i2GQCUBp'hknVq]u,plG`G;PT_jH+n^po6YkX4I!=72un7F!!#1Iq5qHbWU!%ZDiOpDT5gF0Z%D_q]l.32YT)53RV;D_YBOq\_!(NsXg,;LXGp94E419#"Jc?#$D<I\'EXn$!>f?d?-B[L6b+9#F4oAr^@-_sC[3;$.bbN5$J)"&YJ!(?_oAm$QX+a;V_*%.II)"G[b^Y'qp+W<jkT03m^LL\p?m+j\pa=n:JZ*'l1\fJqsRk_,bt[4]=2996n"aV`f525mgrJ#W:E+BqYT]'k/fL_UV:)PgtYcIGMd3#^#+1kfulWrf2VW`pYFYpkj6$cg%X+4`Og=tpRAkb]AI6[^=V,kIHur8\Q&EPZb=LC=Z3hHn%AMSFPhM[lMKE3],Ng]lR"^F^AGCOmt\X7(L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