mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +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"
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user