mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-18 21:35:20 +00:00
Add proper version management
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>
This commit is contained in:
parent
7a689719bd
commit
9d1dcca229
@ -14,6 +14,13 @@
|
|||||||
PROJECT(libgit2 C)
|
PROJECT(libgit2 C)
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
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 required dependencies
|
||||||
FIND_PACKAGE(ZLIB REQUIRED)
|
FIND_PACKAGE(ZLIB REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} src)
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} src)
|
||||||
@ -80,7 +87,8 @@ ENDIF ()
|
|||||||
# Compile and link libgit2
|
# Compile and link libgit2
|
||||||
ADD_LIBRARY(git2 ${SRC} ${SRC_PLAT} ${SRC_SHA1})
|
ADD_LIBRARY(git2 ${SRC} ${SRC_PLAT} ${SRC_SHA1})
|
||||||
TARGET_LINK_LIBRARIES(git2 ${ZLIB_LIBRARY} ${LIB_SHA1} ${PTHREAD_LIBRARY} ${SQLITE3_LIBRARIES})
|
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
|
||||||
INSTALL(TARGETS git2
|
INSTALL(TARGETS git2
|
||||||
|
@ -5,7 +5,7 @@ includedir=${prefix}/include
|
|||||||
|
|
||||||
Name: libgit2
|
Name: libgit2
|
||||||
Description: The git library, take 2
|
Description: The git library, take 2
|
||||||
Version: 0.0.1
|
Version: @version@
|
||||||
Requires: libcrypto
|
Requires: libcrypto
|
||||||
Libs: -L${libdir} -lgit2 -lz -lcrypto
|
Libs: -L${libdir} -lgit2 -lz -lcrypto
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
@ -26,6 +26,11 @@
|
|||||||
#ifndef INCLUDE_git_git_h__
|
#ifndef INCLUDE_git_git_h__
|
||||||
#define 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/common.h"
|
||||||
#include "git2/errors.h"
|
#include "git2/errors.h"
|
||||||
#include "git2/zlib.h"
|
#include "git2/zlib.h"
|
||||||
|
21
wscript
21
wscript
@ -104,6 +104,19 @@ def build(bld):
|
|||||||
from waflib import Options
|
from waflib import Options
|
||||||
Options.commands = [bld.cmd + '-shared', bld.cmd + '-static'] + Options.commands
|
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):
|
def build_library(bld, build_type):
|
||||||
|
|
||||||
BUILD = {
|
BUILD = {
|
||||||
@ -115,6 +128,9 @@ def build_library(bld, build_type):
|
|||||||
directory = bld.path
|
directory = bld.path
|
||||||
sources = directory.ant_glob('src/*.c')
|
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
|
# Compile platform-dependant code
|
||||||
# E.g. src/unix/*.c
|
# E.g. src/unix/*.c
|
||||||
# src/win32/*.c
|
# src/win32/*.c
|
||||||
@ -136,12 +152,13 @@ def build_library(bld, build_type):
|
|||||||
target='git2',
|
target='git2',
|
||||||
includes='src',
|
includes='src',
|
||||||
install_path='${LIBDIR}',
|
install_path='${LIBDIR}',
|
||||||
use=ALL_LIBS
|
use=ALL_LIBS,
|
||||||
|
vnum=version,
|
||||||
)
|
)
|
||||||
|
|
||||||
# On Unix systems, build the Pkg-config entry file
|
# On Unix systems, build the Pkg-config entry file
|
||||||
if bld.env.PLATFORM == 'unix' and bld.is_install:
|
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',
|
source='libgit2.pc.in',
|
||||||
target='libgit2.pc',
|
target='libgit2.pc',
|
||||||
install_path='${LIBDIR}/pkgconfig',
|
install_path='${LIBDIR}/pkgconfig',
|
||||||
|
Loading…
Reference in New Issue
Block a user