waf: regenerate canard dsdl sources after clean

This commit is contained in:
bugobliterator 2021-09-30 14:43:08 +05:30 committed by Andrew Tridgell
parent 2223698c47
commit 0b7a913b30
1 changed files with 33 additions and 16 deletions

49
wscript
View File

@ -453,22 +453,7 @@ def configure(cfg):
])
if cfg.env.AP_PERIPH:
src = cfg.srcnode.ant_glob('modules/pyuavcan/uavcan/dsdl_files/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False)
src = ' '.join([s.abspath() for s in src])
cmd = '{} {} -O {} {}'.format(cfg.env.get_flat('PYTHON'),
cfg.srcnode.make_node('Tools/canard_dsdlc/canard_dsdlc.py').abspath(),
cfg.bldnode.make_node(cfg.variant + '/modules/libcanard/dsdlc_generated').abspath(),
src)
cfg.start_msg('Generating DSDL C bindings')
ret = subprocess.run(cmd, shell=True, capture_output=True)
if ret.returncode != 0:
cfg.end_msg('failed', color='RED')
print('Failed to run: ', cmd)
print(ret.stdout.decode('utf-8'))
print(ret.stderr.decode('utf-8'))
raise RuntimeError('Failed to generate DSDL C bindings')
else:
cfg.end_msg('OK')
generate_canard_dsdlc(cfg)
# Always use system extensions
cfg.define('_GNU_SOURCE', 1)
@ -480,6 +465,32 @@ def configure(cfg):
_collect_autoconfig_files(cfg)
def generate_canard_dsdlc(cfg, in_configure=True):
if in_configure:
dsdlc_gen_path = cfg.bldnode.make_node(os.path.join(cfg.variant, 'modules/libcanard/dsdlc_generated')).abspath()
else:
dsdlc_gen_path = cfg.bldnode.make_node('modules/libcanard/dsdlc_generated').abspath()
src = cfg.srcnode.ant_glob('modules/pyuavcan/uavcan/dsdl_files/* libraries/AP_UAVCAN/dsdl/*', dir=True, src=False)
src = ' '.join([s.abspath() for s in src])
cmd = '{} {} -O {} {}'.format(cfg.env.get_flat('PYTHON'),
cfg.srcnode.make_node('Tools/canard_dsdlc/canard_dsdlc.py').abspath(),
dsdlc_gen_path,
src)
if in_configure:
cfg.start_msg('Generating DSDL C bindings')
else:
print("Generating DSDLC for CANARD: " + cmd)
ret = subprocess.run(cmd, shell=True, capture_output=True)
if ret.returncode != 0:
if in_configure:
cfg.end_msg('failed', color='RED')
print('Failed to run: ', cmd)
print(ret.stdout.decode('utf-8'))
print(ret.stderr.decode('utf-8'))
raise RuntimeError('Failed to generate DSDL C bindings')
elif in_configure:
cfg.end_msg('OK')
def collect_dirs_to_recurse(bld, globs, **kw):
dirs = []
globs = Utils.to_list(globs)
@ -684,6 +695,12 @@ def _load_pre_build(bld):
if bld.cmd == 'clean':
return
brd = bld.get_board()
if bld.env.AP_PERIPH:
dsdlc_gen_path = bld.bldnode.make_node('modules/libcanard/dsdlc_generated/include').abspath()
#check if canard dsdlc directory empty
# check if directory exists
if not os.path.exists(dsdlc_gen_path) or not os.listdir(dsdlc_gen_path):
generate_canard_dsdlc(bld, False)
if getattr(brd, 'pre_build', None):
brd.pre_build(bld)