diff --git a/.gitmodules b/.gitmodules index e69de29..8eb5872 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/libgit2"] + path = vendor/libgit2 + url = https://github.com/libgit2/libgit2 diff --git a/Makefile b/Makefile index fa6964f..acb57b0 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ 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: go run script/check-MakeGitError-thread-lock.go go test ./... -install: build-libgit2 +install: go install ./... diff --git a/git.go b/git.go index 411c11b..31d863a 100644 --- a/git.go +++ b/git.go @@ -3,7 +3,6 @@ package git /* #include #include -#cgo pkg-config: libgit2 #if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25 # error "Invalid libgit2 version; this git2go supports libgit2 v0.25" diff --git a/git_dynamic.go b/git_dynamic.go new file mode 100644 index 0000000..75d9cbc --- /dev/null +++ b/git_dynamic.go @@ -0,0 +1,9 @@ +// +build !static + +package git + +/* +#cgo pkg-config: libgit2 +#include +*/ +import "C" diff --git a/git_static.go b/git_static.go new file mode 100644 index 0000000..062dd95 --- /dev/null +++ b/git_static.go @@ -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" diff --git a/vendor/libgit2 b/vendor/libgit2 new file mode 160000 index 0000000..2fcb870 --- /dev/null +++ b/vendor/libgit2 @@ -0,0 +1 @@ +Subproject commit 2fcb8705e584ca61f6c4657525c9d2713f6a39d2