Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Commit 0362cf0

Browse files
committed
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 <geoff@infradead.org>
1 parent 9ccdafa commit 0362cf0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@ ldflags="-X ${REPO_PATH}/version.Version=${version}"
1717

1818
host_build() {
1919
echo "Building $1"
20-
go build -i -ldflags "${ldflags}" -o "bin/$1" "${REPO_PATH}/cmd/$1"
20+
21+
if [[ "${GOHOSTARCH}" == "${GOARCH}" ]]; then
22+
install_dir="bin"
23+
else
24+
install_dir="bin/${GOARCH}"
25+
fi
26+
mkdir -p "${install_dir}"
27+
go build -ldflags "${ldflags}" -o "${install_dir}/$1" "${REPO_PATH}/cmd/$1"
2128
}
2229

2330
cross_build() {
31+
[[ -z "${NO_CROSS}" ]] || return 0
2432
local a
2533
for a in amd64 arm64; do
2634
echo "Building $a/$1"

0 commit comments

Comments
 (0)