build: Update the build script to make it possible to build for other architectures
authorLucas Käldström <lucas.kaldstrom@hotmail.co.uk>
Sat, 13 Aug 2016 09:44:28 +0000 (12:44 +0300)
committerLucas Käldström <lucas.kaldstrom@hotmail.co.uk>
Sat, 13 Aug 2016 09:44:28 +0000 (12:44 +0300)
This makes it possible to cross-compile cni like so:
$ GOARCH=arm ./build
$ GOARCH=arm64 ./build
$ GOARCH=ppc64le ./build

ref #209

build
test

diff --git a/build b/build
index f1faf26..d0e2885 100755 (executable)
--- a/build
+++ b/build
@@ -10,14 +10,13 @@ if [ ! -h gopath/src/${REPO_PATH} ]; then
 fi
 
 export GO15VENDOREXPERIMENT=1
-export GOBIN=${PWD}/bin
 export GOPATH=${PWD}/gopath
 
 echo "Building API"
 go build "$@" ${REPO_PATH}/libcni
 
 echo "Building reference CLI"
-go install "$@" ${REPO_PATH}/cnitool
+go build -o ${PWD}/bin/cnitool "$@" ${REPO_PATH}/cnitool
 
 echo "Building plugins"
 PLUGINS="plugins/meta/* plugins/main/* plugins/ipam/* plugins/test/*"
@@ -25,6 +24,6 @@ for d in $PLUGINS; do
        if [ -d $d ]; then
                plugin=$(basename $d)
                echo "  " $plugin
-               go install "$@" ${REPO_PATH}/$d
+               go build -o ${PWD}/bin/$plugin "$@" ${REPO_PATH}/$d
        fi
 done
diff --git a/test b/test
index 2f1a4b2..afb1c94 100755 (executable)
--- a/test
+++ b/test
@@ -35,7 +35,7 @@ TEST=${split[@]/#/${REPO_PATH}/}
 
 echo -n "Running tests "
 function testrun {
-    sudo -E bash -c "umask 0; PATH=$GOROOT/bin:$GOBIN:$PATH go test -covermode set $@"
+    sudo -E bash -c "umask 0; PATH=$GOROOT/bin:$(pwd)/bin:$PATH go test -covermode set $@"
 }
 if [ ! -z "${COVERALLS}" ]; then
     echo "with coverage profile generation..."