mirror of https://github.com/docker/cli.git
Merge pull request #3513 from thaJeztah/fix_ldflags
use GO_LDFLAGS instead of LDFLAGS to prevent inheriting unrelated options
This commit is contained in:
commit
abe41ad309
|
@ -63,23 +63,23 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then
|
|||
fi
|
||||
export GO_BUILDMODE
|
||||
|
||||
LDFLAGS="${LDFLAGS:-} -w"
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\""
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\""
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\""
|
||||
GO_LDFLAGS="${GO_LDFLAGS:-} -w"
|
||||
GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\""
|
||||
GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\""
|
||||
GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\""
|
||||
if test -n "${PLATFORM}"; then
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
|
||||
GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
|
||||
fi
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
|
||||
LDFLAGS="$LDFLAGS -extldflags -static"
|
||||
GO_LDFLAGS="$GO_LDFLAGS -extldflags -static"
|
||||
fi
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then
|
||||
# compiling statically with CGO enabled requires osusergo to be set.
|
||||
GO_BUILDTAGS="$GO_BUILDTAGS osusergo"
|
||||
fi
|
||||
if [ -n "$GO_STRIP" ]; then
|
||||
LDFLAGS="$LDFLAGS -s"
|
||||
GO_LDFLAGS="$GO_LDFLAGS -s"
|
||||
fi
|
||||
export LDFLAGS="$LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064
|
||||
export GO_LDFLAGS="$GO_LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064
|
||||
|
||||
export SOURCE="github.com/docker/cli/cmd/docker"
|
||||
|
|
|
@ -24,6 +24,6 @@ if [ "$(go env GOOS)" = "windows" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}")
|
||||
(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}")
|
||||
|
||||
ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker"
|
||||
|
|
|
@ -15,5 +15,5 @@ for p in cli-plugins/examples/* "$@" ; do
|
|||
mkdir -p "$(dirname "${TARGET_PLUGIN}")"
|
||||
|
||||
echo "Building $GO_LINKMODE $(basename "${TARGET_PLUGIN}")"
|
||||
(set -x ; CGO_ENABLED=0 GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}")
|
||||
(set -x ; CGO_ENABLED=0 GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}")
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue