github.com/bdwilliams/libcompose@v0.3.1-0.20160826154243-d81a9bdacff0/script/cross-binary (about) 1 #!/bin/bash 2 set -e 3 4 if [ -z "$1" ]; then 5 # Remove windows platform because of 6 # https://github.com/mailgun/log/issues/10 7 OS_PLATFORM_ARG=(linux windows darwin freebsd) 8 else 9 OS_PLATFORM_ARG=($1) 10 fi 11 12 if [ -z "$2" ]; then 13 OS_ARCH_ARG=(386 amd64 arm) 14 else 15 OS_ARCH_ARG=($2) 16 fi 17 18 # Get rid of existing binaries 19 rm -f bundles/libcompose-cli* 20 21 # Build binaries 22 for OS in ${OS_PLATFORM_ARG[@]}; do 23 for ARCH in ${OS_ARCH_ARG[@]}; do 24 OUTPUT_BIN="bundles/libcompose-cli_$OS-$ARCH" 25 if test "$ARCH" = "arm"; then 26 if test "$OS" = "windows" || test "$OS" = "darwin"; then 27 # windows/arm and darwin/arm does not compile without cgo :-| 28 continue 29 fi 30 fi 31 if test "$OS" = "windows"; then 32 OUTPUT_BIN="${OUTPUT_BIN}.exe" 33 fi 34 echo "Building binary for $OS/$ARCH..." 35 GOARCH=$ARCH GOOS=$OS CGO_ENABLED=0 go build \ 36 -ldflags="-w -X github.com/docker/libcompose/version.GITCOMMIT=`git rev-parse --short HEAD`" \ 37 -o ${OUTPUT_BIN} ./cli/main 38 done 39 done