Commit f3525d96 authored by Adam Reese's avatar Adam Reese

fix(build): create cross compile target in Makefile

parent 3611d6c1
......@@ -25,6 +25,10 @@ GO_PKGS ?= $(shell glide nv)
build:
@scripts/build-go.sh
.PHONY: build-cross
build-cross:
@BUILD_CROSS=1 scripts/build-go.sh
.PHONY: all
all: build
......
......@@ -9,14 +9,6 @@ readonly DIR="${GOPATH}/src/${REPO}"
source "${DIR}/scripts/common.sh"
if [[ -z "${VERSION:-}" ]]; then
VERSION=$(version_from_git)
fi
LDFLAGS="-s -X ${REPO}/pkg/version.DeploymentManagerVersion=${VERSION}"
echo "Build version: ${VERSION}"
build_binaries "$@"
exit 0
......@@ -10,6 +10,18 @@ error_exit() {
exit 1
}
assign_version() {
if [[ -z "${VERSION:-}" ]]; then
VERSION=$(version_from_git)
fi
}
assign_ldflags() {
if [[ -z "${LDFLAGS:-}" ]]; then
LDFLAGS="-s -X ${REPO}/pkg/version.DeploymentManagerVersion=${VERSION}"
fi
}
version_from_git() {
local git_tag=$(git describe --tags --abbrev=0 2>/dev/null)
local git_commit=$(git rev-parse --short HEAD)
......@@ -29,13 +41,19 @@ build_binary_cross() {
build_binaries() {
local -a targets=($@)
#TODO: accept specific os/arch
local build_cross="${BUILD_CROSS:-}"
if [[ ${#targets[@]} -eq 0 ]]; then
targets=("${ALL_TARGETS[@]}")
fi
for t in "${targets[@]}"; do
build_binary "$t"
if [[ -n "$build_cross" ]]; then
build_binary_cross "$t"
else
build_binary "$t"
fi
done
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment