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",
116 return datetime
.datetime
.now().strftime("%y%m%d")
119 def build(board
, translation
, srcdir
):
120 cmake_options
= " ".join(["-D%s=%s" % (key
, value
) for key
, value
in boards
[board
].items()])
122 if not os
.path
.exists("output"):
124 path
= tempfile
.mkdtemp()
126 command
= "cmake %s -DTRANSLATIONS=%s -DFRSKY_RELEASE=YES %s" % (cmake_options
, translation
, srcdir
)
129 os
.system("make firmware -j6")
133 suffix
= "" if index
== 0 else "_%d" % index
134 filename
= "output/firmware_%s_%s_%s%s.bin" % (board
.lower(), translation
.lower(), timestamp(), suffix
)
135 if not os
.path
.exists(filename
):
136 shutil
.copy("%s/firmware.bin" % path
, filename
)
142 def dir_path(string
):
143 if os
.path
.isdir(string
):
146 raise NotADirectoryError(string
)
150 parser
= argparse
.ArgumentParser(description
="Build FrSky firmware")
151 parser
.add_argument("-b", "--boards", action
="append", help="Destination boards", required
=True)
152 parser
.add_argument("-t", "--translations", action
="append", help="Translations", required
=True)
153 parser
.add_argument("srcdir", type=dir_path
)
155 args
= parser
.parse_args()
157 for board
in (boards
.keys() if "ALL" in args
.boards
else args
.boards
):
158 for translation
in (translations
if "ALL" in args
.translations
else args
.translations
):
159 build(board
, translation
, args
.srcdir
)
162 if __name__
== "__main__":