blob: fc6cbaea7009995c5bc297e8a1009a6fbf60fffa (
plain)
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
|
#!/usr/bin/env python
import os
import sys
import logging
sys.path.append(os.getcwd())
logging.basicConfig(format="%(asctime)s:%(levelname)s:%(message)s")
logger = logging.Logger(name=__name__)
logger.addHandler(logging.StreamHandler())
def main():
args = sys.argv[1:]
for arg in args:
if arg == "version":
printVersion()
elif arg == "help":
printVersion()
print("\n")
printTargets()
elif arg:
target = arg
invokeBuild(target)
elif not arg:
target = "default"
invokeBuild(target)
from xnt.tasks import rm
rm("build.pyc")
def invokeBuild(targetName):
if not os.path.exists("build.py"):
logger.error("There was no build file")
sys.exit(1)
try:
build = __import__("build", fromlist=[])
target = getattr(build, targetName)
target()
except AttributeError:
logger.warning("There was no target: %s", targetName)
except:
logger.error(sys.exc_info()[1].message)
def printVersion():
import xnt
print(xnt.__version__)
def printTargets():
if not os.path.exists("build.py"):
logger.error("There was no build file")
sys.exit(1)
try:
build = __import__("build", fromlist=[])
for f in dir(build):
try:
fa = getattr(build, f)
if fa.decorator == "target":
print(f + ":")
if fa.__doc__:
print(fa.__doc__)
print("\n")
except AttributeError:
pass
except AttributeError:
pass
except:
logger.error(sys.exc_info()[1].message)
if __name__ == "__main__":
main()
|