From fe786aae4cc46981b60f58f37cde0c4911bd6030 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Tue, 26 Jun 2018 16:29:48 +0300 Subject: [PATCH] add a build script for a static stripped binary Related #99 and #103 --- gen/build.sh | 9 +++++++++ gen/xbuild.sh | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100755 gen/build.sh diff --git a/gen/build.sh b/gen/build.sh new file mode 100755 index 00000000..223a1193 --- /dev/null +++ b/gen/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Builds a static stripped binary with version information. +# +# This script is used to build a binary for the current platform. Cgo is +# disabled to make sure the binary is statically linked. Appropriate flags are +# given to the go compiler to strip the binary. Current git tag is passed to +# the compiler to be used as the version in the binary. + +CGO_ENABLED=0 go build -ldflags="-s -w -X main.gVersion=$(git describe --tags)" "$@" diff --git a/gen/xbuild.sh b/gen/xbuild.sh index 870c9391..296dbd61 100755 --- a/gen/xbuild.sh +++ b/gen/xbuild.sh @@ -3,9 +3,10 @@ # # This script is used to build binaries for all supported platforms. Cgo is # disabled to make sure binaries are statically linked. Appropriate flags are -# given to the go compiler to strip binaries. These are then compressed in an -# archive form (`.zip` for windows and `.tar.gz` for the rest) within a folder -# named `dist`. +# given to the go compiler to strip binaries. Current git tag is passed to the +# compiler to be used as the version in binaries. These are then compressed in +# an archive form (`.zip` for windows and `.tar.gz` for the rest) within a +# folder named `dist`. set -o verbose