6 from builtins
import NotADirectoryError
14 "LUA": "NO_MODEL_SCRIPTS",
16 "MODULE_SIZE_STD": "NO",
25 "MODULE_PROTOCOL_D8": "NO",
26 "LUA": "NO_MODEL_SCRIPTS",
28 "MODULE_SIZE_STD": "NO",
37 "LUA": "NO_MODEL_SCRIPTS",
42 "MODULE_SIZE_STD": "NO",
51 "LUA": "NO_MODEL_SCRIPTS",
56 "MODULE_SIZE_STD": "NO",
66 "LUA": "NO_MODEL_SCRIPTS",
71 "MODULE_SIZE_STD": "NO",
82 "LUA": "NO_MODEL_SCRIPTS",
92 "LUA": "NO_MODEL_SCRIPTS",
100 "MODULE_PROTOCOL_D8": "NO",
101 "LUA": "NO_MODEL_SCRIPTS",
110 "LUA": "NO_MODEL_SCRIPTS",
127 return datetime
.datetime
.now().strftime("%y%m%d")
130 def build(board
, translation
, srcdir
):
131 cmake_options
= " ".join(["-D%s=%s" % (key
, value
) for key
, value
in boards
[board
].items()])
133 if not os
.path
.exists("output"):
135 path
= tempfile
.mkdtemp()
137 command
= "cmake %s -DTRANSLATIONS=%s -DFRSKY_RELEASE=YES %s" % (cmake_options
, translation
, srcdir
)
140 os
.system("make firmware -j6")
144 suffix
= "" if index
== 0 else "_%d" % index
145 filename
= "output/firmware_%s_%s_%s%s.bin" % (board
.lower(), translation
.lower(), timestamp(), suffix
)
146 if not os
.path
.exists(filename
):
147 shutil
.copy("%s/firmware.bin" % path
, filename
)
153 def dir_path(string
):
154 if os
.path
.isdir(string
):
157 raise NotADirectoryError(string
)
161 parser
= argparse
.ArgumentParser(description
="Build FrSky firmware")
162 parser
.add_argument("-b", "--boards", action
="append", help="Destination boards", required
=True)
163 parser
.add_argument("-t", "--translations", action
="append", help="Translations", required
=True)
164 parser
.add_argument("srcdir", type=dir_path
)
166 args
= parser
.parse_args()
168 for board
in (boards
.keys() if "ALL" in args
.boards
else args
.boards
):
169 for translation
in (translations
if "ALL" in args
.translations
else args
.translations
):
170 build(board
, translation
, args
.srcdir
)
173 if __name__
== "__main__":