From 858d6d93cb3faea7afb347e805f98d52ff5ac12c Mon Sep 17 00:00:00 2001 From: xylosper Date: Mon, 16 Jun 2014 18:22:46 +0900 Subject: [PATCH] build: add '--enable-libmpv-static' option Signed-off-by: wm4 --- wscript | 8 +++++++- wscript_build.py | 40 +++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/wscript b/wscript index 7351d3bf84..0b4e196823 100644 --- a/wscript +++ b/wscript @@ -14,10 +14,16 @@ build_options = [ 'desc': 'shared library', 'default': 'disable', 'func': check_true + }, { + 'name': '--libmpv-static', + 'desc': 'static library', + 'default': 'disable', + 'deps_neg': [ 'libmpv-shared' ], + 'func': check_true }, { 'name': '--client-api-examples', 'desc': 'build client API examples', - 'deps': ['libmpv-shared'], + 'deps_any': [ 'libmpv-shared', 'libmpv-static' ], 'func': check_true }, { 'name': '--static-build', diff --git a/wscript_build.py b/wscript_build.py index d2d514419b..e2d7c9e894 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -439,8 +439,11 @@ def build(ctx): **cprog_kwargs ) - if ctx.dependency_satisfied('libmpv-shared'): - ctx.load("syms") + build_shared = ctx.dependency_satisfied('libmpv-shared') + build_static = ctx.dependency_satisfied('libmpv-static') + if build_shared or build_static: + if build_shared: + ctx.load("syms") vnum = int(re.search('^#define MPV_CLIENT_API_VERSION 0x(.*)UL$', ctx.path.find_node("libmpv/client.h").read(), re.M) @@ -448,17 +451,28 @@ def build(ctx): libversion = (str(vnum >> 24) + '.' + str((vnum >> 16) & 0xff) + '.' + str(vnum & 0xffff)) - ctx( - target = "mpv", - source = ctx.filtered_sources(sources), - use = ctx.dependencies_use(), - includes = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \ - ctx.dependencies_includes(), - features = "c cshlib syms", - export_symbols_regex = 'mpv_.*', - install_path = ctx.env.LIBDIR, - vnum = libversion, - ) + + def _build_libmpv(shared): + features = "c " + if shared: + features += "cshlib syms" + else: + features += "cstlib" + ctx( + target = "mpv", + source = ctx.filtered_sources(sources), + use = ctx.dependencies_use(), + includes = [ctx.bldnode.abspath(), ctx.srcnode.abspath()] + \ + ctx.dependencies_includes(), + features = features, + export_symbols_regex = 'mpv_.*', + install_path = ctx.env.LIBDIR, + vnum = libversion, + ) + if build_shared: + _build_libmpv(True) + if build_static: + _build_libmpv(False) ctx( target = 'libmpv/mpv.pc',