forward-port version function from RC_1_0

This commit is contained in:
arvidn 2015-11-11 00:57:51 -05:00
parent 4ebca897d9
commit 4c0b00c390
7 changed files with 68 additions and 3 deletions

View File

@ -681,6 +681,7 @@ SOURCES =
ConvertUTF
thread
xml_parse
version
peer_class
peer_class_set
part_file

View File

@ -6,11 +6,16 @@
#include <boost/python.hpp>
using namespace boost::python;
using libtorrent::version;
void bind_version()
{
scope().attr("__version__") = version();
#ifndef TORRENT_NO_DEPRECATE
scope().attr("version") = LIBTORRENT_VERSION;
scope().attr("version_major") = LIBTORRENT_VERSION_MAJOR;
scope().attr("version_minor") = LIBTORRENT_VERSION_MINOR;
#endif
}

View File

@ -41,6 +41,8 @@ class test_sha1hash(unittest.TestCase):
s = lt.sha1_hash(binascii.unhexlify(h))
self.assertEqual(h, str(s))
if __name__ == '__main__':
unittest.main()
if __name__ == '__main__':
print lt.__version__
unittest.main()

View File

@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_VERSION_HPP_INCLUDED
#define TORRENT_VERSION_HPP_INCLUDED
#include "libtorrent/export.hpp"
#define LIBTORRENT_VERSION_MAJOR 1
#define LIBTORRENT_VERSION_MINOR 1
#define LIBTORRENT_VERSION_TINY 0
@ -42,6 +44,13 @@ POSSIBILITY OF SUCH DAMAGE.
#define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTORRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY)
#define LIBTORRENT_VERSION "1.1.0.0"
#define LIBTORRENT_REVISION "$Rev$"
#define LIBTORRENT_REVISION "a10289a"
namespace libtorrent {
// returns the libtorrent version as string form in this format:
// "<major>.<minor>.<tiny>.<tag>.<revision>"
TORRENT_EXPORT char const* version();
}
#endif

View File

@ -141,6 +141,7 @@ libtorrent_rasterbar_la_SOURCES = \
utp_stream.cpp \
web_peer_connection.cpp \
xml_parse.cpp \
version.cpp \
file_progress.cpp \
\
$(KADEMLIA_SOURCES)

43
src/version.cpp Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright (c) 2015, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/version.hpp"
namespace libtorrent {
char const* version()
{
return LIBTORRENT_VERSION "." LIBTORRENT_REVISION ;
}
}

View File

@ -14,6 +14,8 @@ def v(version):
else: ret = ret + (chr(ord('A') + i - 10),)
return ret
revision = os.popen('git log -1 --format=format:%h').read().strip()
def substitute_file(name):
subst = ''
f = open(name)
@ -26,6 +28,8 @@ def substitute_file(name):
l = '#define LIBTORRENT_VERSION_TINY %d\n' % version[2]
elif '#define LIBTORRENT_VERSION ' in l and name.endswith('.hpp'):
l = '#define LIBTORRENT_VERSION "%d.%d.%d.%d"\n' % (version[0], version[1], version[2], version[3])
elif '#define LIBTORRENT_REVISION ' in l and name.endswith('.hpp'):
l = '#define LIBTORRENT_REVISION "%s"' % revision
elif 'AC_INIT([libtorrent-rasterbar]' in l and name.endswith('.ac'):
l = 'AC_INIT([libtorrent-rasterbar],[%d.%d.%d],[arvid@libtorrent.org],\n' % (version[0], version[1], version[2])
elif 'set (VERSION ' in l and name.endswith('.txt'):