waf: mavgen: scan for implicit dependencies
Process the input file to catch dependencies. Otherwise, changes in included files wouldn't trigger the code regeneration.
This commit is contained in:
parent
0f60c8ed4f
commit
bc62164ac9
@ -9,12 +9,47 @@ The **mavgen.py** program is a code generator which creates mavlink header files
|
||||
from waflib import Logs, Task, Utils, Node
|
||||
from waflib.TaskGen import feature, before_method, extension
|
||||
import os
|
||||
import os.path
|
||||
from xml.etree import ElementTree as et
|
||||
|
||||
class mavgen(Task.Task):
|
||||
"""generate mavlink header files"""
|
||||
color = 'BLUE'
|
||||
before = 'cxx c'
|
||||
|
||||
def scan(self):
|
||||
nodes = []
|
||||
names = []
|
||||
|
||||
entry_point = self.inputs[0]
|
||||
queue = [entry_point]
|
||||
head = 0
|
||||
|
||||
while head < len(queue):
|
||||
node = queue[head]
|
||||
head += 1
|
||||
|
||||
tree = et.parse(node.abspath())
|
||||
root = tree.getroot()
|
||||
includes = root.findall('include')
|
||||
for i in includes:
|
||||
path = i.text.strip()
|
||||
n = node.parent.find_node(path)
|
||||
if n:
|
||||
nodes.append(n)
|
||||
if n not in queue:
|
||||
queue.append(n)
|
||||
continue
|
||||
|
||||
path = os.path.join(
|
||||
node.parent.path_from(entry_point.parent),
|
||||
path
|
||||
)
|
||||
if not path in names:
|
||||
names.append(path)
|
||||
|
||||
return nodes, names
|
||||
|
||||
def run(self):
|
||||
python = self.env.get_flat('PYTHON')
|
||||
mavgen = self.env.get_flat('MAVGEN')
|
||||
|
Loading…
Reference in New Issue
Block a user