forked from OpenI6X/opentx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-flysky.py
executable file
·114 lines (97 loc) · 2.81 KB
/
build-flysky.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
107
108
109
110
111
112
113
114
#!/usr/bin/python3
import argparse
import datetime
import os
from builtins import NotADirectoryError
import shutil
import tempfile
boards = {
"I6X": {
"HELI": "NO",
"PCBI6X_ELRS": "YES",
"PCBI6X_INAV": "YES",
"DFPLAYER": "NO",
},
"I6X_DFPLAYER": {
"HELI": "NO",
"PCBI6X_ELRS": "YES",
"PCBI6X_INAV": "YES",
"DFPLAYER": "YES",
},
"I6X_HELI": {
"HELI": "YES",
"PCBI6X_ELRS": "YES",
"PCBI6X_INAV": "NO",
"DFPLAYER": "NO",
},
"I6X_HELI_DFPLAYER": {
"HELI": "YES",
"PCBI6X_ELRS": "YES",
"PCBI6X_INAV": "NO",
"DFPLAYER": "YES",
},
}
translations = [
"EN",
"PL",
"CZ",
"DE",
"ES",
"PT",
"NL",
"SE",
"FI",
"IT",
"FR"
]
common_options = {
"PCB": "I6X",
"MULTIMODULE": "NO",
# "CROSSFIRE": "YES",
"GVARS": "YES",
"LUA": "NO",
"LUA_COMPILER": "NO",
"DISABLE_COMPANION": "YES",
"PPM_UNIT": "PERCENT_PREC0",
"PCBI6X_USB_VBUS": "NO",
}
def timestamp():
return datetime.datetime.now().strftime("%y%m%d")
def build(board, translation, srcdir):
cmake_options = " ".join(["-D%s=%s" % (key, value) for key, value in list(boards[board].items()) + list(common_options.items())])
cwd = os.getcwd()
if not os.path.exists("output"):
os.mkdir("output")
path = tempfile.mkdtemp()
os.chdir(path)
command = "cmake %s -DTRANSLATIONS=%s -DDEFAULT_TEMPLATE_SETUP=21 %s" % (cmake_options, translation, srcdir)
print(command)
os.system(command)
os.system("make firmware -j6")
os.chdir(cwd)
index = 0
while 1:
suffix = "" if index == 0 else "_%d" % index
# filename = "output/firmware_%s_%s_%s%s.bin" % (board.lower(), translation.lower(), timestamp(), suffix)
filename = "output/open%s_%s_%s%s.bin" % (board.lower(), translation.lower(), timestamp(), suffix)
if not os.path.exists(filename):
shutil.copy("%s/firmware.bin" % path, filename)
break
index += 1
shutil.rmtree(path)
def dir_path(string):
if os.path.isdir(string):
return string
else:
raise NotADirectoryError(string)
def main():
parser = argparse.ArgumentParser(description="Build FlySky firmware")
parser.add_argument("-b", "--boards", action="append", help="Destination boards", required=True)
parser.add_argument("-t", "--translations", action="append", help="Translations", required=True)
parser.add_argument("srcdir", type=dir_path)
args = parser.parse_args()
for board in (boards.keys() if "ALL" in args.boards else args.boards):
for translation in (translations if "ALL" in args.translations else args.translations):
build(board, translation, args.srcdir)
if __name__ == "__main__":
main()