source: waf_gensyms.py @ eba0cc4

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since eba0cc4 was 18ec142, checked in by Paul Brossier <piem@piem.org>, 7 years ago

waf_gensyms.py: move to own file

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[18ec142]1import re
2import os.path
3from waflib import TaskGen, Task
4from waflib.Context import STDOUT
5from waflib.Utils import O644
6
7class gen_sym_file(Task.Task):
8    color = 'BLUE'
9    inst_to = '${LIBDIR}'
10    def run(self):
11        syms = {}
12        reg = getattr(self.generator, 'export_symbols_regex','.+?')
13        if 'msvc' in self.env.CC_NAME:
14            outputs = [x.abspath() for x in self.generator.link_task.outputs]
15            binary_path = list(filter(lambda x: x.endswith('lib'), outputs))[0]
16            reg_compiled = re.compile(r'External\s+\|\s+(?P<symbol>%s)\b' % reg)
17            cmd =(self.env.LINK_CC) + ['/dump', '/symbols', binary_path]
18        else: # using gcc? assume we have nm
19            outputs = [x.abspath() for x in self.generator.link_task.outputs]
20            binary_path = list(filter(lambda x: x.endswith('dll'), outputs))[0]
21            reg_compiled = re.compile(r'(T|D)\s+_(?P<symbol>%s)\b'%reg)
22            cmd = (self.env.NM or ['nm']) + ['-g', binary_path]
23        dump_output = self.generator.bld.cmd_and_log(cmd, quiet=STDOUT)
24        syms = set([])
25        for m in reg_compiled.finditer(dump_output):
26            syms.add(m.group('symbol'))
27        syms = list(syms)
28        syms.sort()
29        self.outputs[0].write('EXPORTS\n'+'\n'.join(syms))
30
31@TaskGen.feature('gensyms')
32@TaskGen.after_method('process_source','process_use','apply_link','process_uselib_local','propagate_uselib_vars')
33def gen_symbols(self):
34    #sym_file = self.path.find_or_declare(self.target + '.def')
35    sym_file_name = os.path.splitext(self.link_task.outputs[0].abspath())[0] + '.def'
36    sym_file = self.path.find_or_declare(sym_file_name)
37    symtask = self.create_task('gen_sym_file', self.link_task.outputs, sym_file)
38    self.add_install_files(install_to=self.link_task.inst_to, install_from=sym_file,
39        chmod=O644, task=self.link_task)
40
Note: See TracBrowser for help on using the repository browser.