From e5a21cd459475634fdeff60d89df00c04544ded5 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 9 May 2016 22:14:30 -0300 Subject: [PATCH] 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. --- Tools/ardupilotwaf/mavgen.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Tools/ardupilotwaf/mavgen.py b/Tools/ardupilotwaf/mavgen.py index ad8d2acf72..d98fbf79be 100644 --- a/Tools/ardupilotwaf/mavgen.py +++ b/Tools/ardupilotwaf/mavgen.py @@ -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):