-
Notifications
You must be signed in to change notification settings - Fork 0
/
waf
executable file
·70 lines (59 loc) · 1.98 KB
/
waf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/env python
# vim : set fileencoding=utf-8 expandtab noai ts=4 sw=4 filetype=python :
VERSION="1.9.1"
def err(m):
import sys
print(('\033[91mError: %s\033[0m' % m))
sys.exit(1)
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def waf():
import os
import sys
import inspect
import subprocess
src = os.path.abspath(inspect.getfile(inspect.getmodule(err)))
base, name = os.path.split(src)
wafdir = os.path.abspath(os.path.join(base, ".waf"))
if not os.path.isdir(wafdir):
git = which("git") or which("git.exe")
if not git:
err("git not found in the path, please install.")
subprocess.call([git, 'subtree', 'add', '--prefix', '.waf', 'https://github.com/waf-project/waf.git', 'master'])
#subprocess.call([git, "clone", "https://github.com/waf-project/waf.git", "-b", "waf-%s" % VERSION, wafdir])
if not os.path.isdir(os.path.join(wafdir, "waflib")):
err("waflib-Folder not present in %s." % wafdir)
return False
sys.path.insert(0, wafdir)
from waflib import Scripting
return Scripting.waf_entry_point(os.getcwd(), VERSION, wafdir)
def main():
import os
import sys
import inspect
src = os.path.abspath(inspect.getfile(inspect.getmodule(err)))
base, name = os.path.split(src)
sys.path.insert(0, base)
from core.tools import repository
commands = {
"repo": repository.execute
}
if len(sys.argv) > 1 and sys.argv[1] in commands:
commands[sys.argv[1]](base)
else:
waf()
if __name__ == "__main__":
main()