From c05824091bd8d767ca93ecef054ec4828023c682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sat, 19 Dec 2015 01:30:28 +0100 Subject: [PATCH] Get rid of the with-static.sh script CGO can perform variable substitution in the directives, so we don't need to use a script to set up the variables; we can let the go tool do it for us. --- Makefile | 4 ++-- README.md | 9 ++++----- git.go | 3 +++ script/with-static.sh | 12 ------------ 4 files changed, 9 insertions(+), 19 deletions(-) delete mode 100755 script/with-static.sh diff --git a/Makefile b/Makefile index 3040857..39fc558 100644 --- a/Makefile +++ b/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 ./... diff --git a/README.md b/README.md index a5e6100..c5a0348 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,14 @@ libgit2 uses OpenSSL and LibSSH2 for performing encrypted network connections. F Running the tests ----------------- -For the stable version, `go test` will work as usual. For the `next` branch, similarly to installing, running the tests requires linking against the local libgit2 library, so the Makefile provides a wrapper +For the stable version, `go test` will work as usual. For the `next` branch, similarly to installing, running the tests requires building a local libgit2 library, so the Makefile provides a wrapper make test -Alternatively, if you want to pass arguments to `go test`, you can use the script that sets it all up +Alternatively, you can build the library manually first and then run the tests - ./script/with-static.sh go test -v - -which will run the specified arguments with the correct environment variables. + ./script/build-libgit2-static.sh + go test -v License ------- diff --git a/git.go b/git.go index 2b2a909..d6ec300 100644 --- a/git.go +++ b/git.go @@ -1,6 +1,9 @@ package git /* +#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include +#cgo LDFLAGS: ${SRCDIR}/vendor/libgit2/build/libgit2.a +#cgo pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc #include #include */ diff --git a/script/with-static.sh b/script/with-static.sh deleted file mode 100755 index 3f60e31..0000000 --- a/script/with-static.sh +++ /dev/null @@ -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" - -$@