ctdb-scripts: Support storing statd-callout state in cluster filesystem
[samba4-gss.git] / third_party / waf / waflib / Tools / asm.py
blob1d34ddaca7ff49aad47cef073a3e6f53c8828330
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2008-2018 (ita)
5 """
6 Assembly support, used by tools such as gas and nasm
8 To declare targets using assembly::
10 def configure(conf):
11 conf.load('gcc gas')
13 def build(bld):
14 bld(
15 features='c cstlib asm',
16 source = 'test.S',
17 target = 'asmtest')
19 bld(
20 features='asm asmprogram',
21 source = 'test.S',
22 target = 'asmtest')
24 Support for pure asm programs and libraries should also work::
26 def configure(conf):
27 conf.load('nasm')
28 conf.find_program('ld', 'ASLINK')
30 def build(bld):
31 bld(
32 features='asm asmprogram',
33 source = 'test.S',
34 target = 'asmtest')
35 """
37 import re
38 from waflib import Errors, Logs, Task
39 from waflib.Tools.ccroot import link_task, stlink_task
40 from waflib.TaskGen import extension
41 from waflib.Tools import c_preproc
43 re_lines = re.compile(
44 '^[ \t]*(?:%)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef)[ \t]*(.*)\r*$',
45 re.IGNORECASE | re.MULTILINE)
47 class asm_parser(c_preproc.c_parser):
48 def filter_comments(self, node):
49 code = node.read()
50 code = c_preproc.re_nl.sub('', code)
51 code = c_preproc.re_cpp.sub(c_preproc.repl, code)
52 return re_lines.findall(code)
54 class asm(Task.Task):
55 """
56 Compiles asm files by gas/nasm/yasm/...
57 """
58 color = 'BLUE'
59 run_str = '${AS} ${ASFLAGS} ${ASMPATH_ST:INCPATHS} ${ASMDEFINES_ST:DEFINES} ${AS_SRC_F}${SRC} ${AS_TGT_F}${TGT}'
61 def scan(self):
62 if self.env.ASM_NAME == 'gas':
63 return c_preproc.scan(self)
64 elif self.env.ASM_NAME == 'nasm':
65 Logs.warn('The Nasm dependency scanner is incomplete!')
67 try:
68 incn = self.generator.includes_nodes
69 except AttributeError:
70 raise Errors.WafError('%r is missing the "asm" feature' % self.generator)
72 if c_preproc.go_absolute:
73 nodepaths = incn
74 else:
75 nodepaths = [x for x in incn if x.is_child_of(x.ctx.srcnode) or x.is_child_of(x.ctx.bldnode)]
77 tmp = asm_parser(nodepaths)
78 tmp.start(self.inputs[0], self.env)
79 return (tmp.nodes, tmp.names)
81 @extension('.s', '.S', '.asm', '.ASM', '.spp', '.SPP')
82 def asm_hook(self, node):
83 """
84 Binds the asm extension to the asm task
86 :param node: input file
87 :type node: :py:class:`waflib.Node.Node`
88 """
89 return self.create_compiled_task('asm', node)
91 class asmprogram(link_task):
92 "Links object files into a c program"
93 run_str = '${ASLINK} ${ASLINKFLAGS} ${ASLNK_TGT_F}${TGT} ${ASLNK_SRC_F}${SRC}'
94 ext_out = ['.bin']
95 inst_to = '${BINDIR}'
97 class asmshlib(asmprogram):
98 "Links object files into a c shared library"
99 inst_to = '${LIBDIR}'
101 class asmstlib(stlink_task):
102 "Links object files into a c static library"
103 pass # do not remove
105 def configure(conf):
106 conf.env.ASMPATH_ST = '-I%s'
107 conf.env.ASMDEFINES_ST = '-D%s'