2015-07-11 07:51:30 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2009-01-29 01:35:57 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2012-09-29 23:30:40 +02:00
|
|
|
import glob
|
2014-12-31 16:51:45 +01:00
|
|
|
import re
|
2009-01-29 01:35:57 +01:00
|
|
|
|
|
|
|
version = (int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]))
|
|
|
|
|
2014-12-31 16:51:45 +01:00
|
|
|
def v(version):
|
|
|
|
ret = ()
|
|
|
|
for i in version:
|
2018-07-20 10:02:04 +02:00
|
|
|
if i < 10: ret = ret + (chr(ord('0') + i),)
|
2014-12-31 16:51:45 +01:00
|
|
|
else: ret = ret + (chr(ord('A') + i - 10),)
|
|
|
|
return ret
|
|
|
|
|
2015-11-11 06:57:51 +01:00
|
|
|
revision = os.popen('git log -1 --format=format:%h').read().strip()
|
|
|
|
|
2009-01-29 01:35:57 +01:00
|
|
|
def substitute_file(name):
|
|
|
|
subst = ''
|
|
|
|
f = open(name)
|
|
|
|
for l in f:
|
2009-04-03 21:33:24 +02:00
|
|
|
if '#define LIBTORRENT_VERSION_MAJOR' in l and name.endswith('.hpp'):
|
2009-01-29 01:35:57 +01:00
|
|
|
l = '#define LIBTORRENT_VERSION_MAJOR %d\n' % version[0]
|
2009-04-03 21:33:24 +02:00
|
|
|
elif '#define LIBTORRENT_VERSION_MINOR' in l and name.endswith('.hpp'):
|
2009-01-29 01:35:57 +01:00
|
|
|
l = '#define LIBTORRENT_VERSION_MINOR %d\n' % version[1]
|
2009-09-18 19:43:50 +02:00
|
|
|
elif '#define LIBTORRENT_VERSION_TINY' in l and name.endswith('.hpp'):
|
2009-03-20 08:38:47 +01:00
|
|
|
l = '#define LIBTORRENT_VERSION_TINY %d\n' % version[2]
|
2012-03-26 18:11:29 +02:00
|
|
|
elif '#define LIBTORRENT_VERSION ' in l and name.endswith('.hpp'):
|
2009-01-29 01:35:57 +01:00
|
|
|
l = '#define LIBTORRENT_VERSION "%d.%d.%d.%d"\n' % (version[0], version[1], version[2], version[3])
|
2015-11-11 06:57:51 +01:00
|
|
|
elif '#define LIBTORRENT_REVISION ' in l and name.endswith('.hpp'):
|
2015-11-11 07:25:30 +01:00
|
|
|
l = '#define LIBTORRENT_REVISION "%s"\n' % revision
|
2009-09-18 20:44:12 +02:00
|
|
|
elif 'AC_INIT([libtorrent-rasterbar]' in l and name.endswith('.ac'):
|
2014-10-22 09:05:10 +02:00
|
|
|
l = 'AC_INIT([libtorrent-rasterbar],[%d.%d.%d],[arvid@libtorrent.org],\n' % (version[0], version[1], version[2])
|
2009-09-18 20:44:12 +02:00
|
|
|
elif 'set (VERSION ' in l and name.endswith('.txt'):
|
2009-01-29 01:35:57 +01:00
|
|
|
l = 'set (VERSION "%d.%d.%d")\n' % (version[0], version[1], version[2])
|
2013-08-18 03:16:13 +02:00
|
|
|
elif ':Version: ' in l and (name.endswith('.rst') or name.endswith('.py')):
|
2009-01-29 01:35:57 +01:00
|
|
|
l = ':Version: %d.%d.%d\n' % (version[0], version[1], version[2])
|
2009-04-03 21:33:24 +02:00
|
|
|
elif 'VERSION = ' in l and name.endswith('Jamfile'):
|
2009-04-03 01:21:44 +02:00
|
|
|
l = 'VERSION = %d.%d.%d ;\n' % (version[0], version[1], version[2])
|
2014-03-23 08:34:18 +01:00
|
|
|
elif 'version=' in l and name.endswith('setup.py'):
|
2014-08-03 00:58:49 +02:00
|
|
|
l = "\tversion = '%d.%d.%d',\n" % (version[0], version[1], version[2])
|
|
|
|
elif "version = '" in l and name.endswith('setup.py'):
|
|
|
|
l = "\tversion = '%d.%d.%d',\n" % (version[0], version[1], version[2])
|
2014-12-31 16:51:45 +01:00
|
|
|
elif '"-LT' in l and name.endswith('settings_pack.cpp'):
|
|
|
|
l = re.sub('"-LT[0-9A-Za-z]{4}-"', '"-LT%c%c%c%c-"' % v(version), l)
|
2009-01-29 01:35:57 +01:00
|
|
|
|
|
|
|
subst += l
|
|
|
|
|
|
|
|
f.close()
|
|
|
|
open(name, 'w+').write(subst)
|
|
|
|
|
|
|
|
|
|
|
|
substitute_file('include/libtorrent/version.hpp')
|
|
|
|
substitute_file('CMakeLists.txt')
|
2009-09-18 20:44:12 +02:00
|
|
|
substitute_file('configure.ac')
|
2014-08-03 00:58:49 +02:00
|
|
|
substitute_file('bindings/python/setup.py')
|
2013-08-18 03:16:13 +02:00
|
|
|
substitute_file('docs/gen_reference_doc.py')
|
2014-12-31 16:51:45 +01:00
|
|
|
substitute_file('src/settings_pack.cpp')
|
2012-09-29 23:30:40 +02:00
|
|
|
for i in glob.glob('docs/*.rst'):
|
|
|
|
substitute_file(i)
|
2009-04-03 21:33:24 +02:00
|
|
|
substitute_file('Jamfile')
|
|
|
|
|
2009-01-29 01:35:57 +01:00
|
|
|
|