Skip to content

Commit a9ea760

Browse files
tpwrulestridge
authored andcommitted
Tools/ardupilotwaf: improve dronecangen dependency tracking
Have the build depend on the input message definition files and the generator source code so that the code is regenerated if either change.
1 parent 12a1063 commit a9ea760

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Tools/ardupilotwaf/dronecangen.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def run(self):
2020
python = self.env.get_flat('PYTHON')
2121
out = self.env.get_flat('OUTPUT_DIR')
2222
src = self.env.get_flat('SRC')
23-
dsdlc = self.env.get_flat("DC_DSDL_COMPILER")
23+
dsdlc = self.env.get_flat("DC_DSDL_COMPILER_DIR")
2424

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

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

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

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

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

0 commit comments

Comments
 (0)