Merge pull request #361 from libgit2/cmn/link-tags-v25

Link dynamically or statically depending on build flags
This commit is contained in:
Carlos Martín Nieto 2017-01-20 13:46:32 +00:00 committed by GitHub
commit 334260d743
6 changed files with 38 additions and 2 deletions

3
.gitmodules vendored
View File

@ -0,0 +1,3 @@
[submodule "vendor/libgit2"]
path = vendor/libgit2
url = https://github.com/libgit2/libgit2

View File

@ -1,8 +1,21 @@
default: test default: test
build-libgit2:
./script/build-libgit2-static.sh
test-static: build-libgit2
go run script/check-MakeGitError-thread-lock.go
go test -tags static ./...
build-static: build-libgit2
go build -tags static ./...
install-static: build-libgit2
go install -tags static ./...
test: test:
go run script/check-MakeGitError-thread-lock.go go run script/check-MakeGitError-thread-lock.go
go test ./... go test ./...
install: build-libgit2 install:
go install ./... go install ./...

1
git.go
View File

@ -3,7 +3,6 @@ package git
/* /*
#include <git2.h> #include <git2.h>
#include <git2/sys/openssl.h> #include <git2/sys/openssl.h>
#cgo pkg-config: libgit2
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25 #if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25
# error "Invalid libgit2 version; this git2go supports libgit2 v0.25" # error "Invalid libgit2 version; this git2go supports libgit2 v0.25"

9
git_dynamic.go Normal file
View File

@ -0,0 +1,9 @@
// +build !static
package git
/*
#cgo pkg-config: libgit2
#include <git2.h>
*/
import "C"

11
git_static.go Normal file
View File

@ -0,0 +1,11 @@
// +build static
package git
/*
#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include
#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2
#cgo windows LDFLAGS: -lwinhttp
#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc
*/
import "C"

1
vendor/libgit2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 2fcb8705e584ca61f6c4657525c9d2713f6a39d2