3 # Thomas Nagy, 2005-2010
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 3. The name of the author may not be used to endorse or promote products
18 derived from this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
21 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
34 if sys
.hexversion
<0x203000f: raise ImportError("Waf requires Python >= 2.3")
36 if 'PSYCOWAF' in os
.environ
:
37 try:import psyco
;psyco
.full()
41 REVISION
="4340ef810f7db5d61c618fdf96cb5695"
52 if sys
.hexversion
>0x300000f:
58 print(('\033[91mError: %s\033[0m' % m
))
61 def unpack_wafdir(dir):
62 f
= open(sys
.argv
[0],'rb')
63 c
= "corrupted waf (%d)"
66 if not line
: err("run waf-light from a folder containing wafadmin")
67 if line
== b('#==>\n'):
69 if not txt
: err(c
% 1)
70 if f
.readline()!=b('#<==\n'): err(c
% 2)
72 if not txt
: err(c
% 3)
73 txt
= txt
[1:-1].replace(b(C1
), b('\n')).replace(b(C2
), b('\r'))
75 import shutil
, tarfile
76 try: shutil
.rmtree(dir)
79 for x
in ['Tools', '3rdparty']:
80 os
.makedirs(join(dir, 'wafadmin', x
))
82 err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
92 for x
in t
: t
.extract(x
)
96 try: shutil
.rmtree(dir)
98 err("Waf cannot be unpacked, check that bzip2 support is present")
100 for x
in ['Tools', '3rdparty']:
101 os
.chmod(join('wafadmin',x
), 493)
105 if sys
.hexversion
>0x300000f:
106 sys
.path
= [join(dir, 'wafadmin')] + sys
.path
108 py3kfixes
.fixdir(dir)
113 try: os
.stat(join(dir, 'wafadmin')); return os
.path
.abspath(dir)
118 base
= os
.path
.dirname(os
.path
.abspath(name
))
121 w
=test(os
.environ
.get('WAFDIR', ''))
125 if name
.endswith('waf-light'):
128 err("waf-light requires wafadmin -> export WAFDIR=/folder")
130 dir = "/lib/%s-%s-%s/" % (WAF
, VERSION
, REVISION
)
131 for i
in [INSTALL
,'/usr','/usr/local','/opt']:
137 if sys
.platform
== 'win32': s
= s
[1:]
138 dir = join(base
, s
% (WAF
, VERSION
, REVISION
))
147 w
= join(wafdir
, 'wafadmin')
149 f
= join(w
, '3rdparty')
150 sys
.path
= [w
, t
, f
] + sys
.path
152 if __name__
== '__main__':
154 Scripting
.prepare(t
, cwd
, VERSION
, wafdir
)
157 #BZh91AY&SYp½—\x02ÀØ\x7fÿÿ°