3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
6 from waflib import Task,Logs,Utils
7 from waflib.TaskGen import extension
8 from waflib.Tools import c_preproc
10 def rc_file(self,node):
12 if self.env['WINRC_TGT_F']=='/fo':
14 rctask=self.create_task('winrc',node,node.change_ext(obj_ext))
16 self.compiled_tasks.append(rctask)
17 except AttributeError:
18 self.compiled_tasks=[rctask]
19 re_lines=re.compile('(?:^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*?)\s*$)|''(?:^\w+[ \t]*(ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)[ \t]*(.*?)\s*$)',re.IGNORECASE|re.MULTILINE)
20 class rc_parser(c_preproc.c_parser):
21 def filter_comments(self,filepath):
22 code=Utils.readf(filepath)
23 if c_preproc.use_trigraphs:
24 for(a,b)in c_preproc.trig_def:code=code.split(a).join(b)
25 code=c_preproc.re_nl.sub('',code)
26 code=c_preproc.re_cpp.sub(c_preproc.repl,code)
28 for m in re.finditer(re_lines,code):
30 ret.append((m.group(2),m.group(3)))
32 ret.append(('include',m.group(5)))
34 def addlines(self,node):
35 self.currentnode_stack.append(node.parent)
36 filepath=node.abspath()
38 if self.count_files>c_preproc.recursion_limit:
39 raise c_preproc.PreprocError("recursion limit exceeded")
41 Logs.debug('preproc: reading file %r',filepath)
47 self.lines.extend(lns)
50 lines=self.filter_comments(filepath)
51 lines.append((c_preproc.POPFILE,''))
54 self.lines.extend(lines)
56 raise c_preproc.PreprocError("could not read the file %s"%filepath)
59 Logs.error("parsing %s failed"%filepath)
61 class winrc(Task.Task):
62 run_str='${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}'
65 tmp=rc_parser(self.generator.includes_nodes)
66 tmp.start(self.inputs[0],self.env)
70 Logs.debug('deps: deps for %s: %r; unresolved %r'%(str(self),nodes,names))
76 if not conf.env.WINRC:
78 conf.find_program('RC',var='WINRC',path_list=v['PATH'])
79 v['WINRC_TGT_F']='/fo'
82 conf.find_program('windres',var='WINRC',path_list=v['PATH'])
83 if not conf.env.WINRC:
84 conf.fatal('winrc was not found!')