diff --git a/Jamfile b/Jamfile index 0db5fec03..148f2b67c 100644 --- a/Jamfile +++ b/Jamfile @@ -681,6 +681,7 @@ SOURCES = ConvertUTF thread xml_parse + version peer_class peer_class_set part_file diff --git a/bindings/python/src/version.cpp b/bindings/python/src/version.cpp index aaeafd900..a7045d020 100644 --- a/bindings/python/src/version.cpp +++ b/bindings/python/src/version.cpp @@ -6,11 +6,16 @@ #include 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 } diff --git a/bindings/python/test.py b/bindings/python/test.py index a54dd315a..5582fcdcf 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -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() diff --git a/include/libtorrent/version.hpp b/include/libtorrent/version.hpp index 1c45490e7..44eee45a7 100644 --- a/include/libtorrent/version.hpp +++ b/include/libtorrent/version.hpp @@ -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: + // "...." + TORRENT_EXPORT char const* version(); + +} #endif diff --git a/src/Makefile.am b/src/Makefile.am index eafdbf67a..ca77b0396 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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) diff --git a/src/version.cpp b/src/version.cpp new file mode 100644 index 000000000..50f962e94 --- /dev/null +++ b/src/version.cpp @@ -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 ; +} + +} + diff --git a/tools/set_version.py b/tools/set_version.py index 88cc10a4d..5bafbf1c8 100755 --- a/tools/set_version.py +++ b/tools/set_version.py @@ -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'):