Let variable handle go binary name in scripts (#1532)

During e.g. cross-compiling, it is sometimes useful to be able to have
another binary than the default one as the compiler. This patch for the
build scripts lets "go" be the default value for the variable GO, and
the latter is then used as the go compiler.

Change-Id: I0adf7a661b26593d9b0ea902a61b631b80e76ae7
Signed-off-by: Joakim Roubert <joakimr@axis.com>
This commit is contained in:
Joakim Roubert
2020-03-25 20:35:07 +01:00
committed by GitHub
parent 47e4e7b582
commit bb0b4db228
7 changed files with 28 additions and 15 deletions

View File

@@ -5,6 +5,8 @@ cd $(dirname $0)/..
. ./scripts/version.sh
GO=${GO-go}
rm -rf bin/crictl bin/kubectl bin/k3s-agent bin/k3s-server bin/kubectl bin/k3s build/data
ln -s containerd bin/k3s-agent
ln -s containerd bin/k3s-server
@@ -49,7 +51,7 @@ fi
CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX}
go generate
"${GO}" generate
LDFLAGS="
-X github.com/rancher/k3s/pkg/version.Version=$VERSION
-X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8}
@@ -59,6 +61,6 @@ STATIC="-extldflags '-static'"
if [ "$DQLITE" = "true" ]; then
DQLITE_TAGS="dqlite"
fi
CGO_ENABLED=0 go build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
CGO_ENABLED=0 "${GO}" build -tags "$DQLITE_TAGS" -ldflags "$LDFLAGS $STATIC" -o ${CMD_NAME} ./cmd/k3s/main.go
./scripts/build-upload ${CMD_NAME} ${COMMIT}