Move waf into third_party/.
[bbaumbach/samba-autobuild/.git] / third_party / waf / wafadmin / Tools / winres.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Brant Young, 2007
4
5 "This hook is called when the class cpp/cc task generator encounters a '.rc' file: X{.rc -> [.res|.rc.o]}"
6
7 import os, sys, re
8 import TaskGen, Task
9 from Utils import quote_whitespace
10 from TaskGen import extension
11
12 EXT_WINRC = ['.rc']
13
14 winrc_str = '${WINRC} ${_CPPDEFFLAGS} ${_CCDEFFLAGS} ${WINRCFLAGS} ${_CPPINCFLAGS} ${_CCINCFLAGS} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}'
15
16 @extension(EXT_WINRC)
17 def rc_file(self, node):
18         obj_ext = '.rc.o'
19         if self.env['WINRC_TGT_F'] == '/fo': obj_ext = '.res'
20
21         rctask = self.create_task('winrc', node, node.change_ext(obj_ext))
22         self.compiled_tasks.append(rctask)
23
24 # create our action, for use with rc file
25 Task.simple_task_type('winrc', winrc_str, color='BLUE', before='cc cxx', shell=False)
26
27 def detect(conf):
28         v = conf.env
29
30         winrc = v['WINRC']
31         v['WINRC_TGT_F'] = '-o'
32         v['WINRC_SRC_F'] = '-i'
33         # find rc.exe
34         if not winrc:
35                 if v['CC_NAME'] in ['gcc', 'cc', 'g++', 'c++']:
36                         winrc = conf.find_program('windres', var='WINRC', path_list = v['PATH'])
37                 elif v['CC_NAME'] == 'msvc':
38                         winrc = conf.find_program('RC', var='WINRC', path_list = v['PATH'])
39                         v['WINRC_TGT_F'] = '/fo'
40                         v['WINRC_SRC_F'] = ''
41         if not winrc:
42                 conf.fatal('winrc was not found!')
43
44         v['WINRCFLAGS'] = ''