From 14c1816c717b374d1309fd601ae52002d659e415 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 12 Mar 2014 00:40:55 +0100 Subject: 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. --- wscript_build.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'wscript_build.py') 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"] -- cgit v1.2.3