Skip to content

Commit 85744a3

Browse files
author
Michael Hudson-Doyle
committed
use code generation for GITCOMMIT/VERSION too
Signed-off-by: Michael Hudson-Doyle <michael.hudson@linaro.org>
1 parent 3e10b93 commit 85744a3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ docs/GIT_BRANCH
2828
docs/VERSION
2929
docs/GITCOMMIT
3030
dockerversion/static.go
31+
dockerversion/details.go

hack/make.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,19 @@ if [ -z "$DOCKER_CLIENTONLY" ]; then
9494
DOCKER_BUILDTAGS+=" daemon"
9595
fi
9696

97-
rm -f dockerversion/static.go
97+
rm -f dockerversion/static.go dockerversion/details.go
98+
cat > dockerversion/details.go <<EOF
99+
// AUTOGENERATED FILE; see hack/make.sh
100+
package dockerversion
101+
102+
func init() {
103+
GITCOMMIT = "$GITCOMMIT"
104+
VERSION = "$VERSION"
105+
}
106+
EOF
98107

99108
# Use these flags when compiling the tests and final binary
100-
LDFLAGS='
101-
-w
102-
-X '$DOCKER_PKG'/dockerversion.GITCOMMIT "'$GITCOMMIT'"
103-
-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
104-
'
109+
LDFLAGS='-w'
105110
LDFLAGS_STATIC='-linkmode external'
106111
EXTLDFLAGS_STATIC='-static'
107112
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build

0 commit comments

Comments
 (0)