Skip to content

Commit

Permalink
Tools/ardupilotwaf: improve dronecangen dependency tracking
Browse files Browse the repository at this point in the history
Have the build depend on the input message definition files and the
generator source code so that the code is regenerated if either change.
  • Loading branch information
tpwrules authored and tridge committed Sep 17, 2024
1 parent 12a1063 commit a9ea760
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Tools/ardupilotwaf/dronecangen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def run(self):
python = self.env.get_flat('PYTHON')
out = self.env.get_flat('OUTPUT_DIR')
src = self.env.get_flat('SRC')
dsdlc = self.env.get_flat("DC_DSDL_COMPILER")
dsdlc = self.env.get_flat("DC_DSDL_COMPILER_DIR")

cmd = ['{}'.format(python),
'{}'.format(dsdlc),
'{}/dronecan_dsdlc.py'.format(dsdlc),
'-O{}'.format(out)] + [x.abspath() for x in self.inputs]
ret = self.exec_command(cmd)
if ret != 0:
Expand Down Expand Up @@ -55,6 +55,16 @@ def process_dronecangen(self):
self.bld.fatal('dronecangen: missing option output_dir')

inputs = self.to_nodes(self.source)
# depend on each message file in the source so rebuilds will occur properly
deps = []
for inp in inputs:
deps.extend(inp.ant_glob("**/*.uavcan"))
# also depend on the generator source itself
dsdlc_dir = self.env.get_flat("DC_DSDL_COMPILER_DIR")
dsdlc = self.bld.root.find_node(dsdlc_dir) # expected to be absolute
if dsdlc is None:
self.bld.fatal("dronecangen: waf couldn't find dsdlc at abspath {}".format(dsdlc_dir))
deps.extend(dsdlc.ant_glob("**/*.py **/*.em"))
outputs = []

self.source = []
Expand All @@ -63,6 +73,7 @@ def process_dronecangen(self):
self.output_dir = self.bld.bldnode.find_or_declare(self.output_dir)

task = self.create_task('dronecangen', inputs, outputs)
task.dep_nodes = deps
task.env['OUTPUT_DIR'] = self.output_dir.abspath()

task.env.env = dict(os.environ)
Expand All @@ -73,5 +84,4 @@ def configure(cfg):
"""
env = cfg.env
env.DC_DSDL_COMPILER_DIR = cfg.srcnode.make_node('modules/DroneCAN/dronecan_dsdlc/').abspath()
env.DC_DSDL_COMPILER = env.DC_DSDL_COMPILER_DIR + '/dronecan_dsdlc.py'
cfg.msg('DC_DSDL compiler', env.DC_DSDL_COMPILER)
cfg.msg('DC_DSDL compiler in', env.DC_DSDL_COMPILER_DIR)

0 comments on commit a9ea760

Please sign in to comment.