From f76f2b66549a7ecc8a5197348fbcaf632f75eb67 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Wed, 5 Apr 2017 23:05:05 +0100 Subject: [PATCH] tools: Add --ldflags to go-compile This flags allows passing additional ldflags to the build. It is primarily there to pass -C arguments to specify values of variables at compile time. Signed-off-by: Rolf Neugebauer --- tools/go-compile/compile.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/go-compile/compile.sh b/tools/go-compile/compile.sh index e49fb5b7e..e5f6806ca 100755 --- a/tools/go-compile/compile.sh +++ b/tools/go-compile/compile.sh @@ -26,6 +26,10 @@ do package="$2" shift ;; + --ldflags) + ldflags="$2" + shift + ;; *) echo "Unknown option $1" exit 1 @@ -61,9 +65,14 @@ test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.* if [ "$GOOS" = "darwin" ] then - go build -o $out "$package" + if [ -z "$ldflags" ] + then + go build -o $out "$package" + else + go build -o $out -ldflags "${ldflags}" "$package" + fi else - go build -o $out -buildmode pie --ldflags '-s -w -extldflags "-static"' "$package" + go build -o $out -buildmode pie -ldflags "-s -w ${ldflags} -extldflags \"-static\"" "$package" fi tar cf - $out