mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #8325 from mwhudson/do-not-use-X
Stop using -X flag to set global variables
This commit is contained in:
commit
d515590d15
6 changed files with 63 additions and 13 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -27,3 +27,6 @@ docs/AWS_S3_BUCKET
|
|||
docs/GIT_BRANCH
|
||||
docs/VERSION
|
||||
docs/GITCOMMIT
|
||||
dockerversion/static.go
|
||||
dockerversion/details.go
|
||||
dockerversion/init.go
|
||||
|
|
18
hack/make.sh
18
hack/make.sh
|
@ -94,12 +94,19 @@ if [ -z "$DOCKER_CLIENTONLY" ]; then
|
|||
DOCKER_BUILDTAGS+=" daemon"
|
||||
fi
|
||||
|
||||
rm -f dockerversion/static.go dockerversion/details.go dockerversion/init.go
|
||||
cat > dockerversion/details.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make.sh
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
GITCOMMIT = "$GITCOMMIT"
|
||||
VERSION = "$VERSION"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Use these flags when compiling the tests and final binary
|
||||
LDFLAGS='
|
||||
-w
|
||||
-X '$DOCKER_PKG'/dockerversion.GITCOMMIT "'$GITCOMMIT'"
|
||||
-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
|
||||
'
|
||||
LDFLAGS='-w'
|
||||
LDFLAGS_STATIC='-linkmode external'
|
||||
EXTLDFLAGS_STATIC='-static'
|
||||
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
||||
|
@ -115,7 +122,6 @@ TESTFLAGS+=" -test.timeout=${TIMEOUT}"
|
|||
EXTLDFLAGS_STATIC_DOCKER="$EXTLDFLAGS_STATIC -lpthread -Wl,--unresolved-symbols=ignore-in-object-files"
|
||||
LDFLAGS_STATIC_DOCKER="
|
||||
$LDFLAGS_STATIC
|
||||
-X $DOCKER_PKG/dockerversion.IAMSTATIC true
|
||||
-extldflags \"$EXTLDFLAGS_STATIC_DOCKER\"
|
||||
"
|
||||
|
||||
|
|
|
@ -3,6 +3,17 @@ set -e
|
|||
|
||||
DEST=$1
|
||||
|
||||
: ${IAMSTATIC:=true}
|
||||
|
||||
cat > dockerversion/static.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/binary and hack/make/dynbinary
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
IAMSTATIC = $IAMSTATIC
|
||||
}
|
||||
EOF
|
||||
|
||||
go build \
|
||||
-o "$DEST/docker-$VERSION" \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
|
|
|
@ -5,6 +5,14 @@ DEST=$1
|
|||
|
||||
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||
# dockerinit still needs to be a static binary, even if docker is dynamic
|
||||
cat > dockerversion/static.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/binary and hack/make/dynbinary
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
IAMSTATIC = true
|
||||
}
|
||||
EOF
|
||||
go build \
|
||||
-o "$DEST/dockerinit-$VERSION" \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
|
@ -39,7 +47,17 @@ fi
|
|||
# exported so that "dyntest" can easily access it later without recalculating it
|
||||
|
||||
(
|
||||
export LDFLAGS_STATIC_DOCKER="-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X $DOCKER_PKG/dockerversion.INITPATH \"$DOCKER_INITPATH\""
|
||||
export LDFLAGS_STATIC_DOCKER=""
|
||||
cat > dockerversion/init.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/dynbinary, hack/make/dyntest-integration and dyntest-unit
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
INITSHA1 = "$DOCKER_INITSHA1"
|
||||
INITPATH = "$DOCKER_INITPATH"
|
||||
}
|
||||
EOF
|
||||
export IAMSTATIC=false
|
||||
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
||||
source "$(dirname "$BASH_SOURCE")/binary"
|
||||
)
|
||||
|
|
|
@ -11,8 +11,14 @@ fi
|
|||
|
||||
(
|
||||
export TEST_DOCKERINIT_PATH="$INIT"
|
||||
export LDFLAGS_STATIC_DOCKER="
|
||||
-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\"
|
||||
"
|
||||
export LDFLAGS_STATIC_DOCKER=""
|
||||
cat > dockerversion/init.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/dynbinary, hack/make/dyntest-integration and dyntest-unit
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
INITSHA1 = "$DOCKER_INITSHA1"
|
||||
}
|
||||
EOF
|
||||
source "$(dirname "$BASH_SOURCE")/test-integration"
|
||||
)
|
||||
|
|
|
@ -11,8 +11,14 @@ fi
|
|||
|
||||
(
|
||||
export TEST_DOCKERINIT_PATH="$INIT"
|
||||
export LDFLAGS_STATIC_DOCKER="
|
||||
-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\"
|
||||
"
|
||||
export LDFLAGS_STATIC_DOCKER=""
|
||||
cat > dockerversion/init.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/dynbinary, hack/make/dyntest-integration and dyntest-unit
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
INITSHA1 = "$DOCKER_INITSHA1"
|
||||
}
|
||||
EOF
|
||||
source "$(dirname "$BASH_SOURCE")/test-unit"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue