diff options
author | wm4 <wm4@nowhere> | 2014-03-12 00:40:55 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-12 00:40:55 +0100 |
commit | 14c1816c717b374d1309fd601ae52002d659e415 (patch) | |
tree | 2fc5f44226b4d0639e47837465d5e4240aef7674 | |
parent | 40855d6c12e736dc2bd4291d7edd58fee0a1400d (diff) | |
download | mpv-14c1816c717b374d1309fd601ae52002d659e415.tar.bz2 mpv-14c1816c717b374d1309fd601ae52002d659e415.tar.xz |
build: automagically extract client library version
This reads MPV_CLIENT_API_VERSION from the source header, and turns it
into a 3 part version number.
E.g. if MPV_CLIENT_API_VERSION were 0x12abcdef, this would result in
"18.171.773615" (8 bits, 8 bits, 16 bits).
We'll see if this is actually useful, or if it's too clever.
-rw-r--r-- | wscript_build.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/wscript_build.py b/wscript_build.py index 48e06d705b..5253f57de4 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -1,3 +1,5 @@ +import re + def _add_rst_manual_dependencies(ctx): manpage_sources_basenames = """ options.rst ao.rst vo.rst af.rst vf.rst encode.rst @@ -440,6 +442,13 @@ def build(ctx): if ctx.dependency_satisfied('libmpv-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) + .group(1), 16) + libversion = (str(vnum >> 24) + '.' + + str((vnum >> 16) & 0xff) + '.' + + str(vnum & 0xffff)) ctx( target = "mpv", source = ctx.filtered_sources(sources), @@ -449,7 +458,7 @@ def build(ctx): features = "c cshlib syms", export_symbols_regex = 'mpv_.*', install_path = ctx.env.LIBDIR, - vnum = "0.0.0", + vnum = libversion, ) ctx( @@ -459,7 +468,7 @@ def build(ctx): PREFIX = ctx.env.PREFIX, LIBDIR = ctx.env.LIBDIR, INCDIR = ctx.env.INCDIR, - VERSION = ctx.env.VERSION, + VERSION = libversion, ) headers = ["client.h"] |