mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-28 13:08:38 +00:00
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 <rolf.neugebauer@docker.com>
This commit is contained in:
parent
d33892e9f8
commit
f76f2b6654
@ -26,6 +26,10 @@ do
|
|||||||
package="$2"
|
package="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--ldflags)
|
||||||
|
ldflags="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown option $1"
|
echo "Unknown option $1"
|
||||||
exit 1
|
exit 1
|
||||||
@ -61,9 +65,14 @@ test -z $(find . -type f -name "*.go" -not -path "*/vendor/*" -not -name "*.pb.*
|
|||||||
|
|
||||||
if [ "$GOOS" = "darwin" ]
|
if [ "$GOOS" = "darwin" ]
|
||||||
then
|
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
|
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
|
fi
|
||||||
|
|
||||||
tar cf - $out
|
tar cf - $out
|
||||||
|
Loading…
Reference in New Issue
Block a user