diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-02-07 11:35:58 +0300 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-02-07 11:35:58 +0300 |
commit | 9d1dcca229c624c7551a287963a19e95ba4753b6 (patch) | |
tree | f4b441b11e7fe6a9ce901e438a51d0d4f4b8e451 | |
parent | 7a689719bd540502bba4842a8aa2546fd1ef8001 (diff) |
Add proper version managementv0.3.0
We now have proper sonames in Mac OS X and Linux, proper versioning on
the pkg-config file and proper DLL naming in Windows.
The version of the library is defined exclusively in 'src/git2.h'; the build scripts
read it from there automatically.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | libgit2.pc.in | 2 | ||||
-rw-r--r-- | src/git2.h | 5 | ||||
-rw-r--r-- | wscript | 21 |
4 files changed, 34 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a29fcda9..a7f96515c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,13 @@ PROJECT(libgit2 C) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +FILE(STRINGS "src/git2.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$") + +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}") +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}") +STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}") +SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}") + # Find required dependencies FIND_PACKAGE(ZLIB REQUIRED) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} src) @@ -80,7 +87,8 @@ ENDIF () # Compile and link libgit2 ADD_LIBRARY(git2 ${SRC} ${SRC_PLAT} ${SRC_SHA1}) TARGET_LINK_LIBRARIES(git2 ${ZLIB_LIBRARY} ${LIB_SHA1} ${PTHREAD_LIBRARY} ${SQLITE3_LIBRARIES}) -SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION 0.0.1 SOVERSION 0) +SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING}) +SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_VERSION_MAJOR}) # Install INSTALL(TARGETS git2 diff --git a/libgit2.pc.in b/libgit2.pc.in index 83fc82fc8..ece5f2b8e 100644 --- a/libgit2.pc.in +++ b/libgit2.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: libgit2 Description: The git library, take 2 -Version: 0.0.1 +Version: @version@ Requires: libcrypto Libs: -L${libdir} -lgit2 -lz -lcrypto Cflags: -I${includedir} diff --git a/src/git2.h b/src/git2.h index e7f56e924..70ab811f1 100644 --- a/src/git2.h +++ b/src/git2.h @@ -26,6 +26,11 @@ #ifndef INCLUDE_git_git_h__ #define INCLUDE_git_git_h__ +#define LIBGIT2_VERSION "0.3.0" +#define LIBGIT2_VER_MAJOR 0 +#define LIBGIT2_VER_MINOR 3 +#define LIBGIT2_VER_REVISION 0 + #include "git2/common.h" #include "git2/errors.h" #include "git2/zlib.h" @@ -104,6 +104,19 @@ def build(bld): from waflib import Options Options.commands = [bld.cmd + '-shared', bld.cmd + '-static'] + Options.commands +def get_libgit2_version(git2_h): + import re + line = None + + with open(git2_h) as f: + line = re.search(r'^#define LIBGIT2_VERSION "(\d\.\d\.\d)"$', f.read(), re.MULTILINE) + + if line is None: + raise "Failed to detect libgit2 version" + + return line.group(1) + + def build_library(bld, build_type): BUILD = { @@ -115,6 +128,9 @@ def build_library(bld, build_type): directory = bld.path sources = directory.ant_glob('src/*.c') + # Find the version of the library, from our header file + version = get_libgit2_version(directory.find_node("src/git2.h").abspath()) + # Compile platform-dependant code # E.g. src/unix/*.c # src/win32/*.c @@ -136,12 +152,13 @@ def build_library(bld, build_type): target='git2', includes='src', install_path='${LIBDIR}', - use=ALL_LIBS + use=ALL_LIBS, + vnum=version, ) # On Unix systems, build the Pkg-config entry file if bld.env.PLATFORM == 'unix' and bld.is_install: - bld(rule="""sed -e 's#@prefix@#${PREFIX}#' -e 's#@libdir@#${LIBDIR}#' < ${SRC} > ${TGT}""", + bld(rule="""sed -e 's#@prefix@#${PREFIX}#' -e 's#@libdir@#${LIBDIR}#' -e 's#@version@#%s#' < ${SRC} > ${TGT}""" % version, source='libgit2.pc.in', target='libgit2.pc', install_path='${LIBDIR}/pkgconfig', |