[0e355f6] | 1 | # vim:set syntax=python: |
---|
| 2 | |
---|
[eae5898] | 3 | uselib = [] |
---|
[ccc55bd] | 4 | uselib += ['M'] |
---|
[0318cc1] | 5 | uselib += ['FFTW3', 'FFTW3F'] |
---|
[379ef6c] | 6 | uselib += ['INTEL_IPP'] |
---|
[0318cc1] | 7 | uselib += ['SAMPLERATE'] |
---|
| 8 | uselib += ['SNDFILE'] |
---|
[ba0ba10] | 9 | uselib += ['AVCODEC'] |
---|
| 10 | uselib += ['AVFORMAT'] |
---|
[cd133ba] | 11 | uselib += ['SWRESAMPLE'] |
---|
[ba0ba10] | 12 | uselib += ['AVRESAMPLE'] |
---|
| 13 | uselib += ['AVUTIL'] |
---|
[f0ce36a1] | 14 | uselib += ['BLAS'] |
---|
[eae5898] | 15 | |
---|
[dc0e759] | 16 | source = ctx.path.ant_glob('*.c **/*.c') |
---|
[ccc55bd] | 17 | |
---|
[985a5d1] | 18 | ctx(features = 'c', |
---|
[dc0e759] | 19 | source = source, |
---|
| 20 | includes = ['.'], |
---|
[ccc55bd] | 21 | use = uselib, |
---|
[dc0e759] | 22 | target = 'lib_objects') |
---|
[afbd7e7] | 23 | |
---|
[985a5d1] | 24 | # build libaubio.so (cshlib) and/or libaubio.a (cstlib) |
---|
[19ddbf3] | 25 | if ctx.env['DEST_OS'] in ['ios', 'iosimulator']: |
---|
[a90e9d4] | 26 | build_features = ['cstlib', 'cshlib'] |
---|
[06dba46] | 27 | elif ctx.env['DEST_OS'] in ['win32', 'win64']: |
---|
[f2f9d8b] | 28 | build_features = ['cstlib', 'cshlib gensyms'] |
---|
[fb5838a] | 29 | elif ctx.env['DEST_OS'] in ['emscripten']: |
---|
[8f343e6] | 30 | build_features = ['cstlib','cshlib'] |
---|
[0ec7113] | 31 | elif '--static' in ctx.env['LDFLAGS'] or '--static' in ctx.env['LINKFLAGS']: |
---|
| 32 | # static in cflags, ... |
---|
| 33 | build_features = ['cstlib'] |
---|
| 34 | else: |
---|
| 35 | # linux, darwin, android, mingw, ... |
---|
[3bf80b9] | 36 | build_features = ['cstlib', 'cshlib'] |
---|
[b712146] | 37 | |
---|
[8698499] | 38 | # also install static lib |
---|
| 39 | from waflib.Tools.c import cstlib |
---|
| 40 | from waflib.Tools.fc import fcstlib |
---|
| 41 | fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}' |
---|
| 42 | |
---|
[f2f9d8b] | 43 | import re |
---|
| 44 | from waflib import TaskGen, Task |
---|
| 45 | from waflib.Context import STDOUT |
---|
| 46 | from waflib.Utils import O644 |
---|
| 47 | |
---|
| 48 | class 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 | if 'msvc' in self.env.CC_NAME: |
---|
[8774047] | 55 | outputs = [x.abspath() for x in self.generator.link_task.outputs] |
---|
| 56 | binary_path = list(filter(lambda x: x.endswith('lib'), outputs))[0] |
---|
| 57 | reg_compiled = re.compile(r'External\s+\|\s+(?P<symbol>%s)\b' % reg) |
---|
| 58 | cmd =(self.env.LINK_CC) + ['/dump', '/symbols', binary_path] |
---|
[f2f9d8b] | 59 | else: # using gcc? assume we have nm |
---|
[8774047] | 60 | binary_path = self.generator.link_task.outputs[0].abspath() |
---|
[f2f9d8b] | 61 | reg_compiled = re.compile(r'(T|D)\s+_(?P<symbol>%s)\b'%reg) |
---|
| 62 | cmd = (self.env.NM or ['nm']) + ['-g', binary_path] |
---|
| 63 | dump_output = self.generator.bld.cmd_and_log(cmd, quiet=STDOUT) |
---|
[8774047] | 64 | syms = set([]) |
---|
[f2f9d8b] | 65 | for m in reg_compiled.finditer(dump_output): |
---|
[8774047] | 66 | syms.add(m.group('symbol')) |
---|
| 67 | syms = list(syms) |
---|
| 68 | syms.sort() |
---|
[f2f9d8b] | 69 | self.outputs[0].write('EXPORTS\n'+'\n'.join(syms)) |
---|
| 70 | |
---|
| 71 | @TaskGen.feature('gensyms') |
---|
| 72 | @TaskGen.after_method('process_source','process_use','apply_link','process_uselib_local','propagate_uselib_vars') |
---|
| 73 | def gen_symbols(self): |
---|
| 74 | #sym_file = self.path.find_or_declare(self.target + '.def') |
---|
| 75 | sym_file_name = os.path.splitext(self.link_task.outputs[0].abspath())[0] + '.def' |
---|
| 76 | sym_file = self.path.find_or_declare(sym_file_name) |
---|
| 77 | symtask = self.create_task('gen_sym_file', self.link_task.outputs, sym_file) |
---|
| 78 | self.add_install_files(install_to=self.link_task.inst_to, install_from=sym_file, |
---|
| 79 | chmod=O644, task=self.link_task) |
---|
| 80 | |
---|
[7fd1831] | 81 | for target in build_features: |
---|
[dc0e759] | 82 | ctx(features = 'c ' + target, |
---|
[ccc55bd] | 83 | use = uselib + ['lib_objects'], |
---|
[dc0e759] | 84 | target = 'aubio', |
---|
[8774047] | 85 | export_symbols_regex=r'(?:.*aubio|fvec|lvec|cvec|fmat|new|del)_.*', |
---|
[dc0e759] | 86 | vnum = ctx.env['LIB_VERSION']) |
---|
[000b090] | 87 | |
---|
| 88 | # install headers, except _priv.h ones |
---|
[0ec7113] | 89 | ctx.install_files('${INCLUDEDIR}/aubio/', |
---|
[dc0e759] | 90 | ctx.path.ant_glob('**/*.h', excl = ['**_priv.h', 'config.h']), |
---|
| 91 | relative_trick=True) |
---|