From a9ea760cadfddf39434cb3b7dbcf8533f6c4fb1a Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 14 Sep 2024 13:19:34 -0500 Subject: [PATCH] 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. --- Tools/ardupilotwaf/dronecangen.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Tools/ardupilotwaf/dronecangen.py b/Tools/ardupilotwaf/dronecangen.py index 1ba2a10941e54..f7c4a6179abdd 100644 --- a/Tools/ardupilotwaf/dronecangen.py +++ b/Tools/ardupilotwaf/dronecangen.py @@ -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: @@ -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 = [] @@ -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) @@ -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)