Really build statically

This commit is contained in:
Carlos Martín Nieto 2014-06-07 15:38:32 +02:00
parent 6862c2c82d
commit aabeb7f585
6 changed files with 22 additions and 5 deletions

View File

@ -5,8 +5,9 @@ build-libgit2:
cat ./vendor/libgit2/libgit2.pc cat ./vendor/libgit2/libgit2.pc
cat ./vendor/install/lib/pkgconfig/libgit2.pc cat ./vendor/install/lib/pkgconfig/libgit2.pc
test: build-libgit2 test: install build-libgit2
./script/with-static.sh go test ./... ./script/with-static.sh go test
./script/with-less-static.sh go test ./settings
install: build-libgit2 install: build-libgit2
./script/with-static.sh go install ./... ./script/with-static.sh go install ./...

1
git.go
View File

@ -1,7 +1,6 @@
package git package git
/* /*
#cgo pkg-config: --static libgit2
#include <git2.h> #include <git2.h>
#include <git2/errors.h> #include <git2/errors.h>
*/ */

View File

@ -9,6 +9,7 @@ cd $VENDORED_PATH
cmake -DTHREADSAFE=ON \ cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \ -DBUILD_CLAR=OFF \
-DBUILD_SHARED_LIBS=OFF \ -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_INSTALL_PREFIX=../install \
. .

13
script/with-less-static.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
set -ex
export INSTALL_LOCATION=$PWD/vendor/install
export PKG_CONFIG_PATH=$INSTALL_LOCATION/lib/pkgconfig
export PCFILE="$PWD/vendor/libgit2/libgit2.pc"
export CGO_LDFLAGS="$(pkg-config --static --libs $PCFILE)"
export CGO_CFLAGS="$(pkg-config --static --cflags $PCFILE)"
$@

View File

@ -4,6 +4,10 @@ set -ex
export INSTALL_LOCATION=$PWD/vendor/install export INSTALL_LOCATION=$PWD/vendor/install
export PKG_CONFIG_PATH=$INSTALL_LOCATION/lib/pkgconfig export PKG_CONFIG_PATH=$INSTALL_LOCATION/lib/pkgconfig
export CGO_LDFLAGS='-lrt'
export PCFILE="$PWD/vendor/libgit2/libgit2.pc"
export CGO_LDFLAGS="$PWD/vendor/libgit2/libgit2.a $(pkg-config --static --libs $PCFILE)"
export CGO_CFLAGS="$(pkg-config --static --cflags $PCFILE)"
$@ $@

View File

@ -1,7 +1,6 @@
package settings package settings
/* /*
#cgo pkg-config: --static libgit2
#include <git2.h> #include <git2.h>
int _go_git_opts_get_search_path(int level, git_buf *buf) int _go_git_opts_get_search_path(int level, git_buf *buf)