ctdb-daemon: Use ctdb_parse_node_address() in ctdbd
[samba4-gss.git] / third_party / waf / waflib / extras / objcopy.py
blobbb7ca6ef224c4b625e7273906096019f40c4d6e0
1 #!/usr/bin/python
2 # Grygoriy Fuchedzhy 2010
4 """
5 Support for converting linked targets to ihex, srec or binary files using
6 objcopy. Use the 'objcopy' feature in conjunction with the 'cc' or 'cxx'
7 feature. The 'objcopy' feature uses the following attributes:
9 objcopy_bfdname Target object format name (eg. ihex, srec, binary).
10 Defaults to ihex.
11 objcopy_target File name used for objcopy output. This defaults to the
12 target name with objcopy_bfdname as extension.
13 objcopy_install_path Install path for objcopy_target file. Defaults to ${PREFIX}/fw.
14 objcopy_flags Additional flags passed to objcopy.
15 """
17 from waflib.Utils import def_attrs
18 from waflib import Task, Options
19 from waflib.TaskGen import feature, after_method
21 class objcopy(Task.Task):
22 run_str = '${OBJCOPY} -O ${TARGET_BFDNAME} ${OBJCOPYFLAGS} ${SRC} ${TGT}'
23 color = 'CYAN'
25 @feature('objcopy')
26 @after_method('apply_link')
27 def map_objcopy(self):
28 def_attrs(self,
29 objcopy_bfdname = 'ihex',
30 objcopy_target = None,
31 objcopy_install_path = "${PREFIX}/firmware",
32 objcopy_flags = '')
34 link_output = self.link_task.outputs[0]
35 if not self.objcopy_target:
36 self.objcopy_target = link_output.change_ext('.' + self.objcopy_bfdname).name
37 task = self.create_task('objcopy', src=link_output, tgt=self.path.find_or_declare(self.objcopy_target))
39 task.env.append_unique('TARGET_BFDNAME', self.objcopy_bfdname)
40 try:
41 task.env.append_unique('OBJCOPYFLAGS', getattr(self, 'objcopy_flags'))
42 except AttributeError:
43 pass
45 if self.objcopy_install_path:
46 self.add_install_files(install_to=self.objcopy_install_path, install_from=task.outputs[0])
48 def configure(ctx):
49 program_name = 'objcopy'
50 prefix = getattr(Options.options, 'cross_prefix', None)
51 if prefix:
52 program_name = '{}-{}'.format(prefix, program_name)
53 ctx.find_program(program_name, var='OBJCOPY', mandatory=True)