Make the cgo tool do more linking work
The cgo directives let us do a lot more than I previously thought, so we can use this to make the building process of git2go go through the go tool directly rather than via the script. libgit2 still needs to be built manually, so we do still require make, but only for building libgit2. Once that's built, any modifications to git2go's own code can be built with go build
This commit is contained in:
parent
74957c2ae6
commit
8f6e13bd08
4
Makefile
4
Makefile
|
@ -5,7 +5,7 @@ build-libgit2:
|
|||
|
||||
test: build-libgit2
|
||||
go run script/check-MakeGitError-thread-lock.go
|
||||
./script/with-static.sh go test ./...
|
||||
go test ./...
|
||||
|
||||
install: build-libgit2
|
||||
./script/with-static.sh go install ./...
|
||||
go install ./...
|
||||
|
|
2
git.go
2
git.go
|
@ -1,6 +1,8 @@
|
|||
package git
|
||||
|
||||
/*
|
||||
#cgo pkg-config: --static --define-variable=libdir=vendor/libgit2/build --define-variable=includedir=vendor/libgit2/include vendor/libgit2/build/libgit2.pc
|
||||
#cgo LDFLAGS: -lgit2
|
||||
#include <git2.h>
|
||||
*/
|
||||
import "C"
|
||||
|
|
|
@ -4,7 +4,7 @@ set -ex
|
|||
|
||||
VENDORED_PATH=vendor/libgit2
|
||||
|
||||
cd $VENDORED_PATH &&
|
||||
cd "$VENDORED_PATH" &&
|
||||
mkdir -p install/lib &&
|
||||
mkdir -p build &&
|
||||
cd build &&
|
||||
|
@ -13,7 +13,7 @@ cmake -DTHREADSAFE=ON \
|
|||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_C_FLAGS=-fPIC \
|
||||
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
|
||||
-DCMAKE_INSTALL_PREFIX=../install \
|
||||
-DCMAKE_INSTALL_PREFIX=. \
|
||||
.. &&
|
||||
|
||||
cmake --build .
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
export BUILD="$PWD/vendor/libgit2/build"
|
||||
export PCFILE="$BUILD/libgit2.pc"
|
||||
|
||||
FLAGS=$(pkg-config --static --libs $PCFILE) || exit 1
|
||||
export CGO_LDFLAGS="$BUILD/libgit2.a -L$BUILD ${FLAGS}"
|
||||
export CGO_CFLAGS="-I$PWD/vendor/libgit2/include"
|
||||
|
||||
$@
|
Loading…
Reference in New Issue