fix(build): create cross compile target in Makefile

pull/291/head
Adam Reese 9 years ago
parent 3611d6c100
commit f3525d9668

@ -25,6 +25,10 @@ GO_PKGS ?= $(shell glide nv)
build: build:
@scripts/build-go.sh @scripts/build-go.sh
.PHONY: build-cross
build-cross:
@BUILD_CROSS=1 scripts/build-go.sh
.PHONY: all .PHONY: all
all: build all: build

@ -9,14 +9,6 @@ readonly DIR="${GOPATH}/src/${REPO}"
source "${DIR}/scripts/common.sh" 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 "$@" build_binaries "$@"
exit 0 exit 0

@ -10,6 +10,18 @@ error_exit() {
exit 1 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() { version_from_git() {
local git_tag=$(git describe --tags --abbrev=0 2>/dev/null) local git_tag=$(git describe --tags --abbrev=0 2>/dev/null)
local git_commit=$(git rev-parse --short HEAD) local git_commit=$(git rev-parse --short HEAD)
@ -29,13 +41,19 @@ build_binary_cross() {
build_binaries() { build_binaries() {
local -a targets=($@) local -a targets=($@)
#TODO: accept specific os/arch
local build_cross="${BUILD_CROSS:-}"
if [[ ${#targets[@]} -eq 0 ]]; then if [[ ${#targets[@]} -eq 0 ]]; then
targets=("${ALL_TARGETS[@]}") targets=("${ALL_TARGETS[@]}")
fi fi
for t in "${targets[@]}"; do for t in "${targets[@]}"; do
build_binary "$t" if [[ -n "$build_cross" ]]; then
build_binary_cross "$t"
else
build_binary "$t"
fi
done done
} }

Loading…
Cancel
Save