third_party/waf: upgrade to waf 2.0.8
[samba.git] / third_party / waf / waflib / Tools / asm.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2008-2018 (ita)
4
5 """
6 Assembly support, used by tools such as gas and nasm
7
8 To declare targets using assembly::
9
10         def configure(conf):
11                 conf.load('gcc gas')
12
13         def build(bld):
14                 bld(
15                         features='c cstlib asm',
16                         source = 'test.S',
17                         target = 'asmtest')
18
19                 bld(
20                         features='asm asmprogram',
21                         source = 'test.S',
22                         target = 'asmtest')
23
24 Support for pure asm programs and libraries should also work::
25
26         def configure(conf):
27                 conf.load('nasm')
28                 conf.find_program('ld', 'ASLINK')
29
30         def build(bld):
31                 bld(
32                         features='asm asmprogram',
33                         source = 'test.S',
34                         target = 'asmtest')
35 """
36
37 from waflib import Task
38 from waflib.Tools.ccroot import link_task, stlink_task
39 from waflib.TaskGen import extension
40
41 class asm(Task.Task):
42         """
43         Compiles asm files by gas/nasm/yasm/...
44         """
45         color = 'BLUE'
46         run_str = '${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
47
48 @extension('.s', '.S', '.asm', '.ASM', '.spp', '.SPP')
49 def asm_hook(self, node):
50         """
51         Binds the asm extension to the asm task
52
53         :param node: input file
54         :type node: :py:class:`waflib.Node.Node`
55         """
56         return self.create_compiled_task('asm', node)
57
58 class asmprogram(link_task):
59         "Links object files into a c program"
60         run_str = '${ASLINK} ${ASLINKFLAGS} ${ASLNK_TGT_F}${TGT} ${ASLNK_SRC_F}${SRC}'
61         ext_out = ['.bin']
62         inst_to = '${BINDIR}'
63
64 class asmshlib(asmprogram):
65         "Links object files into a c shared library"
66         inst_to = '${LIBDIR}'
67
68 class asmstlib(stlink_task):
69         "Links object files into a c static library"
70         pass # do not remove
71
72 def configure(conf):
73         conf.env.ASMPATH_ST = '-I%s'