syms.py: allow environment to supply paths to dumpbin and nm

This is required when doing cross-compilation.

Signed-off-by: Thomas Nagy <tnagy2pow10@gmail.com>
This commit is contained in:
Matt Hoosier 2013-06-26 13:35:31 -05:00 committed by Thomas Nagy
parent 5ea64b56ac
commit 24983316d6
1 changed files with 20 additions and 3 deletions

View File

@ -12,6 +12,7 @@ def build(ctx):
only the symbols starting with 'mylib_' will be exported.
"""
import os
import re
from waflib.Context import STDOUT
from waflib.Task import Task
@ -21,16 +22,32 @@ from waflib.TaskGen import feature, after_method
class gen_sym(Task):
def run(self):
obj = self.inputs[0]
kw = {}
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
re_nm = re.compile(r'External\s+\|\s+_(' + self.generator.export_symbols_regex + r')\b')
cmd = ['dumpbin', '/symbols', obj.abspath()]
if 'DUMPBIN' in self.env:
cmd = [self.env['DUMPBIN']]
else:
cmd = ['dumpbin']
cmd += ['/symbols', obj.abspath()]
# Dumpbin requires custom environment sniffed out by msvc.py earlier
if self.env['PATH']:
env = dict(self.env.env or os.environ)
env.update(PATH = os.pathsep.join(self.env['PATH']))
kw['env'] = env
else:
if self.env.DEST_BINFMT == 'pe': #gcc uses nm, and has a preceding _ on windows
re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b')
else:
re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b')
cmd = ['nm', '-g', obj.abspath()]
syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT))
if 'NM' in self.env:
cmd = [self.env['NM']]
else:
cmd = 'nm'
cmd += ['-g', obj.abspath()]
syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT, **kw))
self.outputs[0].write('%r' % syms)
class compile_sym(Task):