From cbdce4a33d86ee309ae2ebd6f7e5685f4bfb3828 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Tue, 29 May 2018 11:26:19 -0700 Subject: [PATCH] build: Update for cross compile Put cross compiled binaries into a bin/$GOARCH/ directory. Add a new variable NO_CROSS to skip cross compiling of kolet. Signed-off-by: Geoff Levand --- build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build b/build index 44914a4ab..0715dcd16 100755 --- a/build +++ b/build @@ -17,10 +17,18 @@ ldflags="-X ${REPO_PATH}/version.Version=${version}" host_build() { echo "Building $1" - go build -i -ldflags "${ldflags}" -o "bin/$1" "${REPO_PATH}/cmd/$1" + + if [[ "${GOHOSTARCH}" == "${GOARCH}" ]]; then + install_dir="bin" + else + install_dir="bin/${GOARCH}" + fi + mkdir -p "${install_dir}" + go build -ldflags "${ldflags}" -o "${install_dir}/$1" "${REPO_PATH}/cmd/$1" } cross_build() { + [[ -z "${NO_CROSS}" ]] || return 0 local a for a in amd64 arm64; do echo "Building $a/$1"