From a34897378896db937d8cad3e68c62dc61975e2e3 Mon Sep 17 00:00:00 2001 From: kayrus Date: Tue, 18 Jul 2017 10:18:01 +0200 Subject: [PATCH] Added simple build script --- .gitignore | 2 ++ scripts/build | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 scripts/build diff --git a/.gitignore b/.gitignore index bd3fe8b..a3bd847 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .git/ releases/ +dist/ +gopath/ *.orig *.swp diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..c348be4 --- /dev/null +++ b/scripts/build @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +CDIR=$(cd `dirname "$0"`/.. && pwd) +cd "$CDIR" + +ORG_PATH="github.com/ovh" +REPO_PATH="${ORG_PATH}/svfs" + +export GOPATH="${CDIR}/gopath" + +export PATH="${PATH}:${GOPATH}/bin" + +eval $(go env) + +if [ ! -h gopath/src/${REPO_PATH} ]; then + mkdir -p gopath/src/${ORG_PATH} + ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 +fi + +if [ -z "$1" ]; then + OS_PLATFORM_ARG=(-os="darwin linux") +else + OS_PLATFORM_ARG=($1) +fi + +if [ -z "$2" ]; then + OS_ARCH_ARG=(-arch="386 amd64 arm ppc64le") +else + OS_ARCH_ARG=($2) +fi + +if ! which gox > /dev/null ; then + go get github.com/mitchellh/gox +fi + +cd "$GOPATH/src/${REPO_PATH}" +gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" -output="dist/{{.OS}}/{{.Arch}}/{{.Dir}}" -ldflags="-w" ${REPO_PATH}