waf: mavgen: use output_dir instead of target

The option target for the waf task generator is meant for actual files that are
going to be build. Since our target files are dynamic, let's change the code to
use a new parameter output_dir instead.
This commit is contained in:
Gustavo Jose de Sousa 2016-01-14 14:32:26 -02:00 committed by Andrew Tridgell
parent 282c254897
commit 46449ee032
2 changed files with 9 additions and 8 deletions

View File

@ -13,7 +13,7 @@ import os
class mavgen(Task.Task): class mavgen(Task.Task):
"""generate mavlink header files""" """generate mavlink header files"""
color = 'GREEN' color = 'GREEN'
run_str = '${PYTHON} ${MAVGEN} --lang=C --wire-protocol=1.0 --output ${TGT} ${SRC}' run_str = '${PYTHON} ${MAVGEN} --lang=C --wire-protocol=1.0 --output ${OUTPUT_DIR} ${SRC}'
before = 'cxx c' before = 'cxx c'
def post_run(self): def post_run(self):
@ -27,18 +27,19 @@ def options(opt):
@feature('mavgen') @feature('mavgen')
@before_method('process_source') @before_method('process_source')
def process_mavgen(self): def process_mavgen(self):
if not hasattr(self, 'output_dir'):
self.bld.fatal('mavgen: missing option output_dir')
inputs = self.to_nodes(self.source) inputs = self.to_nodes(self.source)
outputs = [] outputs = []
self.target = Utils.to_list(getattr(self, 'target', []))
for t in self.target:
if not isinstance(t, Node.Node):
t = self.bld.bldnode.find_or_declare(t)
outputs.append(t)
self.source = [] self.source = []
if not isinstance(self.output_dir, Node.Node):
self.output_dir = self.bld.bldnode.find_or_declare(self.output_dir)
task = self.create_task('mavgen', inputs, outputs) task = self.create_task('mavgen', inputs, outputs)
task.env['OUTPUT_DIR'] = self.output_dir.abspath()
task.env.env = dict(os.environ) task.env.env = dict(os.environ)
task.env.env['PYTHONPATH'] = task.env.MAVLINK_DIR task.env.env['PYTHONPATH'] = task.env.MAVLINK_DIR

View File

@ -122,7 +122,7 @@ def build(bld):
bld( bld(
features='mavgen', features='mavgen',
source='modules/mavlink/message_definitions/v1.0/ardupilotmega.xml', source='modules/mavlink/message_definitions/v1.0/ardupilotmega.xml',
target='libraries/GCS_MAVLink/include/mavlink/v1.0/', output_dir='libraries/GCS_MAVLink/include/mavlink/v1.0/',
name='mavlink', name='mavlink',
# this below is not ideal, mavgen tool should set this, but that's not # this below is not ideal, mavgen tool should set this, but that's not
# currently possible # currently possible