ref: a60f790b4adbaa7dc43288df401ac23ebc010d97
parent: dfe058a0aceb47abf80d5eb24670b81ad756eaf7
parent: a500a392927f97e328e52dc8b8c77187191f7fac
author: Paul Brossier <piem@piem.org>
date: Tue Oct 3 12:18:49 EDT 2017
Merge branch 'winsymdef' (closes #126, closes waf-project/waf#2053)
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -64,5 +64,3 @@
- "python waf distclean"
# build libaubio
- python waf configure build --verbose --msvc_version="msvc 14.0"
- # build python module using libaubio dll
- - "python setup.py build"
--- a/scripts/build_mingw
+++ b/scripts/build_mingw
@@ -80,10 +80,7 @@
./waf distclean configure build install $WAFOPTS_TGT --testcmd='echo %s'
# fix dll location (see https://github.com/waf-project/waf/issues/1860)
mv $DESTDIR/lib/libaubio-5.dll $DESTDIR/bin
- # generate def file (see https://github.com/aubio/aubio/issues/97)
- ( echo -e "EXPORTS"; $NM $DESTDIR/bin/libaubio-5.dll | grep T\ | \
- egrep "(aubio|fvec|cvec|lvec|fmat)" | sed 's/^.* T _\?//' ) \
- > $DESTDIR/bin/libaubio-5.def
+ mv $DESTDIR/lib/libaubio-5.def $DESTDIR/bin
zip -r $DESTDIR.zip `basename $DESTDIR`
rm -rf $DESTDIR
sha256sum $DESTDIR.zip > $DESTDIR.zip.sha256
--- a/scripts/get_waf.sh
+++ b/scripts/get_waf.sh
@@ -22,7 +22,7 @@
tar xf $WAFTARBALL
pushd waf-$WAFVERSION
- NOCLIMB=1 python waf-light --tools=c_emscripten,syms $*
+ NOCLIMB=1 python waf-light --tools=c_emscripten $*
popd
popd
--- a/src/wscript_build
+++ b/src/wscript_build
@@ -25,7 +25,7 @@
if ctx.env['DEST_OS'] in ['ios', 'iosimulator']:
build_features = ['cstlib', 'cshlib']
elif ctx.env['DEST_OS'] in ['win32', 'win64']:
- build_features = ['cstlib', 'cshlib']
+ build_features = ['cstlib', 'cshlib gensyms']
elif ctx.env['DEST_OS'] in ['emscripten']:
build_features = ['cstlib','cshlib']
elif '--static' in ctx.env['LDFLAGS'] or '--static' in ctx.env['LINKFLAGS']:
@@ -37,13 +37,13 @@
# also install static lib
from waflib.Tools.c import cstlib
-from waflib.Tools.fc import fcstlib
-fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}'
+cstlib.inst_to = '${LIBDIR}'
for target in build_features:
ctx(features = 'c ' + target,
use = uselib + ['lib_objects'],
target = 'aubio',
+ export_symbols_regex=r'(?:.*aubio|fvec|lvec|cvec|fmat|new|del)_.*',
vnum = ctx.env['LIB_VERSION'])
# install headers, except _priv.h ones
--- /dev/null
+++ b/waf_gensyms.py
@@ -1,0 +1,40 @@
+import re
+import os.path
+from waflib import TaskGen, Task
+from waflib.Context import STDOUT
+from waflib.Utils import O644
+
+class gen_sym_file(Task.Task):
+ color = 'BLUE'
+ inst_to = '${LIBDIR}'
+ def run(self):
+ syms = {}
+ reg = getattr(self.generator, 'export_symbols_regex','.+?')
+ if 'msvc' in self.env.CC_NAME:
+ outputs = [x.abspath() for x in self.generator.link_task.outputs]
+ binary_path = list(filter(lambda x: x.endswith('lib'), outputs))[0]
+ reg_compiled = re.compile(r'External\s+\|\s+(?P<symbol>%s)\b' % reg)
+ cmd =(self.env.LINK_CC) + ['/dump', '/symbols', binary_path]
+ else: # using gcc? assume we have nm
+ outputs = [x.abspath() for x in self.generator.link_task.outputs]
+ binary_path = list(filter(lambda x: x.endswith('dll'), outputs))[0]
+ reg_compiled = re.compile(r'(T|D)\s+_(?P<symbol>%s)\b'%reg)
+ cmd = (self.env.NM or ['nm']) + ['-g', binary_path]
+ dump_output = self.generator.bld.cmd_and_log(cmd, quiet=STDOUT)
+ syms = set([])
+ for m in reg_compiled.finditer(dump_output):
+ syms.add(m.group('symbol'))
+ syms = list(syms)
+ syms.sort()
+ self.outputs[0].write('EXPORTS\n'+'\n'.join(syms))
+
+@TaskGen.feature('gensyms')
+@TaskGen.after_method('process_source','process_use','apply_link','process_uselib_local','propagate_uselib_vars')
+def gen_symbols(self):
+ #sym_file = self.path.find_or_declare(self.target + '.def')
+ sym_file_name = os.path.splitext(self.link_task.outputs[0].abspath())[0] + '.def'
+ sym_file = self.path.find_or_declare(sym_file_name)
+ symtask = self.create_task('gen_sym_file', self.link_task.outputs, sym_file)
+ self.add_install_files(install_to=self.link_task.inst_to, install_from=sym_file,
+ chmod=O644, task=self.link_task)
+
--- a/wscript
+++ b/wscript
@@ -103,6 +103,7 @@
ctx.load('compiler_c')
ctx.load('waf_unit_test')
ctx.load('gnu_dirs')
+ ctx.load('waf_gensyms', tooldir='.')
def configure(ctx):
target_platform = sys.platform
@@ -118,6 +119,7 @@
ctx.load('waf_unit_test')
ctx.load('gnu_dirs')
+ ctx.load('waf_gensyms', tooldir='.')
# check for common headers
ctx.check(header_name='stdlib.h')