smbd: Simplify callers of notify_filter_string
[Samba.git] / buildtools / bin / waf
blobc103979cc00e5b8c7990abe5bac6505390930c40
1 #!/usr/bin/env python3
2 # encoding: latin-1
3 # Thomas Nagy, 2005-2018
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:
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.
31 """
33 import os, sys, inspect
35 VERSION="2.0.26"
36 REVISION="x"
37 GIT="x"
38 INSTALL="x"
39 C1='x'
40 C2='x'
41 C3='x'
42 cwd = os.getcwd()
43 join = os.path.join
45 if sys.hexversion<0x206000f:
46         raise ImportError('Python >= 2.6 is required to create the waf file')
48 WAF='waf3'
49 def b(x):
50         return x.encode()
52 def err(m):
53         print(('\033[91mError: %s\033[0m' % m))
54         sys.exit(1)
56 def unpack_wafdir(dir, src):
57         f = open(src,'rb')
58         c = 'corrupt archive (%d)'
59         while 1:
60                 line = f.readline()
61                 if not line: err('run waf-light from a folder containing waflib')
62                 if line == b('#==>\n'):
63                         txt = f.readline()
64                         if not txt: err(c % 1)
65                         if f.readline() != b('#<==\n'): err(c % 2)
66                         break
67         if not txt: err(c % 3)
68         txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r')).replace(b(C3), b('\x00'))
70         import shutil, tarfile
71         try: shutil.rmtree(dir)
72         except OSError: pass
73         try:
74                 for x in ('Tools', 'extras'):
75                         os.makedirs(join(dir, 'waflib', x))
76         except OSError:
77                 err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
79         os.chdir(dir)
80         tmp = 't.bz2'
81         t = open(tmp,'wb')
82         try: t.write(txt)
83         finally: t.close()
85         try:
86                 t = tarfile.open(tmp)
87         except:
88                 try:
89                         os.system('bunzip2 t.bz2')
90                         t = tarfile.open('t')
91                         tmp = 't'
92                 except:
93                         os.chdir(cwd)
94                         try: shutil.rmtree(dir)
95                         except OSError: pass
96                         err("Waf cannot be unpacked, check that bzip2 support is present")
98         try:
99                 for x in t: t.extract(x)
100         finally:
101                 t.close()
103         for x in ('Tools', 'extras'):
104                 os.chmod(join('waflib',x), 493)
106         os.remove(tmp)
107         os.chdir(cwd)
109         try: dir = unicode(dir, 'mbcs')
110         except: pass
111         try:
112                 from ctypes import windll
113                 windll.kernel32.SetFileAttributesW(dir, 2)
114         except:
115                 pass
117 def test(dir):
118         try:
119                 os.stat(join(dir, 'waflib'))
120                 return os.path.abspath(dir)
121         except OSError:
122                 pass
124 def find_lib():
125         path = '../../third_party/waf'
126         paths = [path, path+'/waflib']
127         return [os.path.abspath(os.path.join(os.path.dirname(__file__), x)) for x in paths]
129 wafdir = find_lib()
130 for p in wafdir:
131         sys.path.insert(0, p)
133 if __name__ == '__main__':
134         #import extras.compat15#PRELUDE
135         import sys
137         from waflib.Tools import ccroot, c, ar, compiler_c, gcc
138         sys.modules['cc'] = c
139         sys.modules['ccroot'] = ccroot
140         sys.modules['ar'] = ar
141         sys.modules['compiler_cc'] = compiler_c
142         sys.modules['gcc'] = gcc
144         from waflib import Options
145         Options.lockfile = os.environ.get('WAFLOCK', '.lock-wscript')
146         if os.path.isfile(Options.lockfile) and os.stat(Options.lockfile).st_size == 0:
147                 os.environ['NOCLIMB'] = "1"
148         # there is a single top-level, but libraries must build independently
149         os.environ['NO_LOCK_IN_TOP'] = "1"
151         from waflib import Task
152         class o(object):
153                 display = None
154         Task.classes['cc_link'] = o
156         from waflib import Scripting
157         Scripting.waf_entry_point(cwd, VERSION, wafdir[0])