Changeset f2f9d8b for src


Ignore:
Timestamp:
Oct 3, 2017, 9:07:14 AM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
8774047
Parents:
dfe058a0
Message:

src/wscript_build: add task to create def file on windows, inspired by waf/extras/syms (see #126 and waf-project/waf#2053)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/wscript_build

    rdfe058a0 rf2f9d8b  
    2626    build_features = ['cstlib', 'cshlib']
    2727elif ctx.env['DEST_OS'] in ['win32', 'win64']:
    28     build_features = ['cstlib', 'cshlib']
     28    build_features = ['cstlib', 'cshlib gensyms']
    2929elif ctx.env['DEST_OS'] in ['emscripten']:
    3030    build_features = ['cstlib','cshlib']
     
    4141fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}'
    4242
     43import re
     44from waflib import TaskGen, Task
     45from waflib.Context import STDOUT
     46from waflib.Utils import O644
     47
     48class gen_sym_file(Task.Task):
     49    color = 'BLUE'
     50    inst_to = '${LIBDIR}'
     51    def run(self):
     52        syms = {}
     53        reg = getattr(self.generator, 'export_symbols_regex','.+?')
     54        binary_path = self.generator.link_task.outputs[0].abspath()
     55        if 'msvc' in self.env.CC_NAME:
     56            reg_compiled = re.compile(r'External\s+\|\s+_(?P<symbol>%s)\b' % reg)
     57            cmd =(self.env.DUMPBIN or['dumpbin'])+['/symbols', binary_path]
     58        else: # using gcc? assume we have nm
     59            reg_compiled = re.compile(r'(T|D)\s+_(?P<symbol>%s)\b'%reg)
     60            cmd = (self.env.NM or ['nm']) + ['-g', binary_path]
     61        print (cmd)
     62        dump_output = self.generator.bld.cmd_and_log(cmd, quiet=STDOUT)
     63        print (dump_output)
     64        syms = []
     65        for m in reg_compiled.finditer(dump_output):
     66            syms += [m.group('symbol')]
     67            print (m.group('symbol'))
     68        self.outputs[0].write('EXPORTS\n'+'\n'.join(syms))
     69
     70@TaskGen.feature('gensyms')
     71@TaskGen.after_method('process_source','process_use','apply_link','process_uselib_local','propagate_uselib_vars')
     72def gen_symbols(self):
     73    #sym_file = self.path.find_or_declare(self.target + '.def')
     74    sym_file_name = os.path.splitext(self.link_task.outputs[0].abspath())[0] + '.def'
     75    sym_file = self.path.find_or_declare(sym_file_name)
     76    symtask = self.create_task('gen_sym_file', self.link_task.outputs, sym_file)
     77    self.add_install_files(install_to=self.link_task.inst_to, install_from=sym_file,
     78        chmod=O644, task=self.link_task)
     79
    4380for target in build_features:
    4481    ctx(features = 'c ' + target,
    4582            use = uselib + ['lib_objects'],
    4683            target = 'aubio',
     84            export_symbols_regex=r'(?:.*aubio|fvec|lvec|cvec|fmat)_.*',
    4785            vnum = ctx.env['LIB_VERSION'])
    4886
Note: See TracChangeset for help on using the changeset viewer.