Skip to content

Commit 7cd5a4e

Browse files
authored
Merge pull request libgit2#371 from libgit2/static-dynamic
Allow building statically via the "static" build tag
2 parents 71bdf97 + e7747d3 commit 7cd5a4e

File tree

5 files changed

+46
-16
lines changed

5 files changed

+46
-16
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
language: go
22

3-
sudo: required
4-
5-
install: ./script/install-libgit2.sh
6-
73
go:
84
- 1.5
95
- 1.6
106
- 1.7
117
- tip
128

9+
script: make test-static
10+
1311
matrix:
1412
allow_failures:
1513
- go: tip

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
default: test
22

3-
build-libgit2:
4-
./script/build-libgit2-static.sh
5-
63
test: build-libgit2
74
go run script/check-MakeGitError-thread-lock.go
85
go test ./...
96

107
install: build-libgit2
118
go install ./...
9+
10+
build-libgit2:
11+
./script/build-libgit2-static.sh
12+
13+
static: build-libgit2
14+
go run script/check-MakeGitError-thread-lock.go
15+
go test --tags "static" ./...
16+
17+
install-static: build-libgit2
18+
go install --tags "static" ./...
19+
20+
test-static: build-libgit2
21+
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)