3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
6 from waflib import Utils,Logs
7 def filter_comments(filename):
8 txt=Utils.readf(filename)
16 buf.append(txt[begin:i])
28 buf.append(txt[begin:i])
39 if prev=='/'and c=='+':
42 elif prev=='+'and c=='/':
53 if prev=='*'and c=='/':break
57 while i<max and txt[i]!='\n':
67 buf.append(txt[begin:])
69 class d_parser(object):
70 def __init__(self,env,incpaths):
72 self.re_module=re.compile("module\s+([^;]+)")
73 self.re_import=re.compile("import\s+([^;]+)")
74 self.re_import_bindings=re.compile("([^:]+):(.*)")
75 self.re_import_alias=re.compile("[^=]+=(.+)")
79 self.incpaths=incpaths
80 def tryfind(self,filename):
82 for n in self.incpaths:
83 found=n.find_resource(filename.replace('.','/')+'.d')
85 self.nodes.append(found)
86 self.waiting.append(found)
89 if not filename in self.names:
90 self.names.append(filename)
91 def get_strings(self,code):
94 mod_name=self.re_module.search(code)
96 self.module=re.sub('\s+','',mod_name.group(1))
97 import_iterator=self.re_import.finditer(code)
99 for import_match in import_iterator:
100 import_match_str=re.sub('\s+','',import_match.group(1))
101 bindings_match=self.re_import_bindings.match(import_match_str)
103 import_match_str=bindings_match.group(1)
104 matches=import_match_str.split(',')
105 for match in matches:
106 alias_match=self.re_import_alias.match(match)
108 match=alias_match.group(1)
111 def start(self,node):
114 nd=self.waiting.pop(0)
118 code="".join(filter_comments(path))
119 names=self.get_strings(code)
121 if x in self.allnames:continue
122 self.allnames.append(x)
126 gruik=d_parser(env,self.generator.includes_nodes)
132 Logs.debug('deps: deps for %s: %r; unresolved %r'%(str(node),nodes,names))