build: add rsync command

The original proposal was to add this functionality to the --upload option, but
it turns out that --upload seems something slightly different from what the
functionality added with patch does.

The issue motivating this patch is at
https://github.com/ArduPilot/ardupilot/issues/6283
This commit is contained in:
Gustavo Sousa 2017-06-05 10:22:09 -03:00 committed by Lucas De Marchi
parent 923e62cb74
commit 374556df22
1 changed files with 43 additions and 0 deletions

43
wscript
View File

@ -80,6 +80,15 @@ reconfiguration whenever it thinks it's necessary - this option disables that.
help='''
Don't update git submodules. Useful for building with submodules at specific
revisions.
''')
g.add_option('--rsync-dest',
dest='rsync_dest',
action='store',
default='',
help='''
Destination for the rsync Waf command. It can be passed during configuration in
order to save typing.
''')
g.add_option('--enable-benchmarks',
@ -191,6 +200,11 @@ def configure(cfg):
cfg.srcnode.abspath() + '/libraries/',
])
cfg.find_program('rsync', mandatory=False)
if cfg.options.rsync_dest:
cfg.msg('Setting rsync destination to', cfg.options.rsync_dest)
cfg.env.RSYNC_DEST = cfg.options.rsync_dest
# TODO: Investigate if code could be changed to not depend on the
# source absolute path.
cfg.env.prepend_value('DEFINES', [
@ -412,3 +426,32 @@ class LocalInstallContext(Build.InstallContext):
r = super(LocalInstallContext, self).execute()
self.options.destdir = old_destdir
return r
class RsyncContext(LocalInstallContext):
"""runs linstall and then rsyncs BLD/install with the target system"""
cmd = 'rsync'
def __init__(self, **kw):
super(RsyncContext, self).__init__(**kw)
self.add_pre_fun(RsyncContext.create_rsync_taskgen)
def create_rsync_taskgen(self):
if 'RSYNC' not in self.env:
self.fatal('rsync program seems not to be installed, can\'t continue')
self.add_group()
tg = self(
name='rsync',
rule='${RSYNC} -a ${RSYNC_SRC}/ ${RSYNC_DEST}',
always=True,
)
tg.env.RSYNC_SRC = self.local_destdir
if self.options.rsync_dest:
self.env.RSYNC_DEST = self.options.rsync_dest
if 'RSYNC_DEST' not in tg.env:
self.fatal('Destination for rsync not defined. Either pass --rsync-dest here or during configuration.')
tg.post()