Move waf into third_party/.
[samba.git] / third_party / waf / wafadmin / Tools / nasm.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2008
4
5 """
6 Nasm processing
7 """
8
9 import os
10 import TaskGen, Task, Utils
11 from TaskGen import taskgen, before, extension
12
13 nasm_str = '${NASM} ${NASM_FLAGS} ${NASM_INCLUDES} ${SRC} -o ${TGT}'
14
15 EXT_NASM = ['.s', '.S', '.asm', '.ASM', '.spp', '.SPP']
16
17 @before('apply_link')
18 def apply_nasm_vars(self):
19
20         # flags
21         if hasattr(self, 'nasm_flags'):
22                 for flag in self.to_list(self.nasm_flags):
23                         self.env.append_value('NASM_FLAGS', flag)
24
25         # includes - well, if we suppose it works with c processing
26         if hasattr(self, 'includes'):
27                 for inc in self.to_list(self.includes):
28                         node = self.path.find_dir(inc)
29                         if not node:
30                                 raise Utils.WafError('cannot find the dir' + inc)
31                         self.env.append_value('NASM_INCLUDES', '-I%s' % node.srcpath(self.env))
32                         self.env.append_value('NASM_INCLUDES', '-I%s' % node.bldpath(self.env))
33
34 @extension(EXT_NASM)
35 def nasm_file(self, node):
36         try: obj_ext = self.obj_ext
37         except AttributeError: obj_ext = '_%d.o' % self.idx
38
39         task = self.create_task('nasm', node, node.change_ext(obj_ext))
40         self.compiled_tasks.append(task)
41
42         self.meths.append('apply_nasm_vars')
43
44 # create our action here
45 Task.simple_task_type('nasm', nasm_str, color='BLUE', ext_out='.o', shell=False)
46
47 def detect(conf):
48         nasm = conf.find_program(['nasm', 'yasm'], var='NASM', mandatory=True)