Link dynamically or statically depending on build flags #361
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "vendor/libgit2"]
|
||||||
|
path = vendor/libgit2
|
||||||
|
url = https://github.com/libgit2/libgit2
|
15
Makefile
15
Makefile
|
@ -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
1
git.go
|
@ -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"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
// +build !static
|
||||||
|
|
||||||
|
package git
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo pkg-config: libgit2
|
||||||
|
#include <git2.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
|
@ -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"
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 2fcb8705e584ca61f6c4657525c9d2713f6a39d2
|
Loading…
Reference in New Issue