Skip to content

Commit ef83908

Browse files
committed
Revert "Make the cgo tool do more linking work"
1 parent db3754c commit ef83908

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-libgit2:
55

66
test: build-libgit2
77
go run script/check-MakeGitError-thread-lock.go
8-
go test ./...
8+
./script/with-static.sh go test ./...
99

1010
install: build-libgit2
11-
go install ./...
11+
./script/with-static.sh go install ./...

git.go

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

33
/*
4-
#cgo pkg-config: --static --define-variable=libdir=vendor/libgit2/build --define-variable=includedir=vendor/libgit2/include vendor/libgit2/build/libgit2.pc
5-
#cgo LDFLAGS: -lgit2
64
#include <git2.h>
75
*/
86
import "C"

script/build-libgit2-static.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -ex
44

55
VENDORED_PATH=vendor/libgit2
66

7-
cd "$VENDORED_PATH" &&
7+
cd $VENDORED_PATH &&
88
mkdir -p install/lib &&
99
mkdir -p build &&
1010
cd build &&
@@ -13,7 +13,7 @@ cmake -DTHREADSAFE=ON \
1313
-DBUILD_SHARED_LIBS=OFF \
1414
-DCMAKE_C_FLAGS=-fPIC \
1515
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
16-
-DCMAKE_INSTALL_PREFIX=. \
16+
-DCMAKE_INSTALL_PREFIX=../install \
1717
.. &&
1818

1919
cmake --build .

script/with-static.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
export BUILD="$PWD/vendor/libgit2/build"
6+
export PCFILE="$BUILD/libgit2.pc"
7+
8+
FLAGS=$(pkg-config --static --libs $PCFILE) || exit 1
9+
export CGO_LDFLAGS="$BUILD/libgit2.a -L$BUILD ${FLAGS}"
10+
export CGO_CFLAGS="-I$PWD/vendor/libgit2/include"
11+
12+
$@

0 commit comments

Comments
 (0)