lib: Convert [up|low]case.dat to C
[Samba.git] / buildtools / wafadmin / Tools / nasm.py
blobb99c3c7340460f51433c2aa982b4ac8827213a46
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2008
5 """
6 Nasm processing
7 """
9 import os
10 import TaskGen, Task, Utils
11 from TaskGen import taskgen, before, extension
13 nasm_str = '${NASM} ${NASM_FLAGS} ${NASM_INCLUDES} ${SRC} -o ${TGT}'
15 EXT_NASM = ['.s', '.S', '.asm', '.ASM', '.spp', '.SPP']
17 @before('apply_link')
18 def apply_nasm_vars(self):
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)
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))
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
39 task = self.create_task('nasm', node, node.change_ext(obj_ext))
40 self.compiled_tasks.append(task)
42 self.meths.append('apply_nasm_vars')
44 # create our action here
45 Task.simple_task_type('nasm', nasm_str, color='BLUE', ext_out='.o', shell=False)
47 def detect(conf):
48 nasm = conf.find_program(['nasm', 'yasm'], var='NASM', mandatory=True)