Tools: add --upload-port option to waf

This commit is contained in:
Andy Piper 2019-09-25 12:32:32 +01:00 committed by Andrew Tridgell
parent ddde512b74
commit 1d11fe5377
2 changed files with 12 additions and 1 deletions

View File

@ -507,6 +507,13 @@ platforms may support this. Example: `waf copter --upload` means "build
arducopter and upload it to my board".
''')
g.add_option('--upload-port',
action='store',
dest='upload_port',
default=None,
help='''Specify the port to be used with the --upload option. For example a port of /dev/ttyS10 indicates that serial port 10 shuld be used.
''')
g = opt.ap_groups['check']
g.add_option('--check-verbose',

View File

@ -53,8 +53,12 @@ class upload_fw(Task.Task):
always_run = True
def run(self):
upload_tools = self.env.get_flat('UPLOAD_TOOLS')
upload_port = self.generator.bld.options.upload_port
src = self.inputs[0]
return self.exec_command("{} '{}/uploader.py' '{}'".format(self.env.get_flat('PYTHON'), upload_tools, src))
cmd = "{} '{}/uploader.py' '{}'".format(self.env.get_flat('PYTHON'), upload_tools, src)
if upload_port is not None:
cmd += " '--port' '%s'" % upload_port
return self.exec_command(cmd)
def exec_command(self, cmd, **kw):
kw['stdout'] = sys.stdout