root/gtkimageview/waf

Revision 637, 75.7 kB (checked in by bjourne, 4 years ago)

New version of waf which makes it possible to build documentation
again.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2005-2008
4
5 """
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 1. Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12
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.
16
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.
19
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.
31 """
32
33 import os, sys
34 if sys.hexversion<0x203000f: raise "Waf requires Python >= 2.3"
35
36 if 'PSYCOWAF' in os.environ:
37         try:import psyco;psyco.full()
38         except:pass
39
40 VERSION="1.5.2"
41 REVISION="6d5d58072b747f08a76958909adaaae0"
42 INSTALL=sys.platform=='win32' and 'c:/temp' or '/usr/local'
43 C1='#.'
44 C2='#+'
45 cwd = os.getcwd()
46 join = os.path.join
47
48 def err(m):
49         print ('\033[91mError: %s\033[0m' % m)
50         sys.exit(1)
51
52 def unpack_wafdir(dir):
53         f = open(sys.argv[0],'rb')
54         c = "corrupted waf (%d)"
55         while 1:
56                 line = f.readline()
57                 if not line: err("run waf-light from a folder containing wafadmin")
58                 if line == '#==>\n':
59                         txt = f.readline()
60                         if not txt: err(c % 1)
61                         if f.readline()!='#<==\n': err(c % 2)
62                         break
63         if not txt: err(c % 3)
64         txt = txt[1:-1].replace(C1, '\n').replace(C2, '\r')
65
66         import shutil, tarfile
67         try: shutil.rmtree(dir)
68         except OSError: pass
69         try: os.makedirs(join(dir, 'wafadmin', 'Tools'))
70         except OSError: err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
71
72         os.chdir(dir)
73         tmp = 't.tbz2'
74         t = open(tmp,'wb')
75         t.write(txt)
76         t.close()
77
78         t = tarfile.open(tmp)
79         for x in t: t.extract(x)
80         t.close()
81
82         os.chmod(join('wafadmin','Tools'), 493)
83
84         os.unlink(tmp)
85         os.chdir(cwd)
86
87 def test(dir):
88         try: os.stat(join(dir, 'wafadmin')); return os.path.abspath(dir)
89         except OSError: pass
90
91 def find_lib():
92         name = sys.argv[0]
93         base = os.path.dirname(os.path.abspath(name))
94
95         #devs use $WAFDIR
96         w=test(os.environ.get('WAFDIR', ''))
97         if w: return w
98
99         #waf-light
100         if name.endswith('waf-light'):
101                 w = test(base)
102                 if w: return w
103                 err("waf-light requires wafadmin -> export WAFDIR=/folder")
104
105         dir = "/lib/waf-%s-%s/" % (VERSION, REVISION)
106         for i in [INSTALL,'/usr','/usr/local','/opt']:
107                 w = test(i+dir)
108                 if w: return w
109
110         #waf-local
111         s = '.waf-%s-%s'
112         if sys.platform == 'win32': s = s[1:]
113         dir = join(base, s % (VERSION, REVISION))
114         w = test(dir)
115         if w: return w
116
117         #unpack
118         unpack_wafdir(dir)
119         return dir
120
121 wafdir = find_lib()
122 w = join(wafdir, 'wafadmin')
123 t = join(w, 'Tools')
124 sys.path = [w, t] + sys.path
125
126 import Scripting
127 Scripting.prepare(t, cwd, VERSION, wafdir)
128
129 #==>
130 #BZh91AY&SYé“U@X4ÿÿ0€àÿÿÿÿÿÿÿÿÿÿÿ„@Ð@‚‚H@R&T(aˆ>÷·ßaà
Note: See TracBrowser for help on using the browser.