Split out massive list of cross compile deps+cmds
This commit is contained in:
parent
e620336a0c
commit
6a085080bc
|
@ -8,9 +8,20 @@ DEFAULT_CPU_COUNT = 2
|
|||
$script = <<SCRIPT
|
||||
GO_VERSION="1.7.4"
|
||||
|
||||
# Install Prereq Packages
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential curl git-core mercurial bzr libpcre3-dev pkg-config zip default-jre qemu gcc-4.8-arm-linux-gnueabihf libc6-dev-i386 silversearcher-ag jq htop vim unzip liblxc1 lxc-dev
|
||||
|
||||
# Install base dependencies
|
||||
sudo apt-get install -y build-essential curl git-core mercurial bzr libpcre3-dev pkg-config zip default-jre qemu silversearcher-ag jq htop vim unzip liblxc1 lxc-dev tree
|
||||
|
||||
# Install cross-compilation dependencies
|
||||
# ARM64 / Aarch64 compiler
|
||||
sudo apt-get install -y gcc-4.8-aarch64-linux-gnu binutils-aarch64-linux-gnu
|
||||
|
||||
# ARM hard-float (32bit) compiler
|
||||
sudo apt-get install -y gcc-4.8-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
|
||||
|
||||
# i386 dependencies
|
||||
sudo apt-get install -y libc6-dev-i386 linux-libc-dev:i386
|
||||
|
||||
# Setup go, for development of Nomad
|
||||
SRCROOT="/opt/go"
|
||||
|
|
|
@ -14,14 +14,7 @@ cd "$DIR"
|
|||
# Get the git commit
|
||||
GIT_COMMIT="$(git rev-parse HEAD)"
|
||||
GIT_DIRTY="$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"
|
||||
|
||||
# Determine the arch/os combos we're building for
|
||||
# XC_ARCH=${XC_ARCH:-"386 amd64"}
|
||||
# XC_OS=${XC_OS:-linux}
|
||||
|
||||
XC_ARCH=${XC_ARCH:-"386 amd64 arm arm64"}
|
||||
XC_OS=${XC_OS:-"linux"}
|
||||
XC_EXCLUDE=${XC_EXCLUDE:-"!darwin/arm !darwin/386"}
|
||||
LDFLAG="main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}"
|
||||
|
||||
# Delete the old dir
|
||||
echo "==> Removing old directory..."
|
||||
|
@ -29,30 +22,33 @@ rm -f bin/*
|
|||
rm -rf pkg/*
|
||||
mkdir -p bin/
|
||||
|
||||
# Build!
|
||||
echo "==> Building..."
|
||||
gox \
|
||||
-os="${XC_OS}" \
|
||||
-arch="${XC_ARCH}" \
|
||||
-osarch="${XC_EXCLUDE}" \
|
||||
-cgo \
|
||||
-ldflags "-X main.GitCommit='${GIT_COMMIT}${GIT_DIRTY}'" \
|
||||
-output "pkg/{{.OS}}_{{.Arch}}/nomad" \
|
||||
.
|
||||
|
||||
echo ""
|
||||
if [[ $(uname) == "Linux" ]]; then
|
||||
if pkg-config --exists lxc; then
|
||||
echo "==> Building linux_amd64-lxc..."
|
||||
go build \
|
||||
-tags lxc \
|
||||
-ldflags "-X main.GitCommit='${GIT_COMMIT}${GIT_DIRTY}+lxc'" \
|
||||
-o "pkg/linux_amd64-lxc/nomad"
|
||||
else
|
||||
# Require LXC for release mode
|
||||
echo "LXC not installed; install lxc-dev to build release binaries"
|
||||
exit 1
|
||||
fi
|
||||
echo "==> Building linux 386..."
|
||||
CGO_ENABLED=1 GOARCH="386" GOOS="linux" go build -ldflags "-X $LDFLAG" -o "pkg/linux_386/nomad"
|
||||
|
||||
echo "==> Building linux amd64..."
|
||||
CGO_ENBALED=1 GOARCH="amd64" GOOS="linux" go build -ldflags "-X $LDFLAG" -o "pkg/linux_amd64/nomad"
|
||||
|
||||
echo "==> Building linux amd64 with lxc..."
|
||||
CGO_ENBALED=1 GOARCH="amd64" GOOS="linux" go build -ldflags "-X $LDFLAG" -o "pkg/linux_amd64-lxc/nomad" -tags "lxc"
|
||||
|
||||
echo "==> Building linux arm..."
|
||||
CC="arm-linux-gnueabihf-gcc-4.8" GOOS=linux GOARCH="arm" CGO_ENABLED=1 go build -ldflags "-X $LDFLAG" -o "pkg/linux_arm/nomad"
|
||||
|
||||
echo "==> Building linux arm64..."
|
||||
CC="aarch64-linux-gnu-gcc-4.8" GOOS=linux GOARCH="arm64" CGO_ENABLED=1 go build -ldflags "-X $LDFLAG" -o "pkg/linux_arm64/nomad"
|
||||
|
||||
echo "==> Building windows 386..."
|
||||
CGO_ENABLED=1 GOARCH="386" GOOS="windows" go build -ldflags "-X $LDFLAG" -o "pkg/windows_386/nomad"
|
||||
|
||||
echo "==> Building windows amd64..."
|
||||
CGO_ENABLED=1 GOARCH="amd64" GOOS="windows" go build -ldflags "-X $LDFLAG" -o "pkg/windows_amd64/nomad"
|
||||
elif [[ $(uname) == "Darwin" ]]; then
|
||||
echo "==> Building darwin amd64..."
|
||||
CGO_ENABLED=1 GOARCH="amd64" GOOS="darwin" go build -ldflags "-X $LDFLAG" -o "pkg/darwin_amd64/nomad"
|
||||
else
|
||||
echo "Unable to build on $(uname). Use Linux or Darwin."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Move all the compiled things to the $GOPATH/bin
|
||||
|
@ -87,4 +83,4 @@ done
|
|||
# Done!
|
||||
echo
|
||||
echo "==> Results:"
|
||||
ls -hl bin/
|
||||
tree pkg/
|
||||
|
|
Loading…
Reference in New Issue