waf: use direct import of mavgen for mavlink generation

this avoids a path problem on windows under eclipse
This commit is contained in:
Andrew Tridgell 2018-11-14 19:27:42 +11:00
parent 6cacc738b3
commit e6651b01bb

View File

@ -51,23 +51,16 @@ class mavgen(Task.Task):
return nodes, names return nodes, names
def run(self): def run(self):
python = self.env.get_flat('PYTHON') from pymavlink.generator import mavgen
mavgen = self.env.get_flat('MAVGEN') class mavgen_options:
out = self.env.get_flat('OUTPUT_DIR') language = 'C'
src = self.env.get_flat('SRC') wire_protocol = '2.0'
ret = self.exec_command("{} '{}' --lang=C --wire-protocol=2.0 --output '{}' '{}'".format( validate = False
python, mavgen, out, self.inputs[0].abspath())) output = self.env.get_flat('OUTPUT_DIR')
xml = self.inputs[0].abspath()
if ret != 0: if mavgen.mavgen(mavgen_options(), [xml]):
# ignore if there was a signal to the interpreter rather return 0
# than a real error in the script. Some environments use a return 1
# signed and some an unsigned return for this
if ret > 128 or ret < 0:
Logs.warn('mavgen crashed with code: {}'.format(ret))
ret = 0
else:
Logs.error('mavgen returned {} error code'.format(ret))
return ret
def post_run(self): def post_run(self):
super(mavgen, self).post_run() super(mavgen, self).post_run()