mirror of https://github.com/mpv-player/mpv
build: list exported symbols explicitly
Instead of using a regex to match names to be exported from the libmpv dynamic shared library, use a libmpv.def file, which lists all exported functions explicitly. This reduces the platform specifics in syms.py. I'm not sure if the separate compile_sym task is still needed (it could probably be collapsed, which would concentrate the platform specifics into one place).
This commit is contained in:
parent
62a79ae556
commit
bdf607ea5f
|
@ -0,0 +1,34 @@
|
|||
mpv_client_api_version
|
||||
mpv_client_name
|
||||
mpv_command
|
||||
mpv_command_async
|
||||
mpv_command_string
|
||||
mpv_create
|
||||
mpv_detach_destroy
|
||||
mpv_error_string
|
||||
mpv_event_name
|
||||
mpv_free
|
||||
mpv_free_node_contents
|
||||
mpv_get_property
|
||||
mpv_get_property_async
|
||||
mpv_get_property_osd_string
|
||||
mpv_get_property_string
|
||||
mpv_get_time_us
|
||||
mpv_get_wakeup_pipe
|
||||
mpv_initialize
|
||||
mpv_load_config_file
|
||||
mpv_observe_property
|
||||
mpv_request_event
|
||||
mpv_request_log_messages
|
||||
mpv_resume
|
||||
mpv_set_option
|
||||
mpv_set_option_string
|
||||
mpv_set_property
|
||||
mpv_set_property_async
|
||||
mpv_set_property_string
|
||||
mpv_set_wakeup_callback
|
||||
mpv_suspend
|
||||
mpv_terminate_destroy
|
||||
mpv_unobserve_property
|
||||
mpv_wait_event
|
||||
mpv_wakeup
|
|
@ -1,56 +1,27 @@
|
|||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Source: waflib/extras/syms.py from waf git 610d0d59f (New BSD License)
|
||||
# Original source: waflib/extras/syms.py from waf git 610d0d59f (New BSD License)
|
||||
|
||||
"""
|
||||
this tool supports the export_symbols_regex to export the symbols in a shared library.
|
||||
by default, all symbols are exported by gcc, and nothing by msvc.
|
||||
set the list of symbols exported from a dynamic library
|
||||
to use the tool, do something like:
|
||||
|
||||
def build(ctx):
|
||||
ctx(features='c cshlib syms', source='a.c b.c', export_symbols_regex='mylib_.*', target='testlib')
|
||||
ctx(features='c cshlib syms', source='a.c b.c', export_symbols_def='syms.def', target='testlib')
|
||||
|
||||
only the symbols starting with 'mylib_' will be exported.
|
||||
only the symbols listed in the file syms.def will be exported.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
from waflib.Context import STDOUT
|
||||
from waflib.Task import Task
|
||||
from waflib.Errors import WafError
|
||||
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 = [self.env.DUMPBIN or 'dumpbin', '/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 in ('mac-o',): #gcc uses nm, and has a preceding _ on osx
|
||||
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 = [self.env.NM or 'nm', '-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):
|
||||
def run(self):
|
||||
syms = {}
|
||||
for x in self.inputs:
|
||||
slist = eval(x.read())
|
||||
for s in slist:
|
||||
syms[s] = 1
|
||||
lsyms = list(syms.keys())
|
||||
lsyms = []
|
||||
for line in self.inputs[0].read().split():
|
||||
lsyms.append(line.strip())
|
||||
lsyms.sort()
|
||||
if self.env.DEST_BINFMT == 'pe':
|
||||
self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms))
|
||||
|
@ -64,11 +35,8 @@ class compile_sym(Task):
|
|||
@feature('syms')
|
||||
@after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local')
|
||||
def do_the_symbol_stuff(self):
|
||||
ins = [x.outputs[0] for x in self.compiled_tasks]
|
||||
self.gen_sym_tasks = [self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins]
|
||||
|
||||
tsk = self.create_task('compile_sym',
|
||||
[x.outputs[0] for x in self.gen_sym_tasks],
|
||||
[self.path.find_node(self.export_symbols_def)],
|
||||
self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def')))
|
||||
self.link_task.set_run_after(tsk)
|
||||
self.link_task.dep_nodes.append(tsk.outputs[0])
|
||||
|
|
4
wscript
4
wscript
|
@ -789,13 +789,12 @@ def is_debug_build(ctx):
|
|||
def configure(ctx):
|
||||
ctx.check_waf_version(mini='1.7.15')
|
||||
target = os.environ.get('TARGET')
|
||||
(cc, pkg_config, windres, nm) = ('cc', 'pkg-config', 'windres', 'nm')
|
||||
(cc, pkg_config, windres) = ('cc', 'pkg-config', 'windres')
|
||||
|
||||
if target:
|
||||
cc = '-'.join([target, 'gcc'])
|
||||
pkg_config = '-'.join([target, pkg_config])
|
||||
windres = '-'.join([target, windres])
|
||||
nm = '-'.join([target, nm])
|
||||
|
||||
ctx.find_program(cc, var='CC')
|
||||
ctx.find_program(pkg_config, var='PKG_CONFIG')
|
||||
|
@ -803,7 +802,6 @@ def configure(ctx):
|
|||
ctx.find_program('rst2man', var='RST2MAN', mandatory=False)
|
||||
ctx.find_program('rst2pdf', var='RST2PDF', mandatory=False)
|
||||
ctx.find_program(windres, var='WINDRES', mandatory=False)
|
||||
ctx.find_program(nm, var='NM', mandatory=False)
|
||||
|
||||
for ident, _, _ in _INSTALL_DIRS_LIST:
|
||||
varname = ident.upper()
|
||||
|
|
|
@ -469,7 +469,7 @@ def build(ctx):
|
|||
includes = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \
|
||||
ctx.dependencies_includes(),
|
||||
features = features,
|
||||
export_symbols_regex = 'mpv_.*',
|
||||
export_symbols_def = "etc/libmpv.def",
|
||||
install_path = ctx.env.LIBDIR,
|
||||
vnum = libversion,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue