1 | #! /usr/bin/env python |
---|
2 | # encoding: utf-8 |
---|
3 | # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file |
---|
4 | |
---|
5 | import re,traceback |
---|
6 | from waflib import Task,Logs,Utils |
---|
7 | from waflib.TaskGen import extension |
---|
8 | from waflib.Tools import c_preproc |
---|
9 | @extension('.rc') |
---|
10 | def rc_file(self,node): |
---|
11 | obj_ext='.rc.o' |
---|
12 | if self.env['WINRC_TGT_F']=='/fo': |
---|
13 | obj_ext='.res' |
---|
14 | rctask=self.create_task('winrc',node,node.change_ext(obj_ext)) |
---|
15 | try: |
---|
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) |
---|
27 | ret=[] |
---|
28 | for m in re.finditer(re_lines,code): |
---|
29 | if m.group(2): |
---|
30 | ret.append((m.group(2),m.group(3))) |
---|
31 | else: |
---|
32 | ret.append(('include',m.group(5))) |
---|
33 | return ret |
---|
34 | def addlines(self,node): |
---|
35 | self.currentnode_stack.append(node.parent) |
---|
36 | filepath=node.abspath() |
---|
37 | self.count_files+=1 |
---|
38 | if self.count_files>c_preproc.recursion_limit: |
---|
39 | raise c_preproc.PreprocError("recursion limit exceeded") |
---|
40 | pc=self.parse_cache |
---|
41 | Logs.debug('preproc: reading file %r',filepath) |
---|
42 | try: |
---|
43 | lns=pc[filepath] |
---|
44 | except KeyError: |
---|
45 | pass |
---|
46 | else: |
---|
47 | self.lines.extend(lns) |
---|
48 | return |
---|
49 | try: |
---|
50 | lines=self.filter_comments(filepath) |
---|
51 | lines.append((c_preproc.POPFILE,'')) |
---|
52 | lines.reverse() |
---|
53 | pc[filepath]=lines |
---|
54 | self.lines.extend(lines) |
---|
55 | except IOError: |
---|
56 | raise c_preproc.PreprocError("could not read the file %s"%filepath) |
---|
57 | except Exception: |
---|
58 | if Logs.verbose>0: |
---|
59 | Logs.error("parsing %s failed"%filepath) |
---|
60 | traceback.print_exc() |
---|
61 | class winrc(Task.Task): |
---|
62 | run_str='${WINRC} ${WINRCFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}' |
---|
63 | color='BLUE' |
---|
64 | def scan(self): |
---|
65 | tmp=rc_parser(self.generator.includes_nodes) |
---|
66 | tmp.start(self.inputs[0],self.env) |
---|
67 | nodes=tmp.nodes |
---|
68 | names=tmp.names |
---|
69 | if Logs.verbose: |
---|
70 | Logs.debug('deps: deps for %s: %r; unresolved %r'%(str(self),nodes,names)) |
---|
71 | return(nodes,names) |
---|
72 | def configure(conf): |
---|
73 | v=conf.env |
---|
74 | v['WINRC_TGT_F']='-o' |
---|
75 | v['WINRC_SRC_F']='-i' |
---|
76 | if not conf.env.WINRC: |
---|
77 | if v.CC_NAME=='msvc': |
---|
78 | conf.find_program('RC',var='WINRC',path_list=v['PATH']) |
---|
79 | v['WINRC_TGT_F']='/fo' |
---|
80 | v['WINRC_SRC_F']='' |
---|
81 | else: |
---|
82 | conf.find_program('windres',var='WINRC',path_list=v['PATH']) |
---|
83 | if not conf.env.WINRC: |
---|
84 | conf.fatal('winrc was not found!') |
---|
85 | v['WINRCFLAGS']=[] |
---|