-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonk.py
executable file
·109 lines (97 loc) · 2.92 KB
/
monk.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/python2.7
# for path inspection:
import sys
import os
import inspect
import fnmatch
import monkDebug as debug
import monkModule
import monkArg
import monkTools
myArg = monkArg.MonkArg()
myArg.add(monkArg.ArgDefine("h", "help", desc="display this help"))
myArg.add_section("option", "Can be set one time in all case")
myArg.add(monkArg.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"]], desc="Display makefile debug level (verbose) default =2"))
myArg.add(monkArg.ArgDefine("C", "color", desc="Display makefile output in color"))
myArg.add_section("cible", "generate in order set")
localArgument = myArg.parse()
##
## @brief Display the help of this makefile
##
def usage():
# generic argument displayed :
myArg.display()
print(" all")
print(" Build all (only for the current selected board) (bynary and packages)")
print(" clean")
print(" Clean all (same as previous)")
listOfAllModule = monkModule.list_all_module_with_desc()
for mod in listOfAllModule:
print(" " + mod[0] + " / " + mod[0] + "-clean")
if mod[1] != "":
print(" " + mod[1])
print(" ex: " + sys.argv[0] + " all")
exit(0)
##
## @brief Preparse the argument to get the verbose element for debug mode
##
def parse_generic_arg(argument,active):
if argument.get_option_name() == "help":
#display help
if active==False:
usage()
return True
elif argument.get_option_name() == "verbose":
if active==True:
debug.set_level(int(argument.get_arg()))
return True
elif argument.get_option_name() == "color":
if active==True:
debug.enable_color()
return True
return False
##
## @brief Parse default unique argument:
##
if __name__ == "__main__":
for argument in localArgument:
parse_generic_arg(argument, True)
##
## @brief Run everything that is needed in the system
##
def start():
actionDone=False
# parse all argument
for argument in localArgument:
if parse_generic_arg(argument, False) == True:
continue
if argument.get_option_name() != "":
debug.warning("Can not understand argument : '" + argument.get_option_name() + "'")
usage()
else:
module = monkModule.get_module(argument.get_arg())
module.parse_code()
module.generate()
actionDone=True
# if no action done : we do "all" ...
if actionDone==False:
#Must generate all docs :
moduleElements = monkModule.get_all_module()
for module in moduleElements:
module.parse_code()
for module in moduleElements:
module.generate()
##
## @brief When the user use with make.py we initialise ourself
##
if __name__ == '__main__':
sys.path.append(monkTools.get_run_folder())
# Import all sub path without out and archive
for folder in os.listdir("."):
if os.path.isdir(folder)==True:
if folder.lower()!="android" \
and folder.lower()!="archive" \
and folder.lower()!="out" :
debug.debug("Automatic load path: '" + folder + "'")
monkModule.import_path(folder)
start()