waf: allow mavgen to segfault without failing

This is a hackish way to allow waf running on windows. In some
combinations of the tools the python interpreter seems to be crashing on
windows:

	Found 180 MAVLink message types in 2 XML files
	Generating C implementation in directory /tmp/ArduPlane.build/libraries/GCS_MAVLink/include/mavlink/v1.0/ardupilotmega
	Generating C implementation in directory /tmp/ArduPlane.build/libraries/GCS_MAVLink/include/mavlink/v1.0/common
	Copying fixed headers
	last line in mavgen.py
	Aborted (core dumped)

	michael@WIN-3NBOUTHN4TN /cygdrive/c/Users/michael/Desktop/DIYDrones/ardupilot/ArduPlane
	$ echo $?
	134

Here we check the return code to be greater than 128 since that means the
interpreter received a signal. In this case we clear the return code.
This commit is contained in:
Lucas De Marchi 2016-05-09 22:14:30 -03:00 committed by Andrew Tridgell
parent 50908edc91
commit e5a21cd459
1 changed files with 18 additions and 2 deletions

View File

@ -6,16 +6,32 @@
The **mavgen.py** program is a code generator which creates mavlink header files.
"""
from waflib import Task, Utils, Node
from waflib import Logs, Task, Utils, Node
from waflib.TaskGen import feature, before_method, extension
import os
class mavgen(Task.Task):
"""generate mavlink header files"""
color = 'BLUE'
run_str = '${PYTHON} ${MAVGEN} --lang=C --wire-protocol=1.0 --output ${OUTPUT_DIR} ${SRC}'
before = 'cxx c'
def run(self):
python = self.env.get_flat('PYTHON')
mavgen = self.env.get_flat('MAVGEN')
out = self.env.get_flat('OUTPUT_DIR')
src = self.env.get_flat('SRC')
ret = self.exec_command('{} {} --lang=C --wire-protocol=1.0 --output {} {}'.format(
python, mavgen, out, self.inputs[0].abspath()))
if ret != 0:
# ignore if there was a signal to the interpreter rather than a real error in the script
if ret > 128:
Logs.warning('mavgen crashed with code: {}'.format(ret))
ret = 0
else:
Logs.error('mavgen returned {} error code'.format(ret))
return ret
def post_run(self):
super(mavgen, self).post_run()
for header in self.generator.output_dir.ant_glob("*.h **/*.h", remove=False):