Skip to content

Commit 5001942

Browse files
committed
Allow building statically via the "static" build tag
1 parent 71bdf97 commit 5001942

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ test: build-libgit2
99

1010
install: build-libgit2
1111
go install ./...
12+
13+
build-libgit2:
14+
./script/build-libgit2-static.sh
15+
16+
static: build-libgit2
17+
go run script/check-MakeGitError-thread-lock.go
18+
go test --tags "static" ./...
19+
20+
install-static: build-libgit2
21+
go install --tags "static" ./...
22+
23+
test-static: build-libgit2
24+
go test --tags "static" ./...

git.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
package git
22

33
/*
4-
#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include
5-
#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2
6-
#cgo windows LDFLAGS: -lwinhttp
7-
#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc
84
#include <git2.h>
95
#include <git2/sys/openssl.h>
10-
11-
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25
12-
# error "Invalid libgit2 version; this git2go supports libgit2 v0.25"
13-
#endif
14-
156
*/
167
import "C"
178
import (

git_dynamic.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// +build !static
2+
3+
package git
4+
5+
/*
6+
#include <git2.h>
7+
#cgo pkg-config: libgit2
8+
9+
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25
10+
# error "Invalid libgit2 version; this git2go supports libgit2 v0.25"
11+
#endif
12+
13+
*/
14+
import "C"

git_static.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// +build static
2+
3+
package git
4+
5+
/*
6+
#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include
7+
#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2
8+
#cgo windows LDFLAGS: -lwinhttp
9+
#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc
10+
#include <git2.h>
11+
12+
#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25
13+
# error "Invalid libgit2 version; this git2go supports libgit2 v0.25"
14+
#endif
15+
16+
*/
17+
import "C"

0 commit comments

Comments
 (0)