diff --git a/scripts/build/.variables b/scripts/build/.variables index ece560174a..cc98a5f6dc 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -13,13 +13,13 @@ if test -n "${PLATFORM}"; then PLATFORM_LDFLAGS="-X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\"" fi -export LDFLAGS="\ +export GO_LDFLAGS="\ -w \ ${PLATFORM_LDFLAGS} \ -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\" \ -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\" \ -X \"github.com/docker/cli/cli/version.Version=${VERSION}\" \ - ${LDFLAGS:-} \ + ${GO_LDFLAGS:-} \ " GOOS="$(go env GOOS)" diff --git a/scripts/build/binary b/scripts/build/binary index e4c5e12a6b..f12a5ac86f 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -47,11 +47,11 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then 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 [ -n "$GO_STRIP" ]; then - LDFLAGS="$LDFLAGS -s -w" + GO_LDFLAGS="$GO_LDFLAGS -s -w" fi if [ "$(go env GOOS)" = "windows" ]; then @@ -75,6 +75,6 @@ echo "Building $GO_LINKMODE $(basename "${TARGET}")" export GO111MODULE=auto -go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}" +go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}" ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker" diff --git a/scripts/build/plugins b/scripts/build/plugins index f4e9c74600..2ce249bd3d 100755 --- a/scripts/build/plugins +++ b/scripts/build/plugins @@ -17,5 +17,5 @@ for p in cli-plugins/examples/* "$@" ; do echo "Building statically linked $TARGET" export CGO_ENABLED=0 - GO111MODULE=auto go build -o "${TARGET}" --ldflags "${LDFLAGS}" "github.com/docker/cli/${p}" + GO111MODULE=auto go build -o "${TARGET}" --ldflags "${GO_LDFLAGS}" "github.com/docker/cli/${p}" done diff --git a/scripts/build/plugins-osx b/scripts/build/plugins-osx index 8e870f4f05..f0390b91ad 100755 --- a/scripts/build/plugins-osx +++ b/scripts/build/plugins-osx @@ -12,7 +12,7 @@ export GOOS=darwin export GOARCH=amd64 export CC=o64-clang export CXX=o64-clang++ -export LDFLAGS="$LDFLAGS -linkmode external -s" +export GO_LDFLAGS="$GO_LDFLAGS -linkmode external -s" export LDFLAGS_STATIC_DOCKER='-extld='${CC} source ./scripts/build/plugins diff --git a/scripts/make.ps1 b/scripts/make.ps1 index 7dd3fafb4d..0b899f772d 100644 --- a/scripts/make.ps1 +++ b/scripts/make.ps1 @@ -109,12 +109,12 @@ Function Execute-Build($additionalBuildTags, $directory) { Write-Host "INFO: Building..." $buildTime=$(Get-Date).ToUniversalTime() - $env:LDFLAGS="-linkmode=internal ` + $env:GO_LDFLAGS="-linkmode=internal ` -X \""github.com/docker/cli/cli/version.Version=$dockerVersion\"" ` -X \""github.com/docker/cli/cli/version.GitCommit=$gitCommit\"" ` -X \""github.com/docker/cli/cli/version.BuildTime=$buildTime\""" if ($env:PLATFORM) { - $env:LDFLAGS="$env:LDFLAGS -X \""github.com/docker/cli/cli/version.PlatformName=$env:PLATFORM\""" + $env:GO_LDFLAGS="$env:GO_LDFLAGS -X \""github.com/docker/cli/cli/version.PlatformName=$env:PLATFORM\""" } # Generate a version in the form major,minor,patch,build @@ -138,7 +138,7 @@ Function Execute-Build($additionalBuildTags, $directory) { # By using --% we can use \"key=%foo%\" and have a environment variable foo that contains spaces go build $raceParm $verboseParm $allParm $optParm -tags "$buildTags" ` -o "$root\build\$directory.exe" ` - -ldflags --% "%LDFLAGS%" + -ldflags --% "%GO_LDFLAGS%" if ($LASTEXITCODE -ne 0) { Throw "Failed to compile" } Pop-Location; $global:pushed=$False