2020-10-27 04:23:58 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
#
|
|
|
|
# Runs `go build` with flags configured for binary distribution. All
|
|
|
|
# it does differently from `go build` is burn git commit and version
|
|
|
|
# information into the binaries, so that we can track down user
|
|
|
|
# issues.
|
|
|
|
#
|
2023-08-23 00:14:00 +01:00
|
|
|
# To include the embedded web client, build the web client assets
|
|
|
|
# before running this script. See README.md for details.
|
|
|
|
#
|
2020-10-27 04:23:58 +00:00
|
|
|
# If you're packaging Tailscale for a distro, please consider using
|
|
|
|
# this script, or executing equivalent commands in your
|
|
|
|
# distro-specific build system.
|
|
|
|
|
2020-11-03 22:39:45 +00:00
|
|
|
set -eu
|
2020-10-27 04:23:58 +00:00
|
|
|
|
2023-02-18 06:07:19 +00:00
|
|
|
go="go"
|
|
|
|
if [ -n "${TS_USE_TOOLCHAIN:-}" ]; then
|
|
|
|
go="./tool/go"
|
2021-06-03 21:14:32 +01:00
|
|
|
fi
|
2020-10-27 04:23:58 +00:00
|
|
|
|
2023-04-27 08:58:57 +01:00
|
|
|
eval `CGO_ENABLED=0 GOOS=$($go env GOHOSTOS) GOARCH=$($go env GOHOSTARCH) $go run ./cmd/mkversion`
|
2021-06-03 21:14:32 +01:00
|
|
|
|
2021-06-06 03:02:12 +01:00
|
|
|
if [ "$1" = "shellvars" ]; then
|
|
|
|
cat <<EOF
|
2023-02-18 06:07:19 +00:00
|
|
|
VERSION_MINOR="$VERSION_MINOR"
|
|
|
|
VERSION_SHORT="$VERSION_SHORT"
|
|
|
|
VERSION_LONG="$VERSION_LONG"
|
|
|
|
VERSION_GIT_HASH="$VERSION_GIT_HASH"
|
2021-06-06 03:02:12 +01:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-07-27 22:38:39 +01:00
|
|
|
tags=""
|
2023-02-18 06:07:19 +00:00
|
|
|
ldflags="-X tailscale.com/version.longStamp=${VERSION_LONG} -X tailscale.com/version.shortStamp=${VERSION_SHORT}"
|
2022-07-27 22:38:39 +01:00
|
|
|
|
|
|
|
# build_dist.sh arguments must precede go build arguments.
|
|
|
|
while [ "$#" -gt 1 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--extra-small)
|
|
|
|
shift
|
|
|
|
ldflags="$ldflags -w -s"
|
2023-02-08 23:25:00 +00:00
|
|
|
tags="${tags:+$tags,}ts_omit_aws,ts_omit_bird,ts_omit_tap,ts_omit_kube"
|
2022-07-27 22:38:39 +01:00
|
|
|
;;
|
|
|
|
--box)
|
|
|
|
shift
|
|
|
|
tags="${tags:+$tags,}ts_include_cli"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2023-06-04 18:07:50 +01:00
|
|
|
exec $go build ${tags:+-tags=$tags} -ldflags "$ldflags" "$@"
|