handle missing GOPATH and cygwin considerations

This commit is contained in:
Matthew Patton 2017-02-02 02:05:09 -05:00 committed by Matthew Patton
parent 049e1bbf73
commit 1d0cf3d909
1 changed files with 13 additions and 24 deletions

View File

@ -21,44 +21,33 @@ rm -f bin/*
rm -rf pkg/*
mkdir -p bin/
OLDIFS=$IFS
IFS=:
case $(uname) in
MINGW*|MSYS*)
IFS=";"
;;
esac
# Build!
echo "==> Building..."
set +e
gox \
${GOX:-$GOPATH/bin/gox} \
-os="${XC_OS}" \
-arch="${XC_ARCH}" \
-osarch="!darwin/arm !darwin/arm64" \
-ldflags "${GOLDFLAGS}" \
-output "pkg/{{.OS}}_{{.Arch}}/packer" \
.
set -e
# Move all the compiled things to the $GOPATH/bin
GOPATH=${GOPATH:-$(go env GOPATH)}
case $(uname) in
CYGWIN*)
GOPATH="$(cygpath $GOPATH)"
;;
esac
OLDIFS=$IFS
IFS=:
case $(uname) in
MINGW*)
IFS=";"
;;
MSYS*)
IFS=";"
;;
esac
MAIN_GOPATH=($GOPATH)
IFS=$OLDIFS
set -e
# Copy our OS/Arch to the bin/ directory
echo "==> Copying binaries for this platform..."
DEV_PLATFORM="./pkg/$(go env GOOS)_$(go env GOARCH)"
for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do
cp ${F} bin/
cp ${F} ${MAIN_GOPATH}/bin/
for F in $(find pkg/$(go env GOOS)_$(go env GOARCH) -mindepth 1 -maxdepth 1 -type f); do
cp -v ${F} bin/
cp -v ${F} ${GOPATH}/bin/
done
# Done!